# Demodulating wideband FM signal in Octave from recorded baseband IQ samples

Assuming I have a baseband recording of 8 bit IQ samples at 2.4MSps centered on an FM station is it correct to say that after low pass-filtering the complex signal to 240KHz, taking discrete derivative of phase and computing the envelope of the result this envelope should be the baseband audio signal?

Will this approach work for FM stereo?

I'm trying to confirm that my understanding is correct in Octave based on IQ samples recorded from RTL-SDR tuned to an FM station, but I'm getting white noise.

pkg load signal;
% 2.4MSps IQ baseband signal of an FM station from RTL-SDR recorded in SDR#
csamples = arrayfun(@complex,samples(:,1),samples(:,2));
% low pass filter and decimate to get 480KSps (240KHz Widband FM)
csamples_filtered = decimate(csamples, 5);
% descrete derivatives of phase
filtered_derivative = conv(angle(csamples_filtered), [-1,1]);
% center amplitude around 0
filtered_derivative = filtered_derivative - (max(filtered_derivative)+min(filtered_derivative));
% rectify, low pass filter and decimate to get the envelope (48 KSps)
envelope = decimate(sqrt(filtered_derivative.*filtered_derivative), 10);
% scale to 0..255
sound_normalized = sound_normalized * (255/max(envelope));

player = audioplayer(sound_normalized, 48000, 8);
play(player);


The FFT plot of the original data in csamples (centered on Fc) corresponds to spectrum that is shown in SDR Sharp I recorded it in (and listened to the station), so I think the input data is good. This should work if you further filter to 15KHz after your FM discriminator. FM stereo is actually sub-modulated as follows:

L+R: 0-15KHz

Pilot Tone: 19KHz

L-R: 23KHz-53KHz as DSB-SC on a 38 KHz sub-carrier

Where L is the left channel and R is the right channel.

Update: I found a nice graphic showing this from Keysight with further details on FM broadcasting at this link: http://rfmw.em.keysight.com/wireless/helpfiles/n7611b/Content/Main/FM_Broadcasting.htm If the pilot tone is present, that indicates the station is transmitting stereo but with this approach mono receivers would still work as you would hear the combined left and right channels.

So the composite signal is formed by first AM modulating using Double-Sideband-Supressed-Carrier (DSB-SC) the L-R channels onto a 38 KHz sub-carrier (subtract R from L and then simply multiply this with a 38Khz tone). The tone is frequency divided by two and this coherent 19Khz pilot tone is added to the DSB-SC L-R waveform. Finally R is added to L and this baseband signal is added.

This is the signal that is then FM modulated, so would be the signal you would expect to get if you are properly FM demodulating.

A stereo demodulator after FM demodulation locks onto the 19KHz pilot to create the AM sub carrier at 38Khz (2x) and with that easily demodulates the AM DSB-SC sub-modulation (by multiplying the two) to achieve L-R at basebnad, and then can extract L and R by summing and subtracting the L+R and L-R results.

If you want to do a simple test of audibly hearing the demodulation of the FM signal, filter out the 19 KHz pilot and higher frequencies after you have FM demodulated this composite signal and you will hear the combined L+R channels.