Converting Audacity Sound Wave to Numerical form and vice versa

Hi,

I am trying to convert my recorded sound wave on Audacity, into a numerical form (a bit like a list of x,y coordinates) and import this into an Excel spreadsheet, and/or Python. Is there any way I can do this? I’m sure there must be some sort of technique which would allow me to just capture the audio as a text file but not exactly sure how! Secondly, is there any way to convert a bunch of coordinates into something that Audacity can read and play back to me as sound? Many thanks!

Best wishes,

See here: https://manual.audacityteam.org/man/sample_data_export.html
and here: https://manual.audacityteam.org/man/sample_data_import.html

Note that for the default sample rate of 44100, there are 44100 samples per audio channel each second. Each character in a text or csv file requires (at least) one byte of data, so 1 second of mono audio will produce over 366 KB of text data.

Hi,
Thanks so much.
Just a quick follow up.
When I try to export time indexed data I get two duplicate columns of the ‘y value’ rather than one column with the x values. Are you aware of how I could troubleshoot this?

With the import, I am getting an error message that says ‘The file must contain only plain ASCII text. Invalid byte 255 at byte number:1’
Any ideas what this means?

Are you sure?
Try selecting some absolute silence (“Generate menu > Silence”).
When it is a mono track with a sample rate of 44100, the exported data should look like this:

Measurement scale: Linear

0.00000	0.00000
0.00002	0.00000
0.00005	0.00000
0.00007	0.00000
...

Measurement scale: dB

0.00000	[-inf]
0.00002	[-inf]
0.00005	[-inf]
0.00007	[-inf]
...

Is that what you get?

What is the first line of the file that you are trying to import?
What format is the file that you are trying to import, and how did you create it?

Hi steve,
Is it possible I could speak to you over phone/verbally?
As it will take quite a long time to communicate on the forum. No worries if that isn’t possible.

In answer to the first post - No I don’t get that, I get a single column of zeros

What settings are you using in Sample Data Export?

Hi steve,
Is it possible I could speak to you over phone/verbally?
As it will take quite a long time to communicate on the forum. No worries if that isn’t possible.

In answer to the first post - No I don’t get that, I get a single column of zeros

A lot of songs have silence in the beginning so it wouldn’t be unusual to get several thousand zeros before you get to the audio. Try selecting some audio where you can see the wave instead of starting at the beginning.

I’ve never programmed in Python but it should be simple to open a WAV file. A [u]WAV file[/u] is simply a header followed by a series of “Y” values (the amplitude at one instant in time).

The header contains the number of bits per sample and the number of samples so the software knows how to convert the bytes to sample values and separate left from right in a stereo file. The 'X" values are implied by the sample rate (samples per second).

Steve, did you get my private message showing you my settings?

I got your PM but:

  1. Attachments are not permitted, so I’ve not seen the screenshot.
  2. I spend a lot of time helping people on this forum, but I don’t provide support via PM, email, telephone, Skype, Zoom, or anything else.

Please just type the settings that you are using into your reply.

Sure no worries Steve I understand.
Settings as follows:
1000, Linear, (File Pathway), Time Indexed, None, Blank, L-R on same Line, Yes.
We can deal with the import issues after this.

If you select some silence (1000 samples or more) with those settings, AND the file name ends with “.txt”, then you will get:

0.00000	0.00000
0.00002	0.00000
0.00005	0.00000
0.00007	0.00000
...

Note that the “Index” column is only created for .txt files.

I am choosing a csv file - will that not work?

What is the first line of the file that you are trying to import?
What format is the file that you are trying to import, and how did you create it?

In answer to this question

0.00 -0.05
I just took my y values that I was getting and modified the first column with time values every 0.025 seconds.
Text format = txt

The “Index” column is only created for .txt files.

Please attach the file that you are trying to import. (See: https://forum.audacityteam.org/t/how-to-attach-files-to-forum-posts/24026/1)

Here is document I am trying to import but which brings up the aforementioned error message. The export is now working.
Audacity Test Import.txt (33.7 KB)