summaryrefslogtreecommitdiffstats
path: root/src/synth_engine.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2023-09-14 14:30:52 +0300
committergramanas <anastasis.gramm2@gmail.com>2023-09-14 14:30:52 +0300
commit2a2a1b0d9fc4bfffcaf23d2f66d38d6927d76bbe (patch)
treefbb51f0f79017fb11946a69e7171c4bb751b63a7 /src/synth_engine.c
parent12ef243815d409e5f4039502f378d43ecdf7abaa (diff)
downloadsynth-project-2a2a1b0d9fc4bfffcaf23d2f66d38d6927d76bbe.tar.gz
synth-project-2a2a1b0d9fc4bfffcaf23d2f66d38d6927d76bbe.tar.bz2
synth-project-2a2a1b0d9fc4bfffcaf23d2f66d38d6927d76bbe.zip
Add square wave and fix lowpass styling
Diffstat (limited to 'src/synth_engine.c')
-rw-r--r--src/synth_engine.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/synth_engine.c b/src/synth_engine.c
index 1e82284..5c15565 100644
--- a/src/synth_engine.c
+++ b/src/synth_engine.c
@@ -4,7 +4,6 @@
#include "filter.h"
#include "control.h"
#include "sound.h"
-#include "wavetable.h"
#include "osc.h"
#include <string.h>
@@ -104,7 +103,9 @@ gen5(float f, midi_note_t * midi_note, float x, unsigned int sample_rate)
float
gen6(float f, midi_note_t * midi_note, float x, unsigned int sample_rate)
{
- return wvt_next(wvt_sqr, f, sample_rate, &midi_note->wvt_index);
+ float sample = osc_sqr(midi_note->wvt_index);
+ midi_note->wvt_index = osc_sqr_next(f, midi_note->wvt_index);
+ return sample;
}
float
@@ -194,7 +195,7 @@ make_sample(void *synthData, unsigned int sample_rate, int frame)
synth->x,
sample_rate);
- sample += 0.2 * rms * adsr * synth_sample;
+ sample += rms * adsr * synth_sample;
}
/* filter */
@@ -205,8 +206,8 @@ make_sample(void *synthData, unsigned int sample_rate, int frame)
//cutoff = cutoff + cutoff * (synth->lfo.amp) * lfo(cc_iget(&synth->cc_lfo_freq, frame, FRAMES_PER_BUFFER), synth->lfo.elapsed, sample_rate);
if (cutoff == 0) cutoff = 0.001;
- LowPass_Update(reso, cutoff, sample_rate);
- sample = LowPass_Filter(sample);
+ lpf_update(reso, cutoff, sample_rate);
+ sample = lpf_filter(sample);
update_bw_low_pass_filter(synth->fff, SAMPLE_RATE,cutoff, reso);
sample = bw_low_pass(synth->fff, sample);
@@ -293,9 +294,6 @@ get_frame(void *outputBuffer, synth_t *synth, int i)
*out++ = s;
*out++ = s;
- if (s > 1 || s < -1) {
- printf("!! %f !!\n", s);
- }
// move time
increment_synth(synth);
@@ -431,10 +429,10 @@ init_synth(synth_t * synth)
synth->modi = 0;
- synth->gain = 1;
+ synth->gain = 0.5;
synth->x = 1;
- synth->adsr.a = 0.0;
+ synth->adsr.a = 0.00001f;
synth->adsr.peak = 1.0f;
synth->adsr.d = 0.3;
synth->adsr.s = 0.7;
@@ -487,12 +485,11 @@ init_synth(synth_t * synth)
synth->viz.sample_rate_divider = 1;
synth->viz.wi = 0;
- LowPass_Init();
+ lpf_init();
synth->fff = create_bw_low_pass_filter(2, SAMPLE_RATE, 400);
synth->fff2 = create_bw_band_stop_filter(8, SAMPLE_RATE, 15000, 22000);
init_sound(synth, sound_gen);
- wvt_init();
synth->osctri = make_tri("triangle");
}