Importing text as audio/exporting audio as text

This section is now closed.
Forum rules
Audacity 1.3.x is now obsolete. Please use the current Audacity 2.1.x version.

The final version of Audacity for Windows 98/ME is the legacy 2.0.0 version.
steve
Site Admin
Posts: 81388
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Importing text as audio/exporting audio as text

Post by steve » Wed Mar 06, 2013 7:21 pm

JimMyskin wrote:I am able to generate tone data in audaicty and export to csv
How are you doing that?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

JimMyskin
Posts: 8
Joined: Wed Mar 06, 2013 3:42 pm
Operating System: Please select

Re: Importing text as audio/exporting audio as text

Post by JimMyskin » Wed Mar 06, 2013 9:40 pm

Hello Again Folks,

I had a thought just now. How do I convert my linear data into a format which can be read by Audacity?

Since Excel gives me the ability to generate, manipulate and export data, I should be able to come up with a conversion which is acceptible to the Raw Data import function.

Can anyone suggest what such an algorithm might be?

Thanks,

Jim

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

Re: Importing text as audio/exporting audio as text

Post by Gale Andrews » Wed Mar 06, 2013 10:12 pm

steve wrote:
JimMyskin wrote:I am able to generate tone data in audaicty and export to csv
How are you doing that?
Using "Sample Data Export" by one Steve Daulton. :D


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

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

Re: Importing text as audio/exporting audio as text

Post by Gale Andrews » Wed Mar 06, 2013 10:26 pm

JimMyskin wrote:Since Excel gives me the ability to generate, manipulate and export data, I should be able to come up with a conversion which is acceptible to the Raw Data import function.
Jim,

Audacity's Raw Data Import wants a binary file representing the sample values in 0's and 1's. If Audacity had a way (like Steve's experimental code to convert text data to binary) to interpret imported text values, then you just need the same encoding that the exported file had, assuming you do not change that in your manipulations.

To use Steve's experimental code you may need to export from Excel as pure plain text (or use another program that can do that, or one which can manipulate pure plain text in the first place).

I could not find the topic where Steve's code lives hence I resurrected this topic as it is clearly all about the identical issue.



Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

Robert J. H.
Posts: 3633
Joined: Thu May 31, 2012 8:33 am
Operating System: Windows 10

Re: Importing text as audio/exporting audio as text

Post by Robert J. H. » Wed Mar 06, 2013 11:09 pm

I usually copy the values from the debug window and insert them in Excel.
If I want to create more than one column, I insert a special separater (% / ' etc.) and call afterwards "text in columns".
This works of course only for a few hundred samples.
It would be nice if data could directly be sent to the clipboard from within Nyquist, i.e. an output direction that writes "files" to the clipboard instead of a file pointer allocation on the hard drive (Feature Request?).

@JimMyskin
What format do you have in mind for the RAW export from Excel?
RAW data is normally written in bytes. Excel handles only text based formats (if no formatting is needed i.e. pure values).

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

Re: Importing text as audio/exporting audio as text

Post by Gale Andrews » Thu Mar 07, 2013 3:39 am

Robert J. H. wrote:It would be nice if data could directly be sent to the clipboard from within Nyquist, i.e. an output direction that writes "files" to the clipboard instead of a file pointer allocation on the hard drive (Feature Request?)
Do you want to request that in a new post in Nyquist wish list http://forum.audacityteam.org/viewtopic ... 39&t=38252 ?


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

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

Re: Importing text as audio/exporting audio as text

Post by steve » Thu Mar 07, 2013 3:44 am

Gale Andrews wrote:I could not find the topic where Steve's code lives
I don't think I posted it.

I've got about a dozen different versions on my computer - none complete. but here is one version that works, though with strict limitations.

This is experimental code. There is no error checking. Any user error will just cause the plug-in to silently fail with no indication why.

The text file must be a list of linear values only, for example:

Code: Select all

0.00000
0.05012
0.10004
0.14957
0.19851
0.24667
0.29386
0.33990
0.38460
0.42779
Stereo data is not supported - mono only.

The "input File" text box must be the fully qualified address of the text file to be imported. A valid example (Linux) might be:
/home/username/Desktop/sample-data.txt
On Windows the address would start with C: or whatever the drive letter is. I've not tested on Windows - the file separator may need to be a forward slash rather than the usual back slash.

Try testing with known good data and be very careful to get the file address correct.
This is a "Generate" type plug-in so will appear in the Generate menu when installed.
Attachments
ExperimentalSampleDataImport.ny
(1.16 KiB) Downloaded 466 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Robert J. H.
Posts: 3633
Joined: Thu May 31, 2012 8:33 am
Operating System: Windows 10

Re: Importing text as audio/exporting audio as text

Post by Robert J. H. » Thu Mar 07, 2013 4:17 am

Gale Andrews wrote:
Robert J. H. wrote:It would be nice if data could directly be sent to the clipboard from within Nyquist, i.e. an output direction that writes "files" to the clipboard instead of a file pointer allocation on the hard drive (Feature Request?)
Do you want to request that in a new post in Nyquist wish list http://forum.audacityteam.org/viewtopic ... 39&t=38252 ?


Gale
Maybe I should do this lest the idea gets lost.

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

Re: Importing text as audio/exporting audio as text

Post by Gale Andrews » Fri Mar 08, 2013 5:13 am

steve wrote:I've got about a dozen different versions on my computer - none complete. but here is one version that works, though with strict limitations.

The text file must be a list of linear values only
Is your aim to produce a version that is compatible with an export type produced by Sample Data Export? That's what's wanted, isn't it?
steve wrote:The "input File" text box must be the fully qualified address of the text file to be imported.
On Windows, choosing "Sample Data Import..." from the Generate Menu produces "Nyquist did not return audio" (without any text box) either with no track, an empty mono track or a mono track containing audio present.


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

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

Re: Importing text as audio/exporting audio as text

Post by steve » Fri Mar 08, 2013 6:24 am

Gale Andrews wrote:Is your aim to produce a version that is compatible with an export type produced by Sample Data Export? That's what's wanted, isn't it?
Sample Data Export can export data in a format that is compatible with this "Import" plug-in using a mono track and:
  • Measurement Scale: Linear
  • File data format: Sample List (txt)
  • Include header information: None
Eventually it should support other formats produced by Sample Data Export, but getting it to work with stereo data is the next step before worrying about other format options. It should also have error checking and return meaningful error messages.
Gale Andrews wrote:On Windows, choosing "Sample Data Import..." from the Generate Menu produces "Nyquist did not return audio" (without any text box) either with no track, an empty mono track or a mono track containing audio present.
Try opening the file "ExperimentalSampleDataImport.ny" in a plain text editor (such as NotePad or NotePad++) and add a space to the end of line 13:

Code: Select all

;control file "Input file" string "" ""
Then save the file.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Locked