1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Top-level [`Instrument`] container + [`InstrumentType`] enum.
//!
//! Every [`crate::core::module::Module`] carries a vector of
//! [`Instrument`]s. A Track holds an instrument *index* (invariant
//! for the track's lifetime); the runtime resolves the actual
//! voice each time a Cell triggers.
//!
//! [`InstrumentType`] discriminates the variants the player knows
//! how to render:
//! - `Empty` — placeholder slot.
//! - `Default(InstrDefault)` — the dominant case (sampled, XM/MOD/
//! S3M/IT).
//! - `Midi(InstrMidi)` — routed to an external MIDI synth via the
//! player's observer chain.
//! - `Opl(InstrOpl)` *(cfg `import_s3m`)* — Yamaha OPL FM, opaque
//! to the sample engine.
//! - `Sid(InstrSid)` / `RobSid(InstrRobSid)` *(cfg `import_sid`)* —
//! MOS6581 / Rob-Hubbard-style C64, opaque to the sample engine.
//!
//! Euclidean rhythms are not an instrument kind — they are a Track
//! kind ([`Track::Euclidean`](crate::core::daw::track::Track::Euclidean)).
use ;
use crateInstrDefault;
use crateInstrMidi;
use String;
//===========================================================================
/// Instrument payload, discriminated by kind.
//
// `large_enum_variant` allowed: `Default` is ~2 KiB (mostly
// `sample_for_pitch: [Option<usize>; 120]`) vs ~50–100 B for the others.
// Boxing would help only when modules carry many `Empty` slots (rare),
// cost one extra allocation per instrument at load, hurt iteration
// cache locality, and break the public API at every construction /
// match site.
/// One entry in [`Module::instrument`].
///
/// Pairs a name with the actual instrument payload (the
/// [`InstrumentType`] enum) plus a per-instrument mute switch.
/// Tracks reference instruments by their index into the
/// `Module.instrument` vector; the mute flag lets an editor solo
/// or silence an instrument without dropping it from the bank.
///
/// [`Module::instrument`]: crate::core::module::Module::instrument