how to export raw data to Matlab?

Effects, Recipes, Interfacing with other software, etc.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
ahajnal
Posts: 1
Joined: Wed Jan 21, 2009 8:02 pm
Operating System: Please select

how to export raw data to Matlab?

Post by ahajnal » Wed Jan 21, 2009 8:06 pm

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

steve
Site Admin
Posts: 80752
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: how to export raw data to Matlab?

Post by steve » Fri Jan 23, 2009 2:59 pm

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?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

mjmes
Posts: 5
Joined: Sat Mar 07, 2009 5:14 pm
Operating System: Please select

Re: how to export raw data to Matlab?

Post by mjmes » Mon Mar 09, 2009 5:00 pm

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

steve
Site Admin
Posts: 80752
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: how to export raw data to Matlab?

Post by steve » Mon Mar 09, 2009 8:31 pm

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.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

mjmes
Posts: 5
Joined: Sat Mar 07, 2009 5:14 pm
Operating System: Please select

Re: how to export raw data to Matlab?

Post by mjmes » Tue Mar 10, 2009 12:17 pm

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

kozikowski
Forum Staff
Posts: 68941
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: macOS 10.13 High Sierra

Re: how to export raw data to Matlab?

Post by kozikowski » Tue Mar 10, 2009 9:53 pm

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

steve
Site Admin
Posts: 80752
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: how to export raw data to Matlab?

Post by steve » Wed Mar 11, 2009 12:27 am

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.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Gale Andrews
Quality Assurance
Posts: 41761
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: how to export raw data to Matlab?

Post by Gale Andrews » Wed Mar 11, 2009 9:41 pm

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
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

mjmes
Posts: 5
Joined: Sat Mar 07, 2009 5:14 pm
Operating System: Please select

Re: how to export raw data to Matlab?

Post by mjmes » Wed Mar 11, 2009 10:34 pm

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

kozikowski
Forum Staff
Posts: 68941
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: macOS 10.13 High Sierra

Re: how to export raw data to Matlab?

Post by kozikowski » Wed Mar 11, 2009 11:28 pm

<<<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

Post Reply