How to create sound with variable pitch?

1 次查看(过去 30 天)
I have an m-1 array of frequencies that I'd like Matlab to play back as one continuous tone of varying pitch. I do not want all the sounds to play at once - rather I want a tone that changes pitch. sound() doesn't want to accept an array for Fs. I tried iterating through a loop but the resulting audio is staccato and choppy, not continuous.

回答(1 个)

Walter Roberson
Walter Roberson 2017-4-25
You need to resample each of them into a single common frequency (use the highest frequency) and then put all of those results together and play it at one time.
t = linspace(0, 20, 5000);
t(end) = []; %remove final return to 0 so it is periodic
s = sin(t*2*pi);
max_freq = max(m);
b = [];
for freq = 1 : length(m)
b = [b, resample(s, max_freq, freq)];
end
sound(b, max_freq)
Or something like that.

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by