Repository navigation
osc: blep, and an analog polysynth with drift and unison spread #333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,281 @@ | ||
| # Analog -- a polysynth voice that is never quite in tune. | ||
| # | ||
| # What makes a vintage polysynth sound like one is mostly what its | ||
| # designers were fighting: oscillators that wander a few cents, a | ||
| # filter that sits slightly differently on every voice, two copies of a | ||
| # saw that are never in phase. Take that away and the same circuit | ||
| # sounds like a plug-in. This graph puts it back on purpose. | ||
| # | ||
| # THE OSCILLATORS DO NOT ALIAS. Three osc::blep saws (or pulses, or | ||
| # triangles) at the center and `Unison' cents either side, a second | ||
| # oscillator `Interval' semitones away, and a square an octave down for | ||
| # the sub. PolyBLEP is what keeps a high note from growing tones that | ||
| # are not in it. | ||
| # | ||
| # EVERY OSCILLATOR DRIFTS ON ITS OWN. A misc::drift per oscillator moves | ||
| # its pitch up to `Drift' cents at about a third of a hertz, seeded from | ||
| # the note and the oscillator so no two wander alike -- and a piece | ||
| # replays the same, because the seed is the note and not a clock. The | ||
| # cutoff drifts too, by a few percent. | ||
| # | ||
| # THE UNISON IS SPREAD. The flat copy leans left and the sharp one right | ||
| # by `Spread', and the center one is in both: the beating between them | ||
| # becomes width rather than a wobble in the middle. | ||
| # | ||
| # THE FILTER IS 24 dB AN OCTAVE: two filt::svf low-passes in series, | ||
| # the resonance on the second, the cutoff opened by its own envelope and | ||
| # by velocity, and tracking the keyboard by `Key Track'. | ||
|
|
||
| name "Analog"; | ||
| author "Misha Nasledov"; | ||
| description "A drifting, band-limited polysynth: three unison oscillators spread in stereo, a second oscillator, a sub, and a 24 dB filter."; | ||
| category "Leads and stabs"; | ||
|
|
||
| @wave1 = 0; | ||
| @wave1.widget = 1; | ||
| @wave1.min = 0; | ||
| @wave1.max = 2; | ||
| @wave1.step = 1; | ||
| @wave1.values = "Sawtooth,Pulse,Triangle"; | ||
| @wave1.label = "Wave"; | ||
| @wave1.group = "Oscillators"; | ||
|
|
||
| @wave2 = 1; | ||
| @wave2.widget = 1; | ||
| @wave2.min = 0; | ||
| @wave2.max = 2; | ||
| @wave2.step = 1; | ||
| @wave2.values = "Sawtooth,Pulse,Triangle"; | ||
| @wave2.label = "Wave 2"; | ||
| @wave2.group = "Oscillators"; | ||
|
|
||
| @semi2 = -12; | ||
| @semi2.widget = 1; | ||
| @semi2.min = -24; | ||
| @semi2.max = 24; | ||
| @semi2.step = 1; | ||
| @semi2.label = "Interval (semitones)"; | ||
| @semi2.group = "Oscillators"; | ||
|
|
||
| @mix2 = 0.3; | ||
| @mix2.widget = 1; | ||
| @mix2.min = 0; | ||
| @mix2.max = 1; | ||
| @mix2.label = "Osc 2 Level"; | ||
| @mix2.group = "Oscillators"; | ||
|
|
||
| @pw = 0.4; | ||
| @pw.widget = 1; | ||
| @pw.min = 0.05; | ||
| @pw.max = 0.95; | ||
| @pw.label = "Pulse Width"; | ||
| @pw.group = "Oscillators"; | ||
|
|
||
| @sub = 0.2; | ||
| @sub.widget = 1; | ||
| @sub.min = 0; | ||
| @sub.max = 1; | ||
| @sub.label = "Sub"; | ||
| @sub.group = "Oscillators"; | ||
|
|
||
| @unison = 7; | ||
| @unison.widget = 1; | ||
| @unison.min = 0; | ||
| @unison.max = 40; | ||
| @unison.label = "Unison (cents)"; | ||
| @unison.group = "Warmth"; | ||
|
|
||
| @spread = 0.7; | ||
| @spread.widget = 1; | ||
| @spread.min = 0; | ||
| @spread.max = 1; | ||
| @spread.label = "Spread"; | ||
| @spread.group = "Warmth"; | ||
|
|
||
| @drift = 4; | ||
| @drift.widget = 1; | ||
| @drift.min = 0; | ||
| @drift.max = 25; | ||
| @drift.label = "Drift (cents)"; | ||
| @drift.group = "Warmth"; | ||
|
|
||
| @cutoff = 1200; | ||
| @cutoff.widget = 1; | ||
| @cutoff.min = 40; | ||
| @cutoff.max = 12000; | ||
| @cutoff.label = "Cutoff (Hz)"; | ||
| @cutoff.group = "Filter"; | ||
|
|
||
| @res = 0.3; | ||
| @res.widget = 1; | ||
| @res.min = 0; | ||
| @res.max = 0.95; | ||
| @res.label = "Resonance"; | ||
| @res.group = "Filter"; | ||
|
|
||
| @envamt = 2500; | ||
| @envamt.widget = 1; | ||
| @envamt.min = 0; | ||
| @envamt.max = 10000; | ||
| @envamt.label = "Env Amount (Hz)"; | ||
| @envamt.group = "Filter"; | ||
|
|
||
| @keytrack = 0.5; | ||
| @keytrack.widget = 1; | ||
| @keytrack.min = 0; | ||
| @keytrack.max = 1; | ||
| @keytrack.label = "Key Track"; | ||
| @keytrack.group = "Filter"; | ||
|
|
||
| @fa = 5 ms; | ||
| @fa.widget = 1; | ||
| @fa.min = 0 ms; | ||
| @fa.max = 3000 ms; | ||
| @fa.label = "Attack"; | ||
| @fa.group = "Filter Envelope"; | ||
|
|
||
| @fd = 500 ms; | ||
| @fd.widget = 1; | ||
| @fd.min = 0 ms; | ||
| @fd.max = 5000 ms; | ||
| @fd.label = "Decay"; | ||
| @fd.group = "Filter Envelope"; | ||
|
|
||
| @fs = 0.3; | ||
| @fs.widget = 1; | ||
| @fs.min = 0.01; | ||
| @fs.max = 1; | ||
| @fs.label = "Sustain"; | ||
| @fs.group = "Filter Envelope"; | ||
|
|
||
| @fr = 400 ms; | ||
| @fr.widget = 1; | ||
| @fr.min = 0 ms; | ||
| @fr.max = 5000 ms; | ||
| @fr.label = "Release"; | ||
| @fr.group = "Filter Envelope"; | ||
|
|
||
| @a = 5 ms; | ||
| @a.widget = 1; | ||
| @a.min = 0 ms; | ||
| @a.max = 3000 ms; | ||
| @a.label = "Attack"; | ||
| @a.group = "Envelope"; | ||
|
|
||
| @d = 400 ms; | ||
| @d.widget = 1; | ||
| @d.min = 0 ms; | ||
| @d.max = 5000 ms; | ||
| @d.label = "Decay"; | ||
| @d.group = "Envelope"; | ||
|
|
||
| @s = 0.7; | ||
| @s.widget = 1; | ||
| @s.min = 0.01; | ||
| @s.max = 1; | ||
| @s.label = "Sustain"; | ||
| @s.group = "Envelope"; | ||
|
|
||
| @r = 300 ms; | ||
| @r.widget = 1; | ||
| @r.min = 70 ms; | ||
| @r.max = 5000 ms; | ||
| @r.label = "Release"; | ||
| @r.group = "Envelope"; | ||
|
|
||
| node ionode { | ||
| channels = 2; | ||
| out0 = vcal->out; | ||
| out1 = vcar->out; | ||
| play = env->play; | ||
| }; | ||
|
|
||
| node freq misc::midi2freq { | ||
| note = ionode->note; | ||
| }; | ||
|
|
||
| # One wanderer per oscillator, in cents, and one for the cutoff. | ||
| node driftc misc::drift { rate = 0.3; depth = @drift; seed = ionode->note; }; | ||
| node driftl misc::drift { rate = 0.37; depth = @drift; seed = ionode->note + 1000; }; | ||
| node driftr misc::drift { rate = 0.29; depth = @drift; seed = ionode->note + 2000; }; | ||
| node drift2 misc::drift { rate = 0.33; depth = @drift; seed = ionode->note + 3000; }; | ||
| node driftf misc::drift { rate = 0.2; depth = 0.05; seed = ionode->note + 4000; }; | ||
| node drifts misc::drift { rate = 0.31; depth = @drift; seed = ionode->note + 5000; }; | ||
|
|
||
| node oscc osc::blep { | ||
| freq = freq->out * exp2(driftc->out / 1200); | ||
| waveform = @wave1; | ||
| pw = @pw; | ||
| phase = 0; | ||
| }; | ||
| node oscl osc::blep { | ||
| freq = freq->out * exp2((driftl->out - @unison) / 1200); | ||
| waveform = @wave1; | ||
| pw = @pw; | ||
| phase = 0.33; | ||
| }; | ||
| node oscr osc::blep { | ||
| freq = freq->out * exp2((driftr->out + @unison) / 1200); | ||
| waveform = @wave1; | ||
| pw = @pw; | ||
| phase = 0.67; | ||
| }; | ||
| node osc2 osc::blep { | ||
| freq = freq->out * exp2((@semi2 * 100 + drift2->out) / 1200); | ||
| waveform = @wave2; | ||
| pw = @pw; | ||
| phase = 0.5; | ||
| }; | ||
| node subosc osc::blep { | ||
| freq = freq->out * 0.5 * exp2(drifts->out / 1200); | ||
| waveform = 1; | ||
| pw = 0.5; | ||
| phase = 0.25; | ||
| }; | ||
|
|
||
| # What both sides share, and the unison leaning each way. | ||
| node common math::add { | ||
| in0 = oscc->out + osc2->out * @mix2; | ||
| in1 = subosc->out * @sub; | ||
| }; | ||
| node mixl math::add { | ||
| in0 = common->out + oscl->out * (1 + @spread) * 0.5; | ||
| in1 = oscr->out * (1 - @spread) * 0.5; | ||
| }; | ||
| node mixr math::add { | ||
| in0 = common->out + oscr->out * (1 + @spread) * 0.5; | ||
| in1 = oscl->out * (1 - @spread) * 0.5; | ||
| }; | ||
|
|
||
| node fenv env::adsr { | ||
| a = @fa; | ||
| d = @fd; | ||
| s = @fs; | ||
| r = @fr; | ||
| trigger = ionode->trigger; | ||
| }; | ||
|
|
||
| node cut math::min { | ||
| in0 = (@cutoff + fenv->out * @envamt * ionode->velocity) * | ||
| exp2(@keytrack * (ionode->note - 60) / 12) * (1 + driftf->out); | ||
| in1 = 18000; | ||
| }; | ||
|
|
||
| node lp1l filt::svf { in = mixl->out * 0.2; cutoff = cut->out; res = 0; }; | ||
| node lp2l filt::svf { in = lp1l->out_low; cutoff = cut->out; res = @res; }; | ||
| node lp1r filt::svf { in = mixr->out * 0.2; cutoff = cut->out; res = 0; }; | ||
| node lp2r filt::svf { in = lp1r->out_low; cutoff = cut->out; res = @res; }; | ||
|
|
||
| node env env::adsr { | ||
| a = @a; | ||
| d = @d; | ||
| s = @s * ionode->velocity; | ||
| r = @r; | ||
| p = ionode->velocity; | ||
| trigger = ionode->trigger; | ||
| }; | ||
|
|
||
| node vcal mixer::mul { in0 = lp2l->out_low; in1 = env->out; }; | ||
| node vcar mixer::mul { in0 = lp2r->out_low; in1 = env->out; }; | ||
|
|
||
| io ionode; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.