changing frequency of an existing audio

9 次查看(过去 30 天)
hi i have wrote a simple code as the following.
[y,fs] = audioread("Sound.wav");
sound(y,fs);
i know that i can change the sampling frequency of it by changing the "fs" value, my question is how can i change the frequency of the existing audio, i want it to play at 1000 hz for example.

采纳的回答

Mathieu NOE
Mathieu NOE 2022-8-22
hello
the question is not 100 % clear to me
if you want to play the same signal to a different pitch , you can simply do
newfs = 1000;
sound(y,newfs);
but as the signal has not been resampled , the pitch will be different as if you had played it with the original sampling frequency fs
if you want to have the same pitch , you need also to resample / decimate the data
here is an example how to decimate the data (multi channel case here) , assuming the new sampling rate is a integer factor lower compared to the original sampling rate :
%% decimate (if needed)
% NB : decim = 1 will do nothing (output = input)
decim = 1;
if decim>1
for ck = 1:channels
newsignal(:,ck) = decimate(signal(:,ck),decim);
newfs = fs/decim;
end
end

更多回答(0 个)

类别

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