[SOLVED] Importing raw data - or from text list

Help for Audacity on Windows.
Forum rules
ImageThis forum is for Audacity on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
Sprinterdriver
Posts: 47
Joined: Tue Jan 19, 2010 9:59 pm
Operating System: Please select

[SOLVED] Importing raw data - or from text list

Post by Sprinterdriver » Thu May 26, 2016 4:31 pm

Hi.

I currently posess a large text file with samples. It basically just holds the sample values for left and right channel - one line typically line would hold this information:
  • A signed integer between -32768 and +32768 (left channel)
  • a tab separator
  • signed integer (right channel)
I can always change the format of the list if neccessary in order to import.

I may be able to export as raw data, but I need to know how to assemble it in order to achieve correct stereo, I write what I guess is right and I hope you can correct me:
* No header at all - the samples starts just from first bit.
* 16-bit signed integer (left channel ?)
* 16-bit signed integer (right channel ?)
* 16-bit signed integer (left channel ?)
* 16-bit signed integer (right channel ?)
........
continues like this.



Thanks in advance
Last edited by Sprinterdriver on Fri Jun 03, 2016 2:21 pm, edited 1 time in total.

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

Re: Importing raw data - or from text list

Post by steve » Thu May 26, 2016 4:46 pm

The first thing is that "text" is not "raw data".
"Raw data" is a series of binary numbers, 0's and 1's.
"Text" is a series of "characters". Each character is represented in a file or data stream by a binary number. The relationship between the number and the character depends on the character encoding. For example, using ASCII encoding, the character "6" is represented by the binary number 00110110, which is the decimal number 54.
http://www.ascii-code.com/

So what you have is a text file that lists sample values, not "raw data".

In order to convert that text into audio, you would a program to "read" the text and generate sample values (the actual "raw data") from the text.

In this forum post there is some experimental Nyquist code for reading sample values from a text file: http://forum.audacityteam.org/viewtopic ... 13#p207413

Does that help?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Sprinterdriver
Posts: 47
Joined: Tue Jan 19, 2010 9:59 pm
Operating System: Please select

Re: Importing raw data - or from text list

Post by Sprinterdriver » Thu May 26, 2016 8:34 pm

Thank you, I already know the theory behind different data types and text encdings, that is not the issue.

Your answer confirmed what I suspected - that I need to convert the text file by using another software - wich by the way doesn't seem to exist, at least due to web search for "convert text wav".

I'm a little above beginner level in Autohotkey, so I thing I would be able to save the values as a binary file, wich I plan to import using Audacity (after some research on their forum I hope to figure it out - that is another issue).

However - I hope someone here does know how to put together a raw audio file in order to be able to correctly import it in Audacity.

cyrano
Posts: 2629
Joined: Fri Apr 17, 2015 11:54 pm
Operating System: macOS 10.13 High Sierra

Re: Importing raw data - or from text list

Post by cyrano » Thu May 26, 2016 10:40 pm

Excel can convert numbers into binary. :D

There are even webpages who do that.

But I don't have a clue how to go from binary to audio. Up until now, I always supposed raw audio to be binary. If it's hex, any hex editor can convert from binary to hex.

Can't Sox help?

http://sox.sourceforge.net/

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

Re: Importing raw data - or from text list

Post by steve » Thu May 26, 2016 11:54 pm

Sprinterdriver wrote:Your answer confirmed what I suspected - that I need to convert the text file by using another software - wich by the way doesn't seem to exist
Please read all of my previous answer.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Sprinterdriver
Posts: 47
Joined: Tue Jan 19, 2010 9:59 pm
Operating System: Please select

Re: Importing raw data - or from text list

Post by Sprinterdriver » Tue May 31, 2016 11:22 pm

Thanks Steve. I've spend this afternoon and the day before by testing the plugin you reffered to.

I was able to use convert a CSV file with multiple coloumns into several single coloumns CSV files, while adjust the number format using Libre Office Calc.
The big issues was to keep the numbers in output csv file from growing beyond ±1, but sorted it out (within Calc).

Second - there is no "Browse" button in the plugin gui, just a input field. For that I have a Autohotkey script that I've put in the sendto folder. It simply put the file path(s) to the clipboard (unlike copy file from within Windows explorer):

Code: Select all

If !%0%
ExitApp
Loop %0%
{
GivenPath := %A_Index%
i := A_index
Loop %GivenPath%, 1
{
If (i = 1)
LongPath := A_LoopFileLongPath
Else
LongPath := LongPath . "`n" . A_LoopFileLongPath
}
}
clipboard := LongPath
Sleep 100
Third - At my locale - the decimal separator is a comma (not a dot), so in aditional I need to do a search/replace for that in the CSV file.


Result / Bonus:
I've now the compressed samples of the physical G-forces my bike takes over a ten minutes ride, and I have used Audacity (among other programs) to convert those movements into auditible sound - as if the bike was a pickup.

