Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FM is corrupted #261

Open
JohannesLorenz opened this issue Oct 8, 2023 · 1 comment · May be fixed by #267
Open

FM is corrupted #261

JohannesLorenz opened this issue Oct 8, 2023 · 1 comment · May be fixed by #267
Labels

Comments

@JohannesLorenz
Copy link
Contributor

FM seems to fail in the "sine modulates sine" case in many scenarios. Some may fall in the aliasing area, but the most remarkable scenario is this:

  1. Start zyn with SR 192000 (error occurs with all SRs, but let's exclude aliasing issues)
  2. Use a fresh AD voice
  3. Set modulator type to FM
  4. Set FM volume to 120
  5. Activate AMP env
  6. Set stretch to 127
  7. Play the lowest note on the internal "vK" (virtual keyboard)

After 0.3 seconds, you will hear a sudden transition which can not be caused by aliasing. This must be investigated, possibly with debug printfs at the time where the sound changes.

Also notable, if you switch to PM, the issue is gone. Except for initial parameter,s PM and FM share almost the same modulation code, except for the normalization phase:

//normalize: makes all sample-rates, oscil_sizes to produce same sound
if(FMmode == FMTYPE::FREQ_MOD) { //Frequency modulation
const float normalize = synth.oscilsize_f / 262144.0f * 44100.0f
/ synth.samplerate_f;
for(int k = 0; k < vce.unison_size; ++k) {
float *tw = tmpwave_unison[k];
float fmold = vce.FMoldsmp[k];
for(int i = 0; i < synth.buffersize; ++i) {
fmold = fmodf(fmold + tw[i] * normalize, synth.oscilsize);
tw[i] = fmold;
}
vce.FMoldsmp[k] = fmold;
}
}
else { //Phase or PWM modulation
const float normalize = synth.oscilsize_f / 262144.0f;
for(int k = 0; k < vce.unison_size; ++k) {
float *tw = tmpwave_unison[k];
for(int i = 0; i < synth.buffersize; ++i)
tw[i] *= normalize;
}
}

@friedolino78
Copy link
Contributor

@JohannesLorenz
please check if this bug is fixed with:
#264

@friedolino78 friedolino78 linked a pull request Mar 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants