Page 1 of 2
exporting data as text file at 24fps
Posted: Mon Oct 24, 2011 12:05 pm
by alicemiceli
Is there any way to export data to a text file, both frequency and amplitude values over time, exactly every 24th of a second ?
My sound file to be analyzed is 3 minutes long. I'd need to know frequency amplitude values only at every 24th of a second (or every 0.0416667 seconds, the rounded duration of a 24 fps film frame).
I'm sorry if this is vague, this is my first post and I can happily try to elaborate if need be!
Thank you

Re: exporting data as text file at 24fps
Posted: Mon Oct 24, 2011 3:00 pm
by kozikowski
I don't believe Exporting Metada is a Chained (batch) event and the internal timer has only one event. So I'm going with no.
Koz
Re: exporting data as text file at 24fps
Posted: Mon Oct 24, 2011 3:31 pm
by billw58
There is no way to do it automatically that I can see.
Audacity stores amplitude information. To obtain frequency information you need to do Analyse > Plot Spectrum.
There is a way to do it manually but it would be extremely tedious, and you would end up with 24 x 60 x 3 = 4,320 text files of amplitude versus frequency, one for each 1/24 second of the file. Assuming you got really fast at it and could export a file every 30 seconds, it would take 36 hours.
-- Bill
Re: exporting data as text file at 24fps
Posted: Mon Oct 24, 2011 4:43 pm
by alicemiceli
Hi, thanks so much for getting back. I would not mind doing this manually at all, even if it will be for a few days, in order to acess the frequency and amplitude values for each 1/24 second of the file. I really need to do this!
I have done Analyse > Plot Spectrum for the 3-minute sound file, but the exported text file was only 0.005782 seconds long.
What would be the steps for doing it manually? Thanks.
Re: exporting data as text file at 24fps
Posted: Mon Oct 24, 2011 5:40 pm
by steve
Could you give more information about the frequency analysis that you need.
Are you needing to know the frequency of a pure (sine) tone, or is this complex sound with thousands of frequencies?
Re: exporting data as text file at 24fps
Posted: Mon Oct 24, 2011 5:51 pm
by alicemiceli
Sure. The final sound that needs to be analyzed, although not super rich in timbre, is not a pure sine tone. It is a melody played by a solo flute.
Re: exporting data as text file at 24fps
Posted: Mon Oct 24, 2011 6:20 pm
by kozikowski
So it's complex waveforms which lets out simple, quick analysis tools. This is an analysis of a single piano note.
http://kozco.com/tech/audacity/piano_G1.jpg
Koz
Re: exporting data as text file at 24fps
Posted: Mon Oct 24, 2011 6:50 pm
by alicemiceli
Yes, totally! It is a complex sound with many frequencies.
But hopefully the frequencies/amplitudes data export at the 1/24 second rate is nevertheless possible, even if manually and very painstaking?
Re: exporting data as text file at 24fps
Posted: Mon Oct 24, 2011 7:59 pm
by kozikowski
Maybe not. If you select a really tiny segment of sound, 1/24 second, Analyze > Plot Spectrum will not have enough sound to work with -- and will say so and fail.
For example if you have a performance of 240 Hz (roughly B below middle C), Analysis will only have 10 cycles of waves to work with. That's not enough for Fourier Transform to do its job.
Koz
Re: exporting data as text file at 24fps
Posted: Mon Oct 24, 2011 8:17 pm
by billw58
Using Audacity 1.3.13 ...
Go to Audacity > Preferences, the Interface pane and set Waveform/meter dB range to -96 dB (this affects the lower limit of the Plot Specturm function).
In the Selection Toolbar
http://manual.audacityteam.org/man/Selection_Toolbar set "Snap to": checked; in one of the drop-down menus beside the numbers, select "film frames (24 fps); select the "Length" radio button.
1) Set Selection Start to 000,000 and Length to 000,001 [you now have a selection of 1 frame in the audio]
2) Do Analyse > Plot Spectrum
- select Length: 1024 [you'll only have to do this once]
3) Click the Export... button, name and save the spectrum text file [e.g. spectrum0001.txt].
4) Click the Close button
5) Set Selection Start to 000,001 [you now have the second frame selected]
6) Repeat 2 through 5, incrementing the Selection Start by 1 frame each time
The text file is just that, a text file not an audio file. It is a tab-delimited text file with the first column being frequencies and the second column being levels at those frequencies. This is the data used to draw the spectrum plot for the selected audio. Open it in TextEdit and have a look.
Now that you have those 4,320 text files, you need to find some way to extract the data from them and plot it. I assume that what you'd like is one of those 3-D surface spectrograms like the third illustration on this page:
http://en.wikipedia.org/wiki/Spectrogram. This is a non-trivial task.
The frequencies in the text file are evenly spaced. So you get a lot more detail at the higher frequencies than you do at the lower frequencies. But you want to choose 1024 bands to get reasonable resolution at the low frequencies. You could reduce the data by averaging the amplitude data into octave bands or 1/3 octave bands. If you choose 1/3 octave bands you'd end up with an array of 30x4320 instead of 1024x4320 amplitude values.
You could attack the data analysis using a spreadsheet, but you won't get a 3D surface spectrogram from a spreadsheet. You could get line graphs of amplitude versus time for each frequency.
Hope this helps.
-- Bill