# FM Demodulate IQ Wav Signal

42 views (last 30 days)
Mitja Kocjancic on 26 Feb 2022
Answered: Abhimenyu on 8 Dec 2023
Hello there, I have an IQ Wave file (that I made a long time ago): https://transfer.sh/kcfICr/SCASample.wav
and I would like to play its audio, its nothing fancy just a simple FM modulated file
that's what my code looks like
fDev = 50;
Fc = 0; %Center frequency should be 0 since its a recording of FM station and its in the middle??
% Create audio player
player = audioDeviceWriter('SampleRate',48e3);
fprintf("Sample Rate: %d\n", Fs);
audioSig = fmdemod(d,Fc,Fs,fDev); % Demodulate signal
player(audioSig);
unfortionatly, nothing is played, if I leave Fc at 0 then I get error: Fc must be a real, positive scalar (but Fc should be 0 because its only one FM station and notthing more so I shouldn't tune the frequency)
but if I set Fc at 10 for instance, then I get no errors, but nothing is played eather, so I don't know what I am doing wrong here
Thanks for Anwsering and Best Regards

Abhimenyu on 8 Dec 2023
Hi Mitja,
I understand that you are trying to play an IQ wave file that contains a simple FM modulated signal. The issue is related to the demodulation process and the centre frequency used during the demodulation. When demodulating an FM signal, it's important to properly set the centre frequency and ensure that the demodulation process accurately extracts the baseband signal for audio playback.
The fmdemod function of MATLAB can be used to demodulate the signal. The center frequency Fc should be the frequency of the carrier signal that was used to modulate the original audio signal. This can be estimated by looking at the spectrum of the IQ wave file. MATLAB’sfft and plot functions can do this. Please refer to the example code below to understand more:
N = length (d); % Number of samples of the data vector “d”
f = Fs * (0:N-1) / N; % Frequency vector
D = fft (d); % Fourier transform of IQ wave file
plot (f, abs (D)); % Plot the magnitude spectrum
xlabel ('Frequency (Hz)'); % Label the x-axis
ylabel ('Magnitude'); % Label the y-axis
The peak in the spectrum obtained using the above code corresponds to the center frequency “Fc”. The “findpeaks” function can be used to locate the peak value and index. Please refer to the example code below to understand more:
[pks, locs] = findpeaks (abs (D)); % Find peaks and locations
[maxpk, maxidx] = max (pks); % Find the maximum peak and index
Fc = f (locs (maxidx)); % Find the center frequency
Once the center frequency “Fc” is known, the “fmdemod” function can be used to demodulate the signal. The frequency deviation “fDev” should be the same as the one that was used to modulate the original audio signal. If this value is not known, different values can be tried until a clear sound is heard. Please refer to the example code below to understand more:
fDev = 50; % Try different values
audioSig = fmdemod (d, Fc, Fs, fDev); % Demodulate signal
The audio can be played using “sound” or “audioplayer” functions of MATLAB.
Please refer to the below mentioned documentation links to know more on “fft”,fmdemod”,findpeaks”, “sound” and “audioplayer” functions respectively:
I hope this helps to resolve the query.
Thanks,
Abhimenyu

### Categories

Find more on Get Started with Signal Processing Toolbox in Help Center and File Exchange

R2021b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!