¿Como remuestrear?

1 view (last 30 days)
Juan
Juan on 13 Aug 2022
Edited: Walter Roberson on 15 Aug 2022
help I'm new to programming, I need to resample the audio signal from 44100hz to a higher one but I don't know how to do it, I need to resample to later use FFT() and that the fourier transform is more accurate.
_________sonido_______________________________________________________
[s,fs]=audioread('frase 3-1.wav');
s=s/max(abs(s));
t=size(s,1)/fs; %tiempo total
tiempo=0:1/(fs):t;
[P,Q]=rat(48e3/fs);
snew=resample(s,P,Q);
sound(snew*0.5,fs)
figure
plot(tiempo(2:end),snew)
__________transformada_______________________________________________________
the goal is to do this transform but with greater precision.
[s,fs]=audioread('Frase 3-1.wav', );
sound(0.5*s,fs);
%Ahora normalizamos el vector de audio
s=s/max(abs(s));
%reproducimos el audio cargado
%-----------------------------------------
%--------transformada rapida de fourier----
trans=abs(fft(s));
L=length(trans);
%ya que fft es bilateral, solo nos interesa la mitad del espectro
espectro=trans(1:L/2);
%normalizamos el espesctro
espectro=espectro/max(espectro);
frec=fs*(1:(L/2))/L;
%graficas:
t=size(s,1)/fs; %tiempo total
tiempo=0:1/(fs):t;
figure %invocamos una figura
Grafica1=subplot(2,1,1);
plot(tiempo(2:end),s), %xlim([0.55 0.8])
title('Dominio del tiempo')
xlabel('s')
ylabel('db')
Grafica2=subplot(2,1,2);
plot(frec,espectro), %xlim([0 1500])
title('Dominio de la frecuencia')
xlabel('Hz')
ylabel('db')
%agregamos componentes esteticos
grid(Grafica2)
  2 Comments
Jan
Jan on 14 Aug 2022
Some hints:
  • This is not twitter - no # before the tags. Thanks.
  • User the tool to format code as code to improve the readability.
  • The standard language of this forum is English. More users will understand "How to resample?"
Applying an interpolation will not increase the accuracy of a an FFT.
Walter Roberson
Walter Roberson on 15 Aug 2022
Questions may be asked in any language that the user is comfortable with. There is no "standard language". However, questions asked in English are more likely to get a response.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 15 Aug 2022
Edited: Walter Roberson on 15 Aug 2022
There are multiple ways to resample data, including using resample(), which uses upfirdn() to perform a polyphase interpolation; a Kaiser window is involved for anti-aliasing.
Another way to resample is to call fft() to find the frequencies, then ifft() to reconstruct from the frequencies with the desired new number of points.
Resampling to a higher frequency can never increase the amount of information in a single, so no matter what resampling algorithm you use, you cannot make the higher-frequency fft() "more accurate", only less accurate.

Community Treasure Hunt

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

Start Hunting!