Frequency modulation to a digital signal
9 views (last 30 days)
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;
modulation_argument = 2*pi*Fc/Fs
for i= delay+1:1:duration
delay2 = round(delay + modulation(i));
z(i) = a*x(d);
John BG on 25 Feb 2018
this is John BG <mailto:email@example.com firstname.lastname@example.org>
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:
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