Frequency modulation to a digital signal

9 views (last 30 days)
Haman Siu
Haman Siu on 25 Feb 2018
Commented: Haman Siu on 25 Feb 2018
So I have a digital sound signal that i am trying to have its frequency being modulated by a sinusoidal waveform. I tried to used the following code to create the effect but then realize that all it does is moving samples around creating noise rather than creating the effect that i wish to create does anyone have any idea how to create a piece of code to apply FM to a digital audio file?
[x,Fs]=audioread('Guitar sample file.wav');
duration = size(x);
index = 1 : length(x);
time_delay = 0.04;
delay = ceil(time_delay*Fs);
Fc = 20;
a= 1;
b= 1;
modulation_argument = 2*pi*Fc/Fs
for i= delay+1:1:duration
delay2 = round(delay + modulation(i));
z(i) = a*x(d);

Answers (1)

John BG
John BG on 25 Feb 2018
Hi Haman
do you want to use the function fmmod?
y = fmmod(x,Fc,Fs,freqdev)
It does the job and save you time.
Fs is the frequency of the modulating tone.
You can shift the phase (< 1 cycle) a constant value adding the optional phase shift.
y = fmmod(x,Fc,Fs,freqdev,ini_phase)
If interested to know more how does fmmod work then check
Use fmdemod to FM demodulate, either to recover signal, or just to check fmmod works ok.
Also, perhaps you would like to switch to Simulink.
Simulink has a really powerful array of blocks for signals modulation.
A few toolboxes that you may find interesting:
Communications Toolbox:
DSP Systems Toolbox:
f you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG
  1 Comment
Haman Siu
Haman Siu on 25 Feb 2018
I do not have access to the fmmod function as its not included in my licence and I am working with the code for a project, so simulink is not an option for me

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!