Filter löschen
Filter löschen

Convert .txt/.mat to .wav format

6 Ansichten (letzte 30 Tage)
bilal malik
bilal malik am 25 Mär. 2017
Kommentiert: dpb am 28 Mär. 2017
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

Akzeptierte Antwort

dpb
dpb am 25 Mär. 2017
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 Kommentare
bilal malik
bilal malik am 27 Mär. 2017
Thank you for your help dpb, much appreciated.
I will investigate the sampling rate issue and then after that look to try and convert it to a .wav file with the correct frequency.
dpb
dpb am 28 Mär. 2017
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...

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by