mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-27 03:23:54 +01:00
maybe the darc will come
This commit is contained in:
@@ -12,4 +12,20 @@ float modulate_fm(FMModulator *fm, float sample) {
|
||||
fm->osc_phase += (M_2PI * inst_freq) / fm->sample_rate;
|
||||
fm->osc_phase -= (fm->osc_phase >= M_2PI) ? M_2PI : 0.0f;
|
||||
return sinf(fm->osc_phase);
|
||||
}
|
||||
|
||||
void init_refrenced_fm_modulator(RefrencedFMModulator* fm, Oscillator* osc, float deviation) {
|
||||
fm->deviation = deviation;
|
||||
fm->osc = osc;
|
||||
}
|
||||
|
||||
float refrenced_modulate_fm(RefrencedFMModulator* fm, float sample) {
|
||||
float inst_freq = sample * fm->deviation;
|
||||
float phase = fm->osc->phase + ((M_2PI * inst_freq) / fm->osc->sample_rate);
|
||||
|
||||
if (phase >= M_2PI) {
|
||||
phase -= M_2PI;
|
||||
}
|
||||
|
||||
return sinf(phase);
|
||||
}
|
||||
Reference in New Issue
Block a user