Azzera filtri
Azzera filtri

How to fm demodulate a STREAMING audio file?

3 visualizzazioni (ultimi 30 giorni)
jack feinberg
jack feinberg il 6 Giu 2018
I wrote the simple MATLAB program below to demodulate an audio signal that had previously been frequency modulated with a carrier frequency of 10000 Hz. The program records the frequency-modulated signal, stores it on disc (for possible later use), then retrieves and demodulates it. Now I would like to be able to demodulate (and display) the signal continuously as it streams in, without first having to store it. Any suggestions on how to modify the MATLAB code below?
% FM Demodulate an Audio File June 5, 2018
%%Record the previously frequency-modulated signal for a few seconds.
Fs = 44100; % Sample frequency of the sound wave
duration = 5; % Duration of recording in seconds
recObj = audiorecorder(Fs,16,1); % Sets up the recording conditions
pause(4) % Pause before recording
disp('Start recording.')
recordblocking(recObj,duration);
disp('End of recording.');
%%Store data in double-precision array.
filename = 'RecordedWave.wav';
myRecording = getaudiodata(recObj);
Fs = get(recObj, 'SampleRate');
audiowrite(filename,myRecording,Fs) % Writes the y and Fs as a .wav file
%%Read it back into memory
[y,Fs] = audioread(filename);
% The above statement reads the stored .wav file and loads the y vector
% as well as the stored value of Fs for that .wav file.
%%Demodulate the recorded high-frequency FM sound signal
z = demod(y,10000,44100,'fm');
%%Make and then apply a bandpass filter
filterOrder = 2;
fcutlow = 2;
fcuthigh= 10;
[b,a] = butter(filterOrder,[fcutlow,fcuthigh]/(Fs/2),'bandpass');
z_filtered = filter(b,a,z); % Apply the bandpass filter
%%Plot the demodulated and filtered signal
figure
t_sec = (0:1/Fs:duration-1/Fs); % here is the vector of time
plot(t_sec,z_filtered)

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by