Borrar filtros
Borrar filtros

How do I trim a WAV file from point A to B.

26 visualizaciones (últimos 30 días)
AJ516
AJ516 el 23 de Oct. de 2019
Editada: Daniel M el 23 de Oct. de 2019
I am looking into trimming a WAV file to section out a beep sound. The clip is 47 seconds long and was converted from an AAC file. Here is what I am needing for this script.
-Retrieve file
-Use point A and B with different inputs of seconds (ex. A=37 seconds and B =39 seconds, or A=37.5 and B=38.5)
-Send file out in WAV
I can retrive the file and send a new one out just fine. The new thing I would like to learn about is trimming audio clips. How should I do this?
Any script help and code reffeences would be awesome.

Respuestas (1)

Daniel M
Daniel M el 23 de Oct. de 2019
Editada: Daniel M el 23 de Oct. de 2019
You have the sampling frequency as an output from the audioread function. The time vector would typically go
t = 0:1/fs:(length(soundfile)-1)/fs;
So then, 37 seconds will occur at roughly (37*fs + 1) in t. But this won't always work. Safer is to search for the closest value in your t variable.
[~,loc37] = min(abs(t-37));
[~,loc39] = min(abs(t-39));
x(loc37:loc39) = []; % this will cut out the sections of your sound file between 37 and 39 seconds

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by