libraryextensions/audio/demos/Instruments.xtl
Instruments.xtl -- the instruments of the synthesizer demos (synth.xtl, scope.xtl): music as arrays. An ordinary X_eTaL library beside them. Import: "in:" u_se< "Instruments"
ˡh̲z : Num a => a -> Float
a note's pitch: k semitones above A4 (440 Hz)
ˡh̲z ← { k → 440.0 × 2.0 ^ (f̲loat k) ÷ 12.0 }
Used in: ˡb̲ar
n : Int
the times of the samples of a 0.25 s step, and its envelope: a quick attack, a decay toward 60%, and a release at the end
n ← f̲loor 0.25 × ˡrate
env : Float
env ← (1.0 m̲in t ÷ 0.01) × (((0.25 − t) ÷ 0.06) m̲in 1.0) × 0.6 + 0.4 × e̲xp 0.0 − t ÷ 0.12
Used in: ˡb̲ar
ˡt̲one : Float -> Float -> Float
a tone: three harmonics (1, 1/2, 1/4) at each frequency of f, one row per frequency, along the times tt
ˡt̲one ← { f tt → x ← 6.283185307179586 × f '× t̲able tt (s̲in x) + (0.5 × s̲in 2.0 × x) + 0.25 × s̲in 3.0 × x }
Used in: ˡb̲ar
chords : Int
the chords, as semitones from A4: C, Am, F, G (four notes each)
chords ← 4 4 r̲eshape -9 -5 -2 3 -12 -9 -5 0 -16 -12 -9 -4 -14 -10 -7 -2
Used in: ˡb̲ar
ˡb̲ar : Int -> Float
bar b (from 1): the chord's notes in turn (one row each, enveloped, then laid end to end), over its root two octaves down for the whole bar, mixed to stereo (2 by 22048): the arpeggio more to the right, the bass more to the left
ˡb̲ar ← { b → k ← (1 + (b − 1) m̲od 4) s̲elect₁ chords mel ← r̲avel 0.2 × ((ˡh̲z k) ˡt̲one t) × (4 c̲at n) r̲eshape env tb ← (f̲loat (r̲ange 4 × n) − 1) ÷ ˡrate low ← r̲avel (ˡh̲z (f̲irst k) − 24) ˡt̲one tb bass ← 0.25 × low × (1.0 m̲in tb ÷ 0.02) × ((1.0 − tb) ÷ 0.1) m̲in 1.0 1.5 × (2 c̲at 4 × n) r̲eshape ((0.7 × bass) + 0.3 × mel) c̲at (0.3 × bass) + 0.7 × mel }