MATLAB Answers

Signal audio - effect downsampling ?

22 views (last 30 days)
manuel Cabanillas
manuel Cabanillas on 31 May 2020
clear, clf
fprintf('Choose integer M \n')
M=input(prompt) %factor de reducion
[y,Fs]= audioread('hola.wav');
grid on;
grid on ;
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!


Sign in to comment.

Answers (1)

Thiago Henrique Gomes Lobato
Edited: Thiago Henrique Gomes Lobato on 31 May 2020
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.


manuel Cabanillas
manuel Cabanillas on 31 May 2020
My audio file has 10 seconds of my voice. I want to do the effect of downsampling to make my voice to be hight pitch, but during the same time ! That is the problem, if I use a M=2 , my recording will be around 5 seconds. Do you understand me?
Thiago Henrique Gomes Lobato
You actually want a pitch shifter. Look for Phase Vocoder, a good example with matlab code is in this site .
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
manuel Cabanillas
manuel Cabanillas on 1 Jun 2020
thank you so much ! i will try it

Sign in to comment.