How to play a variation of frequency?

3 views (last 30 days)
jérôme TAÏEB
jérôme TAÏEB on 29 Sep 2018
Commented: Walter Roberson on 3 Oct 2018
Hi,
1)Starting from a pure wave of a given frequency (4000 Hz) I can not implement this pseudo code to play a sound (pure wave) whose frequency decreases continuously from 4000 to 200:
demo matlab
t = (0:0.001:100)';
for n = 4000:-1:200
y = sin(2*pi*n*t)
sound(y,Fs);
end
How to implement this correctly?
2)same question but starting from an very short audio file or an sound sample
thanks
  3 Comments
jérôme TAÏEB
jérôme TAÏEB on 2 Oct 2018
Edited: Walter Roberson on 3 Oct 2018
corrected script:
t=0:0.001:100;
for n=200:1:4000
y=sin(2*pi*n*t);
sound(y,n);
end
Now:
How to create in format.wav the obtained result by adding and scripting ?
thanks
Walter Roberson
Walter Roberson on 3 Oct 2018
That code changes frequency in two different ways simultaneously. You should not do that. Either change the n used in the construction of y or else change the frequency used for playback, but do not do both.
Hint: changing the n used in the construction of y is much easier to put together into a single .wav file than if you change the playback frequency.

Sign in to comment.

Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!