Converting recorded sound (text file) back into playable audio?

Discuss hardware/software tools and techniques involved in capturing sound, in the studio, live or on location.
Post Reply

Converting recorded sound (text file) back into playable audio?

Post by toppe »

Hi all, I am new to the forums here and looking for some help.

I have a lot of stored data from measuring noise generated by various pieces of machinery. This is recorded by a G.R.A.S. microphone and read into the computer by Labview hardware and interface. The measured data is then written to a text file at 49kHz sampling.

My question is this: is there a way to convert this back into a playable audio format? My engineering sense tells me that there should be an easy way since all of the necessary information is present in the file. However, the google approach failed me here since the search results using relevant words almost entirely point towards speech-to-text converters or various audio converter softwares.

Any help or relevant links would be much appreciated. Thanks!
toppe
New here
Posts: 4 Joined: Mon Feb 25, 2013 12:00 am

Re: Converting recorded sound (text file) back into playable audio?

Post by twotoedsloth »

Have you tried importing the data in raw format, in Sound Forge? You might have to load your data into Excel first to sort the information.
twotoedsloth
Frequent Poster
Posts: 1136 Joined: Sat Jan 26, 2008 12:00 am

Re: Converting recorded sound (text file) back into playable audio?

Post by Madman_Greg »


I'd be surprised if these files were text.

http://www.ni.com/white-paper/4139/en
Madman_Greg
Frequent Poster
Posts: 534 Joined: Thu Dec 07, 2006 12:00 am Location: The back of beyond
Madman_Greg

Re: Converting recorded sound (text file) back into playable audio?

Post by Richie Royale »

Based on Madman Greg's link, it looks like the files are ASCII text files, so I don't think there is any audio data to be extracted, but I am far from knowledgeable about technical things like this.

I would have a good look on their website

http://www.ni.com/support/
User avatar
Richie Royale
Frequent Poster
Posts: 4551 Joined: Tue Sep 12, 2006 12:00 am Location: Bristol, England.

Re: Converting recorded sound (text file) back into playable audio?

Post by Madman_Greg »

Richie Royale wrote:but I am far from knowledgeable about technical things like this.

Neither am I, the last time I worked with data logger technology was back around 1986 :shock:

Was interesting to see how it has moved on though...
Madman_Greg
Frequent Poster
Posts: 534 Joined: Thu Dec 07, 2006 12:00 am Location: The back of beyond
Madman_Greg

Re: Converting recorded sound (text file) back into playable audio?

Post by BJG145 »

It sounds like there's a way to convert between WAV files and LabVIEW waveform data, so it may be possible to resurrect the audio using LabVIEW if you have the right files.

http://cnx.org/content/m14771/latest/
User avatar
BJG145
Longtime Poster
Posts: 8081 Joined: Sat Aug 06, 2005 12:00 am Location: UK

Re: Converting recorded sound (text file) back into playable audio?

Post by toppe »

Thanks for the quick responses.
twotoedsloth wrote:Have you tried importing the data in raw format, in Sound Forge? You might have to load your data into Excel first to sort the information.


Madman_Greg wrote: I'd be surprised if these files were text.

http://www.ni.com/white-paper/4139/en

At this point, I do not think it is a ni issue. The text files were written as ASCII by a custom assembly code written by my predecessor. There is a short header which lists operator name and such and then four columns of tab-separated data; time, and three (scaled to Pascals) microphone signals. I can manipulate this file however is necessary, but the question put more precisely is "can a column of pressure values and known sampling frequency be encoded as playable audio?" I am not familiar with raw format, if raw can be converted to other types and can be created by simply formatting text, then that might be my best option.

BJG145 wrote:It sounds like there's a way to convert between WAV files and LabVIEW waveform data, so it may be possible to resurrect the audio using LabVIEW if you have the right files.

http://cnx.org/content/m14771/latest/

I think I will try this, thanks!

Any other suggestions would be still be very welcome. Thanks again for the advice.
toppe
New here
Posts: 4 Joined: Mon Feb 25, 2013 12:00 am

Re: Converting recorded sound (text file) back into playable audio?

Post by ken long »

toppe wrote:I can manipulate this file however is necessary, but the question put more precisely is "can a column of pressure values and known sampling frequency be encoded as playable audio?" I am not familiar with raw format, if raw can be converted to other types and can be created by simply formatting text, then that might be my best option.

