-
Notifications
You must be signed in to change notification settings - Fork 0
/
FMReciver.m
executable file
·44 lines (36 loc) · 1.3 KB
/
FMReciver.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
% Request user input from the command-line for application parameters
userInput = helperFMUserInput;
% Calculate FM system parameters based on the user input
[fmRxParams,sigSrc] = helperFMConfig(userInput);
% Create FM broadcast receiver object and configure based on user input
fmBroadcastDemod = comm.FMBroadcastDemodulator(...
'SampleRate', fmRxParams.FrontEndSampleRate, ...
'FrequencyDeviation', fmRxParams.FrequencyDeviation, ...
'FilterTimeConstant', fmRxParams.FilterTimeConstant, ...
'AudioSampleRate', fmRxParams.AudioSampleRate, ...
'Stereo', true);
% Create audio player
player = audioDeviceWriter('SampleRate',fmRxParams.AudioSampleRate);
% Initialize radio time
radioTime = 0;
% Main loop
while radioTime < userInput.Duration
% Receive baseband samples (Signal Source)
if fmRxParams.isSourceRadio
[rcv,~,lost,late] = sigSrc();
else
rcv = sigSrc();
lost = 0;
late = 1;
end
% Demodulate FM broadcast signals and play the decoded audio
audioSig = fmBroadcastDemod(rcv);
player(audioSig);
% Update radio time. If there were lost samples, add those too.
radioTime = radioTime + fmRxParams.FrontEndFrameTime + ...
double(lost)/fmRxParams.FrontEndSampleRate;
end
% Release the audio and the signal source
release(sigSrc)
release(fmBroadcastDemod)
release(player)