Convert .txt/.mat to .wav format
9 次查看(过去 30 天)
显示 更早的评论
I have a .txt and a .mat file, both containing the same data. I would like to convert either one(whichever is easier) to a .wav file so that I can play the sound and carry out audio processing. I understand 'wavwrite' is one way of doing this but so far I have been unsuccessful. I have tried:
>> load('data.mat')
>> hfile='data.wav';
>> wavwrite(y, Fs, hfile)
But when I run the code, it displays:
Undefined function or variable 'y'.
Does anyone know the solution to this problem or even an alternative method to convert a .txt/.mat file to .wav? Thanks
0 个评论
采纳的回答
dpb
2017-3-25
load('data.mat')
will leave whatever the variable in the file name is as the variable in the workspace. Clearly it wasn't y.
Try
whos -file data.mat
and find out what that variable was that was written, then use it in the wavwrite call. Of course, you'll have to define Fs, too.
NB: documentation indicates
>> help wavwrite
wavwrite Write Microsoft WAVE (".wav") sound file.
wavwrite will be removed in a future release. Use AUDIOWRITE instead.
....
May want to take that into account.
15 个评论
dpb
2017-3-28
I found a blog (somewhat dated, so may not be signficant, but then again...) that has some discussion of how the Due A/D is internally programmed. Depending upon how your device operates, it may be significant.
<DJErickson Arduino> The bottom-most section discusses what he learned about the A/D speed and how to set. There are some articles and code samples by a Stimmer that show how to write interrupt-driven DMA transfers for high-speed acquisition; perhaps that's what the instrument is doing? Or do you have to write code and what you have is just a sensor? Be interesting to see what it is you're actually using...but maybe some of this will help in your quest.
Post back what you find out...
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!