Signal audio - effect downsampling ?

조회 수: 15 (최근 30일)
manuel Cabanillas
manuel Cabanillas 2020년 5월 31일
답변: Harinadh Reddy Arikatla 2021년 12월 2일
HI EVERYBODY!
clear, clf
fprintf('Choose integer M \n')
prompt='';
M=input(prompt) %factor de reducion
[y,Fs]= audioread('hola.wav');
figure(1)
plot(y);
grid on;
sound(y,Fs);
pause(10)
x=downsample(y,M);
figure(2)
plot(x)
grid on ;
pause(10)
sound(x,Fs);
pause(12)
audiowrite('vozgrave.flac',f,Fs);
I would like to make an inquiry, who can help me, I appreciate it. I'm doing the downsampling effect on an audio signal with an integer M factor for example 2 to make the a acute voice. The problem is the following, my original audio has a certain sampling frequency, a number of samples and a duration for example of 10 sec. When applying the dowsampling effect with a reduction factor of M = 2, the audio time is reduced to 5 seconds. There is some way in matlab to make the high-pitched voice effect as it happens to me here but keeping 10 seconds of the original audio?
I leave my program Thank you very much to all!

답변 (2개)

Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato 2020년 5월 31일
편집: Thiago Henrique Gomes Lobato 2020년 5월 31일
What exactly do you want to achieve? You see, downsampling the signal alone doesn't increases the frequency of it. This effects of high pitch happens because you play the new sound with the older sampling rate. This makes the frequency of the sound increase M times, since it is like you're reading the "same" data but M times faster. If you use sound(x,Fs/M) the sound would be pratically the same (as long Nyquist frequency still holds) and with the same duration. Thus you cannot expect the sound to have the same duration in your case with same Fs. For this, you will have to use some frequency shift algorithm to change the frequency while maintain the original sampling rate. If you want to have the exactly same signal but only a sound file with the given duration you can always pad zeros to the array so the number of samples doesn't change in respect to the original sound.
  댓글 수: 3
Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato 2020년 5월 31일
You actually want a pitch shifter. Look for Phase Vocoder, a good example with matlab code is in this site https://www.eumus.edu.uy/eme/ensenanza/electivas/dsp/presentaciones/ejemplos_clase/phase_vocoder/A%20Phase%20Vocoder%20in%20Matlab.htm .
If you copy the functions from this site, you can achieve what you want as:
window = 4096; % try different values in the form of 2^n
x=pvoc(y,1/M,window);
x=downsample(x,M);
manuel Cabanillas
manuel Cabanillas 2020년 6월 1일
thank you so much ! i will try it

댓글을 달려면 로그인하십시오.


Harinadh Reddy Arikatla
Harinadh Reddy Arikatla 2021년 12월 2일
clear, clf
fprintf('Choose integer M \n')
prompt='';
M=input(prompt) %factor de reducion
[y,Fs]= audioread('hola.wav');
figure(1)
plot(y);
grid on;
sound(y,Fs);
pause(10)
x=downsample(y,M);
figure(2)
plot(x)
grid on ;
pause(10)
sound(x,Fs);
pause(12)
audiowrite('vozgrave.flac',f,Fs);

카테고리

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