MATLAB * .pcm至* .wav转换 [英] MATLAB *.pcm to *.wav converting
问题描述
如何在MATLAB代码中将*.pcm
音频文件转换为*.wav
音频文件?
我只需要插入一个标题,但是它是如何工作的?
非常感谢你!
How can I convert *.pcm
audio file to *.wav
audio File in MATLAB-Code?
I just need to insert a header, but how it is work?
Thank you very much!
推荐答案
由于您未指定它,因此我假设您使用的是Matlab 2018b,因此,我将向您介绍有关音频阅读:
Since you didn't specify it, I'm assuming you are using Matlab 2018b, so I will point you to the most recent documentation about audioread:
如您所见, PCM不在受支持的格式列表上.
您应该尝试查看是否可以为AudioRecorder设置参数,以将音频录制为受支持列表中的其他格式:.wav,.ogg,.flac,.au,.aif,.aifc,mp3 、. mp4 ...
You should try to look if you can parameter your AudioRecorder to record your audio to another format within the ones in the supported list: .wav, .ogg, .flac, .au, .aif, .aifc, mp3, .mp4...
不使用audioread
的另一种选择是像导入其他任何数据文件一样导入pcm数据,然后将其转换为16位wav.我假设采样率为44100 Hz.
An alternative option, without using audioread
, would be to import pcm data like any other data file, then convert it to 16 bit wav. I assume sample rate is 44100 Hz.
fid = fopen('audioFile.pcm'); % Open raw pcm file
audio = int16(fread(fid, Inf, 'int16')); % Convert data into 16 bit
fclose(fid); % Close pcm file
audiowrite('audioFile.wav', audio, 44100,'BitsPerSample', 16); % Write wav
这篇关于MATLAB * .pcm至* .wav转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!