Convert .txt/.mat to .wav format
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
dpb
le 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 commentaires
dpb
le 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...
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!