SPL values will not be needed for this but sample rate will. Someone mentioned Soundforge. Another free equivalent is Audacity (http://audacity.sourceforge.net/). This is a free download and will open RAW files provided you supply the header with bit depth, sample rate and channel count. Then it's just a question of "Save As" your desired format.
User avatar
ken long
Frequent Poster
Posts: 3631 Joined: Mon Jan 21, 2008 12:00 am Location: Somers Town
I'm All Ears.

Re: Converting recorded sound (text file) back into playable audio?

Post by BJG145 »

toppe wrote:The text files were written as ASCII by a custom assembly code written by my predecessor.

If the data was generated by a custom program, then even assuming that it contains enough information to recreate a WAV file, you'd clearly need a custom program to do the conversion. Sounds like a lot of effort - what's the purpose...?
User avatar
BJG145
Longtime Poster
Posts: 8081 Joined: Sat Aug 06, 2005 12:00 am Location: UK

Re: Converting recorded sound (text file) back into playable audio?

Post by toppe »

ken long wrote: SPL values will not be needed for this but sample rate will. Someone mentioned Soundforge. Another free equivalent is Audacity (http://audacity.sourceforge.net/). This is a free download and will open RAW files provided you supply the header with bit depth, sample rate and channel count. Then it's just a question of "Save As" your desired format.

Thanks Ken. I have Audacity installed now. However, I am struggling to figure out what options to use when importing the raw data. Audacity prompts asking for bit encoding, byte order, channels, and sample rate. Do these have to be present in the header of the text file as well?

In order to test how the program works, I created a 440Hz sine wave in Excel with 5000Hz sampling and saved as a text file. I have tried a few different import settings, but the waveform showing up in Audacity is not the sine wave I generated. Is someone willing to try importing this as raw from a text file to help me figure out what settings to use or how to format the data differently? I do not see a good way to post a long string of values or attach a file on the forums here. I will post it if someone is willing to try it and can tell me a way to share the file with them.
toppe
New here
Posts: 4 Joined: Mon Feb 25, 2013 12:00 am

Re: Converting recorded sound (text file) back into playable audio?

Post by Madman_Greg »


The way I understand is as follows.....

RAW audio files do not contain any header information

As there is no header, compatible audio players require information from the user that would normally be stored in a header, such as the encoding, sample rate, number of bits used per sample, and the number of channels.

So if your code stripped those out, then you will need to know how they were encoded in the first place
Madman_Greg
Frequent Poster
Posts: 534 Joined: Thu Dec 07, 2006 12:00 am Location: The back of beyond
Madman_Greg

Re: Converting recorded sound (text file) back into playable audio?

Post by James Perrett »

If I was doing this I'd write a C program to do the translation. If you don't know C then Matlab may offer an easier alternative.

James.
User avatar
James Perrett
Moderator
Posts: 16984 Joined: Mon Sep 10, 2001 12:00 am Location: The wilds of Hampshire
JRP Music - Audio Mastering and Restoration. JRP Music Facebook Page

Re: Converting recorded sound (text file) back into playable audio?

Post by Madman_Greg »

Download a sine wave MP3

Put into audacity

Use the analyze / sample data export function

See what it produces - compare with the file you have

Use a number of different export options, to see the different, i.e. with header, headerless etc...

Might help you progress
Madman_Greg
Frequent Poster
Posts: 534 Joined: Thu Dec 07, 2006 12:00 am Location: The back of beyond
Madman_Greg

Re: Converting recorded sound (text file) back into playable audio?

Post by Jim Lockhart »

MatLab will import an ASCII text file into a MatLab variable. You can then plot the variable to see if it looks like a waveform. Then, use MatLab's wavwrite function to export a standard wav file; see this link http://www.mathworks.com/help/matlab/ref/wavwrite.html
Jim Lockhart
Poster
Posts: 49 Joined: Tue Jun 03, 2003 12:00 am Location: Menlo Park, California
The Sound Physicist

Re: Converting recorded sound (text file) back into playable audio?

Post by toppe »

Jim Lockhart wrote:MatLab will import an ASCII text file into a MatLab variable. You can then plot the variable to see if it looks like a waveform. Then, use MatLab's wavwrite function to export a standard wav file; see this link http://www.mathworks.com/help/matlab/ref/wavwrite.html

Wow, thank you so much! This solution was exactly what I what I needed and incredibly simple to implement in matlab.

data=load('noise.dat');
pressure=data(:,2);
Fs=1/(data(4,1)-data(3,1));
wavwrite(pressure,Fs,'sound.wav')

Thanks to everyone for the kind help, it looks like this works well to solve my problem. It converts a two column text file with time in the first column and pressure waveform in the second column into a playable .wav file.
toppe
New here
Posts: 4 Joined: Mon Feb 25, 2013 12:00 am
Post Reply