changing frequency of an existing audio

10 vues (au cours des 30 derniers jours)
Mohamed Turkmani
Mohamed Turkmani le 17 Août 2022
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.

Réponse acceptée

Mathieu NOE
Mathieu NOE le 22 Août 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

Plus de réponses (0)

Catégories

En savoir plus sur Audio I/O and Waveform Generation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by