changing frequency of an existing audio

10 views (last 30 days)
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.

Accepted Answer

Mathieu NOE
Mathieu NOE on 22 Aug 2022
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

More Answers (0)

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!