LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Empty wav file ?

Hello
 
I am setting up a system to stream audio data to disk and then post-process the data. The data is being streamed from a PXI 4462 and saved as a binary file. I then have a seperate VI that opens the binary file and displays the waveform.  This is working perfectly. However I would also like to create a wav file of the data for use at other times. I have wired the same input that goes from my graph into a write wav file block. A file is created, but when I open it, the file plays but is silent. Is this a scaling problem - I have tried using the input values and dB scaled values with no affect. Can anyone tell me what values the write wav file block is looking for. I have checked that the correct input is selected (mono 16 bit , 44100).
 
Any help greatly appreciated
 
Cheers
 
Dave
0 Kudos
Message 1 of 9
(3,804 Views)
Could you post a copy of your wav file and your code for me to have a look at?
Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 2 of 9
(3,768 Views)

There are some examples in the NI Example finder that may help with this application if you're still working on it. If you open the Example Finder and search for the keyword "sound".

The examples Record Wave File.vi and Play Sound.vi should give you an idea of how to set up your wav file to play.

Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 3 of 9
(3,759 Views)

Sarah

Thanks for your input, however what I am doing is slightly different to these examples. I basically have a data file, which I would like to open and save a copy as a wav file. What I am interested in is the range of values which the write wav file vi can accept. If I use sound pressure then the values will be from about -20 to +20 whearas if I use SPL then the values should be from 0 to 120.

 

Cheers

 

Dave

0 Kudos
Message 4 of 9
(3,754 Views)

Hi Dave,

I found the following on another discussion forum:

A few things you should know before trying to record a wave file:

The type of wave file must be known. This is either 8 bit mono, 8 bit stereo, 16 bit mono, or 16 bit stereo. You have a 2D array, which indicates stereo. The 8 or 16 bit selection is then a matter of the levels of your array (amplitude). If the values are in the range of -127 to 127, then you have an 8 bit array. If they are between -32687 and 32687, then you have a 16 bit array. If they are somewhere in between, you will have to scale them, otherwise, you risk the volume being too low.

In order to input your array, you have to convert
it to an integer. In the math palette, you will find a conversion sub palette. Just drop in a U8 or U16 between your array and the appropriate input, and you will be set.

Again, depending upon your data, you will need either 8 or 16 bit stereo, and you have to put that in the Sound Format cluster (constant). The bottom variable is for the sample rate, which again, depends on your data.

Do you think your data is formated correctly according to this?

If so, and it's still not working, could you post your code so I can have a play around with it.

 

Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 5 of 9
(3,753 Views)

Hi Sarah

Thanks for that info and sorry for the delay in replying - I've only just got back round to looking at this project again. I wrote a vi that normalises the wave and scales it up to +-32000 and converts to integers. Fed it ino a wav vi and it now works perfectly.

Thanks for the help

Dave

0 Kudos
Message 6 of 9
(3,723 Views)
Hi Dave,

I was wondering whether I can take a look at the jpg image of your VI. I am trying to build a similar VI as of yours in which while acquiring the real time data from microphone from PXI 4472 I should be able to listen along with it.

Regards
Nitin
0 Kudos
Message 7 of 9
(3,696 Views)

Hi Nitin

Here is a JPG of the main part of the Vi. As you will see I am actually reading the data from a file. Hope this is some help.

 

Cheers

Dave

Message 8 of 9
(3,685 Views)
Hi Dave,

Thanks for your jpg. That worked for me and now i am able to play the sound and I made some changes for my program to run the file.

Thank you very much

Regards
Nitin
0 Kudos
Message 9 of 9
(3,671 Views)