diff options
Diffstat (limited to 'src/synth_engine.c')
-rw-r--r-- | src/synth_engine.c | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/src/synth_engine.c b/src/synth_engine.c index 8fc8221..4a4fd03 100644 --- a/src/synth_engine.c +++ b/src/synth_engine.c @@ -49,6 +49,9 @@ gen10(float f, unsigned long long phase, float x, unsigned int sample_rate) float gen110(float f, unsigned long long phase, float x, unsigned int sample_rate) { + /* return sawX_sample(0.5, f, 5, midi_note->elapsed, sample_rate) */ + /* + saw_sample(0.3, 2 * f / 5, midi_note->elapsed, sample_rate) */ + /* + sin_sample(0.2, f * 5.0 / 7.0 , midi_note->elapsed, sample_rate); */ float a = fmodf(phase, sample_rate/f); return a > (sample_rate/f) / 2.0f ? 0.9999f : -0.9999f; } @@ -56,7 +59,10 @@ gen110(float f, unsigned long long phase, float x, unsigned int sample_rate) float gen0(float f, midi_note_t * midi_note, float x, unsigned int sample_rate) { - return sin_sample(1, f, midi_note->elapsed, sample_rate); + float sample = osc_sin(midi_note->wvt_index); + midi_note->wvt_index = osc_sin_next(f, midi_note->wvt_index); + return sample; + /* return sin_sample(1, f, midi_note->elapsed, sample_rate); */ //return chirp(midi_note->elapsed, f); /* return sqr_sample(0.1, f, 0.3, midi_note->elapsed, sample_rate) */ /* + sqr_sample(0.1, f * 3.0 / 2.0 , 0.5, midi_note->elapsed, sample_rate) */ @@ -71,49 +77,41 @@ gen0(float f, midi_note_t * midi_note, float x, unsigned int sample_rate) float gen1(float f, midi_note_t * midi_note, float x, unsigned int sample_rate) { - //return saw_sample(1, f, midi_note->elapsed, sample_rate); - return sawX_sample(0.5, f, 5, midi_note->elapsed, sample_rate) - + saw_sample(0.3, 2 * f / 5, midi_note->elapsed, sample_rate) - + sin_sample(0.2, f * 5.0 / 7.0 , midi_note->elapsed, sample_rate); + float sample = osc_saw(midi_note->wvt_index); + midi_note->wvt_index = osc_saw_next(f, midi_note->wvt_index); + return sample; } float gen2(float f, midi_note_t * midi_note, float x, unsigned int sample_rate) { - /* return sin_sample(0.5, f * sqrt(2) , midi_note->elapsed, sample_rate) */ - /* + sin_sample(0.5, f, midi_note->elapsed, sample_rate); */ - - return sawX_sample(1, f, 15, midi_note->elapsed, sample_rate); + float sample = osc_weird(midi_note->wvt_index); + midi_note->wvt_index = osc_weird_next(f, midi_note->wvt_index); + return sample; } float gen3(float f, midi_note_t * midi_note, float x, unsigned int sample_rate) { - //return sqr_sample(1, f, .5, midi_note->elapsed, sample_rate); - - //return wvt_next(wvt_sound, f, sample_rate, &midi_note->wvt_index); - float sample = osc_sound(midi_note->wvt_index); - midi_note->wvt_index = osc_sound_next(f, midi_note->wvt_index); + float sample = osc_tri(midi_note->wvt_index); + midi_note->wvt_index = osc_tri_next(f, midi_note->wvt_index); return sample; - - /* return sawX_sample(0.7, f, 5, midi_note->elapsed, sample_rate) */ - /* + sin_sample(0.3, 4.0/17.0*f, midi_note->elapsed, sample_rate); */ } float gen4(float f, midi_note_t * midi_note, float x, unsigned int sample_rate) { - float sample = osc_tri(midi_note->wvt_index); - midi_note->wvt_index = osc_tri_next(f, midi_note->wvt_index); + float sample = osc_sound(midi_note->wvt_index); + midi_note->wvt_index = osc_sound_next(f, midi_note->wvt_index); return sample; - //return wvt_next(wvt_tri, f, sample_rate, &midi_note->wvt_index); } float gen5(float f, midi_note_t * midi_note, float x, unsigned int sample_rate) { - return 0.8 * wvt_next(wvt_saw, f, sample_rate, &midi_note->wvt_index) + - .2 * sin_sample(1, f/2, midi_note->elapsed, sample_rate); + float sample = osc_digisaw(midi_note->wvt_index); + midi_note->wvt_index = osc_digisaw_next(f, midi_note->wvt_index); + return sample; } float @@ -189,8 +187,8 @@ make_sample(void *synthData, unsigned int sample_rate, int frame) continue; float adsr = fix_adsr(&synth->adsr, - synth->midi_note[i].noteOn, - synth->midi_note[i].noteOff, + synth->midi_note[i].noteOn, + synth->midi_note[i].noteOff, synth->midi_note[i].elapsed, synth->midi_note[i].noteOffSample); @@ -199,13 +197,13 @@ make_sample(void *synthData, unsigned int sample_rate, int frame) cc_iget(&synth->cc_lfo_amp, frame, FRAMES_PER_BUFFER) * // (1.05946309436/24.0) * (wvt_next(wvt_tri, (wvt_next(wvt_sound, 2 * cc_iget(&synth->cc_lfo_freq, frame, FRAMES_PER_BUFFER), SAMPLE_RATE, &lfo_index) / 2.0 + 0.5) * cc_iget(&synth->cc_lfo_freq, frame, FRAMES_PER_BUFFER), SAMPLE_RATE, &synth->midi_note[i].lfo_index) / 2.0 + 0.5); - - float synth_sample = synth->osctri->ops->sample(synth->osctri, synth->midi_note[i].wvt_index); - synth->midi_note[i].wvt_index = synth->osctri->ops->next(synth->osctri, targ_freq, synth->midi_note[i].wvt_index); - /* float synth_sample = synth->gen[synth->geni](targ_freq, */ - /* &synth->midi_note[i], */ - /* synth->x, */ - /* sample_rate); */ + + /* float synth_sample = synth->osctri->ops->sample(synth->osctri, synth->midi_note[i].wvt_index); */ + /* synth->midi_note[i].wvt_index = synth->osctri->ops->next(synth->osctri, targ_freq, synth->midi_note[i].wvt_index); */ + float synth_sample = synth->gen[synth->geni](targ_freq, + &synth->midi_note[i], + synth->x, + sample_rate); sample += 0.2 * rms * adsr * synth_sample; } |