The only not perfect thing about this is that the record isn't for the actual movement as for a vinyl pickup coil, but rather the acceleration. To fix this I tried to (in Calc) do a integration of the samples. At first samples (couple of pages) it looks good, but the integrated (converted to movement/distance) it slowly grows to very large numbers, and is therefore useless for converting to audio. Well - unless I find a way to simulate high pass filter in large data samples in Calc. The latter belongs to another forum - I just want to shed som light on what I've experienced given the help I got here.

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

Re: Importing raw data - or from text list

Post by steve » Wed Jun 01, 2016 1:13 am

Sprinterdriver wrote:Second - there is no "Browse" button in the plugin gui
Unfortunately that is currently a limitation of Nyquist plug-ins. Hopefully there will be a browse button some time in the future, but for now we have to make do with an ugly workaround of using a text box. This limitation is the main reason that I've not pursued developing this plug-in further.
Sprinterdriver wrote:For that I have a Autohotkey script that I've put in the sendto folder. It simply put the file path(s) to the clipboard (unlike copy file from within Windows explorer):
Thanks for posting the Autohotkey script. I can't test it myself as I don't use Windows, but it may be useful to others.
Sprinterdriver wrote:Third - At my locale - the decimal separator is a comma (not a dot), so in aditional I need to do a search/replace for that in the CSV file.
As with most computer languages, Nyquist requires a dot as the decimal separator.
At the time that this plug-in was written it was not possible for Nyquist to detect the locale. Nyquist in Audacity can do that now, so it would now be possible to extend the plug-in code so that it automatically converted commas to dots where a comma is the decimal separator for the locale.
Sprinterdriver wrote:I've now the compressed samples of the physical G-forces my bike takes over a ten minutes ride, and I have used Audacity (among other programs) to convert those movements into auditible sound - as if the bike was a pickup.
Ha :D Cool 8-)
Please post a short sample, I'd love to hear how it came out (how to upload audio samples to the forum: http://forum.audacityteam.org/viewtopic ... 49&t=72887)
Sprinterdriver wrote:The only not perfect thing about this is that the record isn't for the actual movement as for a vinyl pickup coil, but rather the acceleration. To fix this I tried to (in Calc) do a integration of the samples.
An alternative approach would be to integrate the audio samples in Audacity.
Nyquist has an "integrate" function: http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index375
If you want some help with that, just ask.
Sprinterdriver wrote:Well - unless I find a way to simulate high pass filter in large data samples in Calc.
which of course is very easy to do in Audacity and/or Nyquist.
Sprinterdriver wrote:The latter belongs to another forum
If you'd like to discus more about using Nyquist, I can move this topic to the Nyquist part of the forum.
Sprinterdriver wrote:I just want to shed som light on what I've experienced given the help I got here.
Thanks, very interesting, and glad that you've had some success with it.
cyrano wrote:Excel can convert numbers into binary. :D
Converting into text notation of binary numbers does not help.
cyrano wrote:Up until now, I always supposed raw audio to be binary.
It is binary.
cyrano wrote:any hex editor can convert from binary to hex
No, a hex editor converts binary into text.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Sprinterdriver
Posts: 47
Joined: Tue Jan 19, 2010 9:59 pm
Operating System: Please select

Re: Importing raw data - or from text list

Post by Sprinterdriver » Wed Jun 01, 2016 7:24 pm

Ok here is the sound:
https://soundcloud.com/random-stereo-so ... compressed
It was not ten minutes but rather five and a half - so it makes the "time compression rate" something like 189,5 times.

The fun thing is when I see the graphical wave form in Audacity, I recognise every spike as a speed bump or crossing of road and other known bumps on the route 8-)

If any interest I can try to make an ahk script to open a file within the nyquist gui box...

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

Re: Importing raw data - or from text list

Post by steve » Wed Jun 01, 2016 7:49 pm

Thanks Sprinterdriver, that's fantastic :D
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Sprinterdriver
Posts: 47
Joined: Tue Jan 19, 2010 9:59 pm
Operating System: Please select

Re: Importing raw data - or from text list

Post by Sprinterdriver » Wed Jun 01, 2016 8:17 pm

About the integration, I think there is a major issue - a large carrier wave bothe lenghtwise and values of max/min sample.

For a data serie where the samples lays between -1 an +1, and even if all samples is substracted to the average value (attempt to prevent growing) - I still end ut with a "long wave" that has a wave length that spans beyond the length of the data sample, but the largest values is like -300 and +480 - and I doubt that those data are accepded for sample input.

Therefore I've figured the best method is probably to filter this out somehow using Libre Office Calc. I've learn the basic about digital filtering ag school - almost twenty years ago - and cannot recall the methods by now.

Post Reply