convert mp3 to wav

16 visualizaciones (últimos 30 días)
Mohamed Amine Messaoudi
Mohamed Amine Messaoudi el 11 de Feb. de 2018
Editada: Walter Roberson el 13 de Jun. de 2021
Hi,
I know that my question has already been asked but my problem is different
I created an Arduino Audio Player that plays wav files from SD through speaker
I want to programatically convert mp3 files to wav using the following settings :
Bit resolution : 8bit
Sampling rate : 16000Hz
Audio channels : mono
PCM format : unsigned 8 bit.
I can easily convert mp3 files using this website
However my internet is pretty slow to upload so I'm intending to do this in Matlab
I created a script that will loop through the mp3 files and convert each one of them
folder = 'C:\Users\Test\Documents\Audio\mp3'; % folder containing mp3 files
files = dir( fullfile(folder,'*.mp3') ); % list of mp3 files in folder
files = {files.name}'; % list of the files (file names)
for i=1:numel(files) % loop through each file
fname = fullfile(dirName,files{i}); % fullname of the file
mp3=audioread(fname);
newfile=strrep(fname,'mp3','wav');
wavwrite(mp3,16000,8,newfile);
end
The files are not correcltly converted and the wav file is full of noise I also get the following warning :
Warning: Data clipped during write to file:song1.wav
> In wavwrite>PCM_Quantize at 280
In wavwrite>write_wavedat at 302
In wavwrite at 139
In convert at 13
Thanks in Advance
  2 comentarios
Walter Roberson
Walter Roberson el 11 de Feb. de 2018
Which MATLAB release are you using? You are not using one of the newest versions: we can tell because wavewrite() no longer exists. But some of the details of what you need to do changed during the releases during which wavewrite did exist.
Mohamed Amine Messaoudi
Mohamed Amine Messaoudi el 11 de Feb. de 2018
Thanks
I'm using Matlab R2013a
I know what I am doing something wrong.
When I searched I found that for 16 bit precision the values are limited to –1.0 <= y < +1.0 when the signal is provided as floating point format
But I have no idea about the changes I have to make

Iniciar sesión para comentar.

Respuestas (3)

Walter Roberson
Walter Roberson el 11 de Feb. de 2018
Use audiowrite() . It is defined in R2013a https://www.mathworks.com/help/releases/R2013a/matlab/ref/audiowrite.html and permits -1.0 ≤ y ≤ +1.0

da he
da he el 20 de Abr. de 2019
Editada: Walter Roberson el 13 de Jun. de 2021
The follwing procedures was revised based on Mohamed Amine Messaoudi,which can succes run in matlab2019a
%conver MP3 to wav
folder = 'E:\DL_denoise\clips'; % folder containing mp3 files
files = dir( fullfile(folder,'*.mp3') ); % list of mp3 files in folder
files = {files.name}'; % list of the files (file names)
L=length(files) ;
for i=1:L
[y,Fs]=audioread(files{i});
str1=files{i};
filename=strcat(str1(1:end-3),'wav');
audiowrite(filename,y,Fs); %转写成.wav格式文件 convert to wav
end

Aayush Gupta
Aayush Gupta el 13 de Jun. de 2021
[Y fs]= audioread(file);
audiowrite('ConvertAudioFile.wav',Y,fs)

Categorías

Más información sobre Audio Processing Algorithm Design en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by