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.
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.
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.
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.
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):
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.
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.
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.
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.
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
If any interest I can try to make an ahk script to open a file within the nyquist gui box…
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.
Here is a Autohotkey script that add a Open file dialog box to the Sample Data Import (SDI for short) dialog box:
Here is how the script must be used:
Must run at the same time as Audacity.
User would have to open the SDI by pressing Alt+N while main window is active.
When SDI dialog box is active, user may press Ctrl+O to browse for a file. The file path will be inserted into the text field.
Things that may not work
May not activate correct menu item after pressing Alt+N if SDI is not the last item on list, or if language* of Audacity interface is not english.
Inside SDI dialog box, the buttons must NOT be activated (e.g. using tab inside) before Ctrl+O is pressed. Cursor MUST be placed in text input field.
If SDI dialog box is opened manually (using mouse) - the tooltip will not appear. The Ctrl+O will however still function.
Any future updates of SDI may change window title, or what control inside SDI gui that is active by default, may cause the script to not function properly.
If the menus in Audacity is in different languages than english, there may be wrong menu opened, because the script sends the keystrokes Alt+G to open the dialog box.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Posted by Sprinterdriver on Audacityforum - 02.06.2016.
; https://forum.audacityteam.org/t/solved-importing-raw-data-or-from-text-list/42504/1
#Singleinstance Force
#persistent
IfWinExist, Sample Data Import...
SetTimer, sampleDataImport_timer, 50
; Audacity main window
#IfWinActive, ahk_class wxWindowClassNR
; Alt+N --> Open "Generate / Sample data import"
; Important note - It need to be at bottom of the list in order to be able to select.
!n::
KeyWait, n
KeyWait, Alt
Send {Alt down}g
Send {Alt up}
Send {Up}{Enter} ; If the "Sample data import" is second last item, change to {up 2} - and so on.
SetTimer, sampleDataImport_timer, 50
Return
; Keep tooltip in place and close whenever the window close or loose focus.
sampleDataImport_timer:
IfWinActive, Sample Data Import...
ToolTip, Press Ctrl+O to browse the file to open, 105, 60
Else {
ToolTip
IfWinNotExist, Sample Data Import...
SetTimer, sampleDataImport_timer, Off
}
Return
#IfWinActive, Sample Data Import...
; Ctrl+O
; User still need to manually click OK to actually start the process..
^o::
FileSelectFile, filePath, 1, %A_MyDocuments%, Open a list of samples file, Plain text files (*.txt; *.csv)
If errorlevel ; Canceled by user
Return
SendInput, %filePath%
Return
Thanks Sprinterdriver. As I wrote earlier, I can’t try it myself as I’m not on Windows, but it may well be useful for others.
If you’re interested in ‘signal processing’ in any form, you should have a look at Nyquist. I think you’d enjoy it If you’d like a chat about Nyquist scripts and what they can do, drop in a post on the Nyquist part of the board (http://forum.audacityteam.org/viewforum.php?f=39) and I’d be happy to chat with you about it.
Are you happy with the outcome of this forum thread? If so I’ll close it.
What version of Windows are you on and which version of Sample Data Import are you using?
On Windows 10 using http://forum.audacityteam.org/download/file.php?id=7264 (space added at the end of line 13) and latest AutoHotKey, ALT + N and CTRL + O do nothing. Yes, the script is running and other AHK scripts work.
OK, so following a PM from Sprinterdriver (who is on Windows XP) I had to open WIndow Spy from the running script’s context menu to see what AHK expects for the window title. Accordingly I changed the line in the script after “; Audacity main window” to
#IfWinActive, ahk_exe audacity.exe
And I had to change all the instances of the plugin’s window title to
Sample Data Import
without the “…” because current Audacity removes the ellipsis given in the ;name line in the plugin from the plugin’s dialogue window. Some older versions of Audacity did not do that.
Also another consideration on Windows 8/8.1 and 10 at least is that if Audacity is running with Administrative privileges the AHK script must be run with Administrative privileges too, or it will appear to do nothing.
UPDATE - I’ve figured out a method for supressing growth of integral of samples over time in Libre Office Calc. The method is simply to substract the average of a range* before and after each integrated samples.
For this specific collection of sample data, I choose a range of 200 samples before and 200 samples prior - and less when closing in to start and end of data serie.
The .ods file is too big to upload, a brief description of the formula I used:
Data serie (integral) is in coloumn E. So in Cell F10000, the formula would be (range of average in this formula is ±50):
=E10000-AVERAGE(E9950:E10050)
Resulting sound
Pretty interesting - I noticed that the auditible sound from the integrated data series is almost the same as for the original data serie, exepf it sounds like a high pass filter is applied - due to the formula used to suppress growing of samples, having similar effect on the sound as a high pass filter.