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’s “fft” 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:
- https://www.mathworks.com/help/matlab/ref/fft.html
- https://www.mathworks.com/help/comm/ref/fmdemod.html
- https://www.mathworks.com/help/signal/ref/findpeaks.html
- https://www.mathworks.com/help/matlab/ref/sound.html
- https://www.mathworks.com/help/matlab/ref/audioplayer.html
I hope this helps to resolve the query.
Thanks,
Abhimenyu