Skip to content

Commit

Permalink
protosynth: declick oscillators
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepVanlier committed Sep 16, 2024
1 parent 01d28b9 commit 8ea2263
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,16 @@ global(srate)
this.init_linearSVF_absolute(filter_freq - 1, 0);
);

function init_tri()
local()
instance(t, lint, ic1eq, ic2eq)
global(srate)
(
lint = 0;
ic1eq = ic2eq = 0;
t = 0;
);

function update_tri(freq, cur_spacing, attenuation)
local(filter_freq)
instance(dt, idt, pw, filter_freq, iconst)
Expand Down
31 changes: 26 additions & 5 deletions protosynth/saike_protosynth.jsfx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
desc:Saike Protosynth
options:maxmem=32000000
tags: instrument, synth, generator, synthesizer
version: 0.45
version: 0.46
author: Joep Vanlier
changelog: Add pulse width modulated square, pulse and triangle.
changelog: Declick voices when they are fighting.
license: MIT
provides:
protosynth_dependencies/*
Expand Down Expand Up @@ -854,9 +854,10 @@ global(
<?loop(i=1;N_OSCS, printf("osc%d_active, ", i); i += 1; );?>
)
instance(
declick,
current_f3_type,
mix1, mix2, mix3, mix4, mix21, mix22, mix31,
osc1, osc2, osc3, osc4, osc5, osc6, osc7, osc8, l, r
osc1, osc2, osc3, osc4, osc5, osc6, osc7, osc8, l, r, dcl, dcr,
g1, g2, g3, g4, g5, g6, g7, g8,
dg1, dg2, dg3, dg4, dg5, dg6, dg7, dg8,
<?loop(i=1;N_OSCS, printf("osc%d_wave, ", i); i += 1; );?>
Expand Down Expand Up @@ -892,6 +893,12 @@ instance(
);
?>

declick ? (
dcl = l;
dcr = r;
declick = 0;
);

<?
function gen_osc(i)
(
Expand Down Expand Up @@ -959,7 +966,14 @@ instance(
this.filter3.shriek.run_mj(o1 * current_f3_gain) / current_f3_gain;
)
) : o1;


dcl ? (
l += dcl;
r += dcr;
dcl *= 0.99;
dcr *= 0.99;
);

<?loop(i=1;8, printf("g%d += dg%d;\n", i, i); i += 1);?>
);

Expand Down Expand Up @@ -993,7 +1007,7 @@ global(
<?loop(i=1;N_MODULATORS, printf("mod%d_restart, mod%d_phase, ", i, i); i += 1; );?>
)
instance(
on, freq, pressed, current_sample, midi_idx, velocity, keyfollow_mod, target_freq, cur_pitch,
on, freq, pressed, current_sample, midi_idx, velocity, keyfollow_mod, target_freq, cur_pitch, declick,
<?loop(i=1;N_MODULATORS, printf("mod%d_lfo, ", i); i += 1; );?>
)
(
Expand All @@ -1015,10 +1029,17 @@ instance(
this.update_voice();
force_filter4_update = 1;
latest_voice = me;

declick = 1;

<?loop(i=1;8,
printf("this.osc%d.init_ssaw();\n", i); i += 1;
)?>

<?loop(i=1;8,
printf("this.osc%d.sqr.init_tri();\n", i); i += 1;
)?>

this.initialize_envelopes();
this.update_voice();
) : (state == -1) ? (
Expand Down

0 comments on commit 8ea2263

Please sign in to comment.