changing frequency of an existing audio

조회 수: 10 (최근 30일)
Mohamed Turkmani
Mohamed Turkmani 2022년 8월 17일
답변: Mathieu NOE 2022년 8월 22일
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