strange spectrum from the FM module

Found a bug? Post it here.
Post Reply
Pavel
Posts: 6
Joined: Fri Mar 20, 2020 2:12 am

strange spectrum from the FM module

Post by Pavel »

I'd expect the spectrum to look like a spectrum of the saw waveform with the fundamental frequency having the highest amplitude. However, the amplitude of the fundamental frequency is 20 dB lower than the amplitude of the second harmonic, as can be seen in the following screenshot. I use windows_x86_64/sunvox.exe version 1.9.5d.
fm_spectrum.png
fm_spectrum.png (45.21 KiB) Viewed 1168 times
For comparison, here is a correctly looking spectrum of the saw waveform:
saw_spectrum.png
saw_spectrum.png (48.79 KiB) Viewed 1168 times
User avatar
NightRadio
Site Admin
Posts: 3550
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: strange spectrum from the FM module

Post by NightRadio »

I'd expect the spectrum to look like a spectrum of the saw waveform with the fundamental frequency having the highest amplitude.
Why? FM is not equal to saw waveform :)
It depends on the M.Sustain value. Please try to set it to 159 or lower values
Pavel
Posts: 6
Joined: Fri Mar 20, 2020 2:12 am

Re: strange spectrum from the FM module

Post by Pavel »

It depends on the M.Sustain value. Please try to set it to 159 or lower values
Thank you for the advice! Indeed, when M.Sustain and M.Volume are set to 32, and M.Feedback is set to 0, I get a waveform and spectrum that look more or less the way I expected:
fm_without_feedback.png
fm_without_feedback.png (47.28 KiB) Viewed 1118 times
For comparison, here is what I expected:
fm_saw_without_feedback.png
fm_saw_without_feedback.png (23.33 KiB) Viewed 1118 times
Pavel
Posts: 6
Joined: Fri Mar 20, 2020 2:12 am

Re: strange spectrum from the FM module

Post by Pavel »

Why? FM is not equal to saw waveform :)
I thought it was possible to obtain a waveform similar to a sawtooth or square, using one carrier and one modulator with feedback.

I've just done a few tests with a simple Python script (it's in the attachments to this post) that simulates one carrier and one modulator with feedback. Here is what I get with 100% modulation index and 100% modulator feedback:
fm_saw.png
fm_saw.png (24.26 KiB) Viewed 1117 times
However, when I try to get something similar by increasing the M.Feedback value, I cannot obtain what I expect:
fm_with_feedback.png
fm_with_feedback.png (49.67 KiB) Viewed 1117 times
Attachments
fm_test.py.txt
(930 Bytes) Downloaded 63 times
Pavel
Posts: 6
Joined: Fri Mar 20, 2020 2:12 am

Re: strange spectrum from the FM module

Post by Pavel »

I've just checked the source code of the FM module at this link and I think that I now understand how the M.Feedback parameter is used.

The algorithm implemented in the FM module can be written as

Code: Select all

fb = sin(mphase) * mfeedback
cval = sin(cphase + sin(mphase + fb) * mvol)
So, what is called feedback in the code of the FM module is not actually feedback, but an additional modulator running at the same frequency as the first modulator. This additional modulator is modulating the first modulator. The M.Feedback parameter is the volume of this additional modulator.

To implement the modulator feedback the algorithm should be changed to

Code: Select all

fb = sin(mphase + previousfb * mfeedback)
cval = sin(cphase + previousfb * mvol)
previousfb = fb
Here are two diagrams illustrating the difference between the current implementation and the modulator with feedback:
fm_diagrams.png
fm_diagrams.png (20.29 KiB) Viewed 1092 times
User avatar
NightRadio
Site Admin
Posts: 3550
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: strange spectrum from the FM module

Post by NightRadio »

Thanks for the detailed analysis!
I plan to update the FM module in one of the new SunVox versions. I will take into account your remark regarding the feedback.
Post Reply