Page 1 of 2

how to export raw data to Matlab?

Posted: Wed Jan 21, 2009 8:06 pm
by ahajnal
Hello everyone,

I have a newbie question. I want to export raw data of sound intensity into a text file or an excel file for further processing in Matlab. I basically need two columns of data: 1) timestamps of each sample; 2) sound intensity level at each sample.

I am not interested in music or complex sound properties, all I need is to extract how sound intensity changes over time.

Many thanks,
Alen

Re: how to export raw data to Matlab?

Posted: Fri Jan 23, 2009 2:59 pm
by steve
ahajnal wrote:raw data of sound intensity
What exactly do you mean? Do you want individual sample values, peak levels within a time frame, RMS values within a time frame, average energy levels, or something else?

Could you perhaps export the audio from Audacity as raw data, then read that directly into MatLab?

Re: how to export raw data to Matlab?

Posted: Mon Mar 09, 2009 5:00 pm
by mjmes
Basically I have the same question as Ahajnal.

For a stereo signal, how do I export the signal as two text files each representing one channel?

Kindest Regards,
Mari

Re: how to export raw data to Matlab?

Posted: Mon Mar 09, 2009 8:31 pm
by steve
mjmes wrote:Basically I have the same question as Ahajnal.
For a stereo signal, how do I export the signal as two text files each representing one channel?
And like Ahajnal you have not said what kind of "representation" you want.

Re: how to export raw data to Matlab?

Posted: Tue Mar 10, 2009 12:17 pm
by mjmes
Thanks Steve, the file specs were incomplete. What I am looking for is two integer text export files for a stereo recording (one file for each channel) that records a stereo signal as:

Filename ch 1.dat
[ASCII 44100Hz, Channels: 1, Samples: 34433, Flags: 1]
297
322
341
.....

Filename Ch 2.dat
[ASCII 44100Hz, Channels: 2, Samples: 34433, Flags: 1]
343
324
299
.....

The " Ch 1" and " Ch 2" would be an automatic addition to the input file name when this option is used.

Kindest Regards,
Mari

Re: how to export raw data to Matlab?

Posted: Tue Mar 10, 2009 9:53 pm
by kozikowski
Not in Audacity (that I know of), but you might be able to get the data from a hex editor. This is Hex Fiend opening up my piano2.wav file on a Mac.

Image

Of course you'll need to know exactly what the file format is ahead of time and it can't be compressed. No MP3 files for you.

Koz

Re: how to export raw data to Matlab?

Posted: Wed Mar 11, 2009 12:27 am
by steve
You can get easily the sample values using Nyquist. I'm not familiar with Matlab, so I've no idea what the integers that you refer to represent.

Re: how to export raw data to Matlab?

Posted: Wed Mar 11, 2009 9:41 pm
by Gale Andrews
Does Sox help you - import the WAV then write as textual data, which I figure would give you the amplitude of each sample (e.g. -0.888617 at one particular sample then + 0.323733 one hundred samples down the line) - something like the data that another user produced from a VB dump:
http://n2.nabble.com/WAV-file-from-Auda ... 15889.html

I'm not sure if opening the audio in a hex editor will let you get at the dec data - the hex editor I have won't let you do that.


Gale

Re: how to export raw data to Matlab?

Posted: Wed Mar 11, 2009 10:34 pm
by mjmes
Steve, I don't know "Nyquist" other than in "Nyquist frequency", obviously out of context.

Gale, thanks for the suggestion. From the specifications it looks like it will work. I have spent some time on how I would streamline the Audacity output. Unfortunately I write it in Word with graphics. I found out too late that I cannot post that. I have asked for some advice on that one.

The more I work with Audacity, the more I like it. I use it and want to use it more to check on multi-channel measurements presented to Audacity as an analog channel output, just like sound. So far I have only done 2 channels, but soon I'll try more.

Kindest Regards,
Mari

Re: how to export raw data to Matlab?

Posted: Wed Mar 11, 2009 11:28 pm
by kozikowski
<<<I found out too late that I cannot post that. I have asked for some advice on that one. >>>

You can't post very much stuff directly to the forum. You can post stuff Somewhere Else and point to it on the forum. I usually push stuff up to my own web site and write the URL here. My web site is starting to look like my garage.

Most normal people find a free hosting service that will allow you to put some stuff on line in exchange for commercials or something.

Koz