summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranastasisg <anastasis@learnworlds.com>2025-11-28 15:25:16 +0200
committeranastasisg <anastasis@learnworlds.com>2025-11-28 15:25:16 +0200
commitd394d6e056788bfb3764463cd04d796f74924e15 (patch)
treec28947dbac6eec56046ab717d5ade8dca09af94d
parent5f3058f662b7222ea47a49ea2a450aa0491b5496 (diff)
downloadsynth-project-d394d6e056788bfb3764463cd04d796f74924e15.tar.gz
synth-project-d394d6e056788bfb3764463cd04d796f74924e15.tar.bz2
synth-project-d394d6e056788bfb3764463cd04d796f74924e15.zip
add lfo-on-pitch toggle
-rw-r--r--src/synth_engine.h1
-rw-r--r--src/synth_engine_v2.c8
-rw-r--r--src/synth_gui.c2
3 files changed, 9 insertions, 2 deletions
diff --git a/src/synth_engine.h b/src/synth_engine.h
index 254bf21..6bc504a 100644
--- a/src/synth_engine.h
+++ b/src/synth_engine.h
@@ -110,6 +110,7 @@ typedef struct {
adsr_t adsr;
adsr_t f_adsr;
+ int lfo_on_pitch;
int lfo_on_cutoff;
float lfo_index;
lfo_t lfo;
diff --git a/src/synth_engine_v2.c b/src/synth_engine_v2.c
index 41cbcf4..538a840 100644
--- a/src/synth_engine_v2.c
+++ b/src/synth_engine_v2.c
@@ -274,7 +274,10 @@ make_sample(synth_t * synth, unsigned int sample_rate, int frame)
float targ_freq = note->freq * CC_GET(pitch);
float lfo_value = osc_sin(note->lfo_index);
- targ_freq = targ_freq + targ_freq * CC_GET(lfo_amp) * lfo_value; //can switch to glfo
+ if (synth->lfo_on_pitch) {
+ targ_freq = targ_freq +
+ targ_freq * CC_GET(lfo_amp) * lfo_value; // can switch to glfo
+ }
note->lfo_index = osc_sin_next(CC_GET(lfo_freq), note->lfo_index);
@@ -524,7 +527,7 @@ init_synth(void)
CC(synth->cc_cutoff, "cutoff", 50, 22000, 30, 5000);
//CC(synth->cc_resonance, "resonance", 1, 10, .02, 1);
CC(synth->cc_resonance, "resonance", 0.01, 10, .02, 0.5);
- CC(synth->cc_lfo_freq, "lfo_freq", 1, 1000, 2, 1);
+ CC(synth->cc_lfo_freq, "lfo_freq", 0.1, 10, .01, 1);
CC(synth->cc_lfo_amp, "lfo_amp", 0, 1, .01f, 0);
CC(synth->cc_pitch, "pitch", -3, 4, 0.01f, 1);
CC(synth->cc_adsr_a, "attack", 0, 3, 0.01f, 0.00);
@@ -559,6 +562,7 @@ init_synth(void)
synth->f_adsr.r = 0.4;
synth->f_adsr.elapsed = 0;
+ synth->lfo_on_pitch = 0;
synth->lfo_on_cutoff = 0;
synth->lfo_index = 0.0f;
diff --git a/src/synth_gui.c b/src/synth_gui.c
index 4cdf37d..265b539 100644
--- a/src/synth_gui.c
+++ b/src/synth_gui.c
@@ -1258,6 +1258,8 @@ draw_main(synth_t *synth)
draw_bars(synth, 20, 20, 200, 16, 3);
draw_text(synth, WIDTH / 2 - 108, 20);
+ synth->lfo_on_pitch = GuiCheckBox((Rectangle){WIDTH / 2.0 - 108 + 120, 20, 12, 12},
+ "lfo", synth->lfo_on_pitch);
//synth->viz.osc_enabled = GuiCheckBox((Rectangle){ x + width - 170, y, 16, 16 }, "osc", synth->viz.osc_enabled);
if (synth->viz.osc_enabled) {