Azzera filtri
Azzera filtri

Convert .txt/.mat to .wav format

6 visualizzazioni (ultimi 30 giorni)
bilal malik
bilal malik il 25 Mar 2017
Commentato: dpb il 28 Mar 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

Risposta accettata

dpb
dpb il 25 Mar 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 Commenti
bilal malik
bilal malik il 27 Mar 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 il 28 Mar 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...

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by