DuoSynth
The DuoSynth is a duophonic two-oscillator synth inspired by the ARP Odyssey, following its Rev 3 (1978 to about 1981): two VCOs with hard sync, white and pink noise, a ring modulator, a sample and hold, a resonant 24 dB per octave low-pass with a static high-pass behind it, an ADSR and an AR envelope, one LFO and a portamento. It sounds thin, bright and biting: a lead that cuts, sync sweeps, S&H bleeps.
import audioinstruments._rack.adapter as adapter
inst = adapter.create(48000, voice="duosynth")
audio_out.play(inst.output)
inst.program_change(3) # Duophonic Thirds
inst.note_on(60, 100)
inst.note_on(64, 100)
Two keys, two oscillators
It is one voice that plays two keys. VCO-1 plays the lowest key you hold and VCO-2 the highest; one key alone plays on both, and a third key between them does nothing. Let go of the high key and VCO-2 moves to the highest of the keys still held, without restarting the envelopes. Both oscillators go through one filter and one VCA, as on the original [M p.18-19]. The one-voice pool that does this is in polyphony.md.
The patch always sets the "duo" key priority, so create(priority=...) has
no effect. If you set inst.priority = "last" once it is playing, both VCOs
follow the one line instead.
With sync on, VCO-2 restarts on every cycle of VCO-1, so its coarse and fine
controls change the overtones rather than the pitch [M p.8]. Turn sync off to
play two notes.
The panel
The controls are the original’s, with sliders from 0 to 10.
VCO-1 has a sawtooth or pulse switch (vco1_wave), a pulse width from 50%
to 5% (vco1_width), pulse width modulation from the LFO sine or the ADSR
(vco1_pwm_src, vco1_pwm), pitch modulation from the LFO sine or square
(vco1_fm_lfo_wave, vco1_fm_lfo) and from the S/H or the ADSR
(vco1_fm_sh_src, vco1_fm_sh). vco1_coarse is in semitones, -36 to +36,
and vco1_fine in cents. The LF switch (vco1_lf) turns VCO-1 into a slow
oscillator from 0.2 Hz to 20 Hz, set by vco1_coarse, that ignores the keys,
the bend, the wheel, the transpose and the portamento [M p.7]: use it to
modulate VCO-2 through the mixer, or as a click track.
VCO-2 has the same wave and width controls, vco2_fine from -400 to +400
cents, pitch modulation from the LFO sine or the live S/H mixer
(vco2_fm_lfo_src, vco2_fm_lfo) and from the S/H or the ADSR
(vco2_fm_sh_src, vco2_fm_sh), and the sync switch.
The mixer has a level for each VCO (mix_vco1, mix_vco2) and a third
for the noise or the ring modulator (mix_noise, mix_noise_src), with the
noise white or pink (noise_type). The ring modulator is the exclusive-OR of
the two pulse waves [M p.19], so it follows their widths.
The sample and hold has its own two-input mixer: VCO-1’s saw or pulse
(sh_vco1, sh_vco1_wave) and pink noise or VCO-2’s pulse (sh_noise,
sh_noise_src). It takes a new level on each rising edge of the LFO or at each
key press (sh_trig), and sh_lag glides between the levels.
The filter is a four-pole low-pass from 16 Hz to 16 kHz (vcf_cutoff,
vcf_resonance) that sings at the top of its resonance. Its cutoff takes the
keyboard from C3 or the S/H mixer (vcf_kybd_src, vcf_kybd), the S/H or the
LFO sine (vcf_sh_src, vcf_sh), the ADSR or the AR (vcf_env_src,
vcf_env) and the velocity (vel_vcf), all at audio rate, so the S/H mixer
into the cutoff gives clean FM sidebands. Behind it is a 6 dB per octave
high-pass (hpf_cutoff), off at 0.
The envelopes are an ADSR (adsr_attack, adsr_decay, adsr_sustain,
adsr_release) and an AR (ar_attack, ar_release), on the original’s time
ranges [M p.19]. Each opens with the key or repeats at the LFO rate while a key
is held (adsr_trig, ar_trig). trigger "multi" restarts them at every
key, and "single" only when you play from no keys held, so you can play
legato. The VCA is a gain that always passes the sound (vca_gain) plus a
level driven by the ADSR or the AR (vca_env, vca_level), and vel_vca makes
it follow the velocity.
lfo_rate sets the LFO from 0.2 Hz to 20 Hz. portamento glides each VCO
from its own last note, up to 1.5 s. transpose shifts both VCOs and the
filter’s keyboard follow by -2, 0 or +2 octaves [M p.6]. The pitch bend moves
both VCOs by bend_range semitones (8 fresh, about the pads’ 2/3 octave
[M p.19]), and the mod wheel adds the LFO sine to both, up to a semitone either
way, as the vibrato pad does. drift is the warm-up drift, up to 1/30 of a
semitone at 10 [M p.18].
Where each source goes
Every rule the voice follows, the control that sets it, its depth at 10 and
the constant in lib/audioinstruments/_rack/modules/duosynth/voice.py that sets it. CV is 0.1
for an octave, so 0.7 is seven octaves, and every sum goes through unclamped
except where the row says so.
Rule |
Source, destination |
Control |
Depth at 10 |
Constant |
|---|---|---|---|---|
|
LFO sine, VCO-1 pitch |
|
half an octave either way |
|
|
LFO square, VCO-1 pitch |
|
1.5 octaves either way |
|
|
S/H, VCO-1 pitch |
|
2 octaves either way |
|
|
ADSR, VCO-1 pitch |
|
up 9 octaves |
|
|
LF switch, VCO-1 rate |
|
0.2 Hz to 20 Hz |
|
|
Drift, VCO-1 and VCO-2 |
|
1/30 semitone |
|
|
LFO sine, VCO-2 pitch |
|
half an octave either way |
|
|
S/H mixer, VCO-2 pitch |
|
2 octaves either way |
|
|
S/H or ADSR, VCO-2 pitch |
|
as for VCO-1 |
|
|
VCO-1’s cycle, VCO-2’s phase |
|
on or off |
none |
|
Low key, VCO-1; high key, VCO-2 |
always |
none |
none |
|
Manual, width |
|
50% to 5% |
|
|
ADSR, width |
|
up 45% |
|
|
LFO sine, width |
|
15% either way |
|
|
The sum, width |
none |
held between 5% and 95% |
|
|
Pulse XOR pulse, mixer |
|
gain 1 |
none |
|
Noise, mixer |
|
3 times a VCO slider’s gain |
|
(mixer) |
Mixer, filter input |
|
gain 0.5 |
|
|
S/H mixer, S/H |
|
gain 2 |
|
|
S/H lag |
|
1 ms to 1 s |
|
|
Keyboard, cutoff |
|
an octave an octave, from C3 |
|
|
S/H mixer, cutoff |
|
2 octaves either way |
|
|
S/H, cutoff |
|
2 octaves either way |
|
|
LFO sine, cutoff |
|
2 octaves either way |
|
|
ADSR or AR, cutoff |
|
up 7 octaves |
|
|
Velocity, cutoff |
|
3 octaves down at velocity 0 |
|
|
Resonance |
|
sings from about 9 |
|
|
LFO gate, ADSR or AR |
|
repeats at |
none |
|
Each key, ADSR and AR |
|
|
none |
|
ADSR or AR, cutoff |
|
as |
|
|
ADSR or AR, VCA |
|
as |
|
|
Gain, VCA |
|
gain 2 |
|
|
Envelope, VCA |
|
gain 2.4 |
|
|
Velocity, VCA |
|
silent at velocity 0 |
|
|
Bend, VCO-1 and VCO-2 |
|
8 semitones fresh, never glides |
|
|
Wheel, VCO-1 and VCO-2 |
mod wheel |
a semitone either way |
|
|
Filter, high-pass, VCA |
|
16 Hz to 16 kHz |
|
|
Lever, VCO-1, VCO-2 and keyboard follow |
|
2 octaves either way |
none |
None of the bend, the wheel, the key, the transpose or the portamento reach an
LF VCO-1, and neither the bend nor the wheel moves the cutoff. Each rule has
its test in tests/test_synth_duosynth.py, named test_route_ and the rule:
test_route_vco1_pitch, test_route_vco2_pitch, test_route_sync,
test_route_duophonic_keys, test_route_pulse_width, test_route_ring,
test_route_sh_sample, test_route_filter_cutoff,
test_route_envelope_triggers, test_route_vcf_envelope_and_vca_envelope,
test_route_vca, test_route_bend_and_wheel, test_route_hpf_position and
test_route_transpose, with test_route_wheel for the wheel’s depth.
Where the numbers come from
The owner’s manual of the 2016 reissue, ARP ODYSSEY / ARP ODYSSEY Module Owner’s Manual [M], gives the panel, the ranges, the FM depths (the LFO sine half an octave, its square 1.5, the S/H 2 and the ADSR 9 octaves), the pulse width modulation (ADSR +45%, LFO +15%), the keyboard follow from C3, the routing of mixer, filter, high-pass and VCA, and the envelope times (pages 4 to 13 and 18 to 19). The rest are choices made here, and they are:
The coarse sliders’ span of 36 semitones either way, and the sliders reaching their depth in a straight line.
Every filter depth in octaves other than the keyboard follow.
The filter’s keyboard follow tracking the low key, VCO-1’s.
The wheel’s vibrato depth of a semitone, and the bend standing in for the pitch pads.
The S/H mixer’s gain of 2, and the live S/H mixer, not the held level, going into VCO-2’s FM and the cutoff.
A portamento of constant time rather than the original’s time per octave.
driftreaching 1/30 of a semitone at 10, the manual’s warm-up figure, as its ceiling.The levels: the noise slider at 3 times a VCO slider’s gain (
NOISE_LEVEL(3.0)), so a noise patch sits with the others, and the VCA’sVCA_GAIN_SCALE(2.0) andVCA_LEVEL_SCALE(2.4), so a chord sits within a dB or so of the other the instruments.The resonance reaching 1.05 of the ladder’s at 10 (
RES_TOP(1.05)), so that it sustains a tone, with a short kick into a quiet filter set above 9 to start it singing, as an analogue filter’s own noise would (SELF_OSC_FROM(0.92),SEED_LEVEL(0.05)).A 10 Hz DC block on the output (
DC_HZinlib/audioinstruments/_rack/modules/duosynth/output.py), because sync and the ring modulator leave an offset that moves with the pitches and the widths.
The filter, and what is not built
The original’s filter changed between revisions: Rev 1’s is 12 dB per octave, Rev 2’s and Rev 3’s 24 dB [M p.10, p.19], and the reissue switches among all three. This one follows Rev 3 alone, for three reasons. The panel copied here is the reissue’s, and its maker describes the reissue as based on Rev 3. Rev 3’s filter is described as staying stable at high resonance, which suits a filter driven by audio-rate FM and sync. And one filter keeps the controls to the original’s: the filter type switch exists only on the reissue.
No source describes the Rev 3 filter’s circuit, so it is not modelled. It runs
on the rack’s least saturating ladder, LadderCore(sample_rate, "clean") with
four poles, which thins out in the bass as the resonance rises, as the Rev 3
is said to. Treat it as a stand-in.
Not built: the 12 dB Rev 1 and the Rev 2 filters and the type switch; a repeating envelope with no key held (the LFO repeats run only while you hold a key, because a quiet voice parks); the portamento’s per-octave timing and its mode switch; and the pedal, external audio, drive and CV inputs.
Patches and the demo
There are twelve patches: Init, Duo Lead, Sync Lead, Duophonic Thirds, Ring
Bell, PWM Strings, Pluck Bass, S&H Steps, Square Trill, Repeat Pulse, Noise Wind
and FM Clang. The ten macros are vcf_cutoff, vcf_resonance, vcf_env,
adsr_attack, adsr_decay, adsr_sustain, adsr_release, vco2_fine,
lfo_rate and portamento, each covering its control’s whole range.
inst.patch.set_control(inst.voice_pool, name, value) sets any other control by
its name in audioinstruments._rack.instruments.duosynth.SETTINGS.
examples/duosynth_demo.py plays all eleven musical patches in order, writes
wav_exports/duosynth_demo.wav, and checks that every section sounds, nothing
clips, and each has energy above 120 Hz and next to none below 40 Hz, so it can
be heard on small speakers. examples/poly_render.py duosynth checks that a
single voice does not click.
What it costs
examples/poly_bench.py duosynth renders 1024-frame buffers with two notes held
(on the desktop the other figures come from):
block |
CPython ms |
factor |
MicroPython ms |
factor |
|---|---|---|---|---|
64 |
8.8 |
2.4 |
3.0 |
7.2 |
128 (the default) |
3.9 |
5.5 |
1.6 |
13.3 |
256 |
1.7 |
12.9 |
1.0 |
20.5 |
The factor is seconds of audio per second of work, the middle of three runs. A second key costs next to nothing, since both keys play on the one voice. With nothing playing, the instrument costs about 1.6 ms a buffer on CPython (0.6 ms on MicroPython).
The graph form
Wherever audiodsp has audiograph with its TANH node (0.6.11.dev5 and later),
create() gives you the DuoSynth compiled to one C graph, as the Poly106 is
(above); engine="rack" asks for the rack. Its four modules
declare fragments: the voice, the LFO, the output’s DC block, and the MIDI module
in the "duo" priority this instrument plays in, which hands the high key to
VCO-2 as two more controls. It plays the same panel, patches and macros. Init,
Duo Lead, Sync Lead, Duophonic Thirds, Ring Bell, PWM Strings, Pluck Bass, Repeat
Pulse and FM Clang agree with the rack to 64 counts at the worst and 6 rms over a
note, over a line with two keys held at once, and over three keys held through
each other (measured worst: 60 counts and 2.7 rms, Duo Lead’s two gliding keys
held; most are under 12 counts and 1 rms). Every control is held to the same bar,
and tests/test_graph_duosynth.py holds them there, with the rack given the
board’s rounding, at block sizes of 64, 128 and 256. CPython and MicroPython
render the same bytes. With two keys held at the default 128-frame block, a
1024-frame buffer takes 0.32 ms on CPython (67x real time, against the rack’s
2.4 ms) and 0.57 ms on MicroPython (37x, against 1.4 ms). How the voice is put
together is in
architecture.md. Where they differ, and why:
The graph’s LFO runs a few parts in 100,000 of its rate away from the rack’s, as the Mono101’s does (below). Square Trill, an LFO or the wheel on a pitch, and the S&H on the LFO’s clock are the rack’s to 20 counts over a note of a tenth of a second, and the rack’s level and brightness to 0.01 dB and 1% over the line.
The filter envelope reaches the cutoff through an int16 envelope wire, where the rack rounds its float envelope once, so the cutoff is a count (0.7 cents) off here and there. You can’t hear it, but a filter that sings on its own (resonance over 9.2) drifts in phase from it over a note. With the envelope off the singing filter is the rack’s to 8 counts, kick and all; with it on, its level and brightness are the rack’s to 0.01 dB and 0.1%. An oscillator swept by the envelope, or one at LF with a long portamento, is the same.
The noise is the graph’s own generator, so Noise Wind and S&H Steps (the S&H of a pink noise) have the rack’s level and brightness, not its samples. Noise Wind is within 0.11 dB and 0.4%. S&H Steps is 0.1 dB and 12% brighter over a long note, which is inside the spread of the rack against itself with another noise seed (0.9 to 1.25). The pink noise is the MonoSynth’s bank of one-poles (below), within 0.2 dB of the rack’s in every octave band to 20 kHz.
After a rest a voice wakes with its free-running oscillators where they were left, and its drift where it stopped. Under the audio pump a park can fall a block from where
step()puts it, so patches that rest and then play again (Init, Duo Lead, Sync Lead, S&H Steps, Square Trill) can wake at another phase there.The voice takes the voice mix’s gain and the output’s scale into its VCA and rounds once, as the rack does (architecture.md): a quiet tail’s white floor is 0.9 of the rack’s.