changing frequency of an existing audio

9 Ansichten (letzte 30 Tage)
Mohamed Turkmani
Mohamed Turkmani am 17 Aug. 2022
Beantwortet: Mathieu NOE am 22 Aug. 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.

Akzeptierte Antwort

Mathieu NOE
Mathieu NOE am 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

Weitere Antworten (0)

Kategorien

Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by