LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to log 8 DAQmx channels into a single wav file?

Hi everybody,

 

I created a data logger for 8 channels at 500kS/s at 16bit with a PXI-6123-S DAQ card. Right now I'm saving the data of the 8 channels in a single TDMS file.

 

The goal is to log the 8 channels into a single wave file. I used the standard sound file open/write/close VIs and I realized it only works with 2 channels. Once I configure the wav file for more than 2 channels, I cannot open this wav file in MATLAB or in a wav player. However, if I look at the file size, I can see that all 8 channels are in that wav file.

 

I also got the Sound and Vibration Toolkit and tried the SVXMPL_WAV Recorder (DAQmx).vi, but it only accepts one channel.

 

I attached a shrinked version of my Data logger vi.

 

Thank you very much for your comments and suggestions,

Martin

Download All
0 Kudos
Message 1 of 16
(4,157 Views)

Can you provide the wav file you created? When opening in a wav player are coming across any specific errors? Can you specify the overall application that prompts you to saving this to a wav file as suppose to a TDMS?

 

Regards,

Glenn


Regards,
Glenn
0 Kudos
Message 2 of 16
(4,144 Views)
Hi Glenn,

 

first of all: thanks for replying. I was about to become desperated. 🙂

 

Here are two files recorded at 200kHz for 1s:

 

1) a 2 channel file, which is perfectly fine(setting the Sound format for the sound file write open vi to 2 channels)

2) an 8 channel file (setting the Sound format for the sound file write open vi to 8 channels)

 

The last file cannot be read by any wav file viewer like in MATLAB the wavread function says: "Data compression format (Format #65534) is not supported." and in ISHMEAL says "Unknown Sample format".

 

You shoul hear a 1kHz test tone on the first channel in both files; all other channels are silent/noise.

 

The overall application is to log data from TWO 4-channel hydrophone arrays during our next research cruise and it is convient for data analyzing purposes to have all 8 channels in one wav file, i.e. ISHMEAL can that display all 8 channels nicely in one window.

 

Since it works perfectly fine with 2 channels, it should also work with 8 channels . I just don't know what I'm doing wrong.

 

Thanks a lot,

Martin

0 Kudos
Message 3 of 16
(4,123 Views)
Here are the files....
Download All
0 Kudos
Message 4 of 16
(4,082 Views)

Hello Martin,

 

After glancing your vi, I was curious to understand the File I/O code that preceded the while loop. I was able to take one of our continuous read examples and add a Sound File Write Simple to create a multi channel sound file.

 

Audio_File.png

 

 

 

Regards,

 

Glenn


Regards,
Glenn
0 Kudos
Message 5 of 16
(3,985 Views)

Hello Glenn,

 

sure will the Sound File Write (Simple)  VI create a multi channel wav file as I mentioned in my first posting. But you cannot open this file in a multi channel sound program, i.e. Matlab wavread function, ISHMEAL, etc. Try to open the multi channel wav file in MATLAB and you will see the error message. You can play it in windows media player though. However, I need to see each channel seperately.

 

I also realized this wav file has a bigger header than the standard 36byte wav file header. MAybe there is something wrong in the header with LV multi channel wav files?

 

Thanks,

Martin

0 Kudos
Message 6 of 16
(3,966 Views)

Hi Martin,

 

I'm not sure how MATLAB or ISHMEAL opens the files. I'm curious to understand the formatting for these multichannel .wav files. It sounds like you have single file that has each channel parsed. Can you explain how you are doing that in the initial code you attached?

 

Glenn


Regards,
Glenn
0 Kudos
Message 7 of 16
(3,852 Views)

Martin,

 

Did you find the answer to this?  A customer of mine has the same question and I'm not sure what is the difference between the WAV file that LabVIEW saves and the WAV file the ISHMAEL (or Raven in this case) uses...

 

Did you find more info on what ISHMAEL requires?

 

Thanks,

 

Vincent 

Vincent Carpentier, Ing./Eng.
CLA
Neosoft Technologies
www.neosoft.ca
DQMH Trusted Advisor
0 Kudos
Message 8 of 16
(3,418 Views)

Vincent Carpentier wrote:

Martin,

 

Did you find the answer to this?  A customer of mine has the same question and I'm not sure what is the difference between the WAV file that LabVIEW saves and the WAV file the ISHMAEL (or Raven in this case) uses...

 

Did you find more info on what ISHMAEL requires?

 

Thanks,

 

Vincent 


A fix can be to check the two bytes at index 20 in the wav file. If this two bytes read 0xFEFF replace with 0x0100. Just write in the two bytes 0x0100 at index 20. You may use labview or a hex editor. I leave it to you to tell your customer the difference between  ASCII and hexadecimal number format. For more info read this

http://forums.ni.com/ni/board/message?board.id=170&message.id=415946



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 9 of 16
(3,402 Views)
Thanks for the info Coq Rouge!
 
I did change these 2 Bytes but it is not enough.  After more research, it seems that LabVIEW saves the wav file in the new WAVE_FORMAT_EXTENSIBLE from MS while the ISHMAEL software only supports PCM, u-Law and Float Wav file....
 
I've also check this Web sites that explains the old WAV binary header format: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
 
The other issue that I see is the Subchunk1Size field that should be 16 (16 bytes) for the PCM format (0x 10 00 00 00), the one created by LabVIEWhas 40 (for 40 bytes) because of the WAVE_FORMAT_EXTENSIBLE header....
 
So, I've changed the Subchunk1Size field (little-endian) to hex: 01 00 (Decimal: 16) to replace hex: 28 00 (decimal 40)  and I've also changed the Audio Format  field to hex: 01 00 like you mentioned instead of the FE FF...
 
And then I deleted the extra bytes in the header to be consistent with the Subchunk1Size field and updated the ChunkSize field (D4 71 0B 00 = 750 036 Bytes).

The recording is 5 channels at 50kHz with 24-bit for 1 second.

I'm still not able to read the file in ISHMAEL.  It recognize the header but when it reads the data, it says:

error.JPG 
 
The original audio file created by LV is in attachment (renamve extension to .wav, the forum doesn't allow a wav file to be in attachment). And this is the VI I made to  modify the header and create a new wave file:
wavmodification.png 
 
I've event looked at the old Sound VIs  but it seems it cannot save in 24 bits without doing some modifications
 
 Any idea?
 
Thanks, 
 
Vincent 
Vincent Carpentier, Ing./Eng.
CLA
Neosoft Technologies
www.neosoft.ca
DQMH Trusted Advisor
0 Kudos
Message 10 of 16
(3,349 Views)