How to create sound with variable pitch?

7 ビュー (過去 30 日間)
Brian Bock
Brian Bock 2017 年 4 月 25 日
回答済み: Walter Roberson 2017 年 4 月 25 日
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 Center および File ExchangeAudio 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