summaryrefslogtreecommitdiffstats
path: root/src/synth_engine.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2023-04-29 14:34:48 +0300
committergramanas <anastasis.gramm2@gmail.com>2023-04-29 14:34:48 +0300
commit0cceb2057e382129ae24565fdefff87e91b076ab (patch)
tree36676e98fecc6bf0a0ee80dbab21331dddc372d7 /src/synth_engine.c
parent402f6791150d503fc29ed75a7b8be9abfdd3867f (diff)
downloadsynth-project-0cceb2057e382129ae24565fdefff87e91b076ab.tar.gz
synth-project-0cceb2057e382129ae24565fdefff87e91b076ab.tar.bz2
synth-project-0cceb2057e382129ae24565fdefff87e91b076ab.zip
self contained adsr
Diffstat (limited to 'src/synth_engine.c')
-rw-r--r--src/synth_engine.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/synth_engine.c b/src/synth_engine.c
index 6710ff6..8587001 100644
--- a/src/synth_engine.c
+++ b/src/synth_engine.c
@@ -138,8 +138,11 @@ make_sample(unsigned long long phase, void *synthData, unsigned int sample_rate,
continue;
sample += 0.2 * rms
- * adsr_amplitude(&synth->adsr, (float)synth->midi_note[i].noteOn, (float)synth->midi_note[i].noteOff, (float)synth->midi_note[i].elapsed)
- * synth->gen[synth->geni](synth->midi_note[i].freq + synth->midi_note[i].freq * synth->freq_offset, synth->midi_note[i].elapsed, synth->x, sample_rate);
+ * adsr_amplitude(&synth->adsr,
+ synth->midi_note[i].noteOn,
+ synth->midi_note[i].noteOff,
+ synth->midi_note[i].elapsed)
+ * synth->gen[synth->geni](synth->midi_note[i].freq + synth->freq_offset, synth->midi_note[i].elapsed, synth->x, sample_rate);
}
/* filter */
@@ -204,7 +207,6 @@ sound_gen(const void *inputBuffer, void *outputBuffer,
}
if (!notes_active(synth)) {
- //if (adsr_amplitude(synth, synth->adsr.elapsed, synth->n.noteOn, synth->n.noteOff) == 0 && synth->n.noteOff != 0) {
synth->active = 0;
*out++ = 0.0f;
*out++ = 0.0f;
@@ -219,11 +221,6 @@ sound_gen(const void *inputBuffer, void *outputBuffer,
synth->lfo.elapsed++;
synth->adsr.elapsed++;
synth->n.elapsed++;
- /* if (!synth->multi) { */
- /* if (synth->n.elapsed >= (1.0 / synth->n.freq) * SAMPLE_RATE) synth->n.elapsed = 0; */
- /* } else { */
-
- /* } */
for (int i = 0; i < MIDI_NOTES; i++) {
if (!synth->midi_note[i].active)
@@ -318,7 +315,7 @@ init_synth(synth_t * synth)
PaStreamParameters outputParameters;
- outputParameters.device = i; Pa_GetDefaultOutputDevice(); /* default output device */
+ outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
printf("-------\nSelected device: %s\n-------\n", Pa_GetDeviceInfo(outputParameters.device)->name);
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */