LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

wav file to DAQmX write in RT

Hello, I would like to read a wav file from hard disk, and play it using DAQmX Write with the card NI PCI-4461.I work on a Desktop RT machine with the LabVIEW Real Time Module, so I can't use the Sound File Read Vi of LabVIEW.Do someone can help me to develop a VI that can transform a .wav file into voltages values compatibles with the NI PCI-4461 ? Thanks in advance.

 

Matthias Baudot 


Matthias Baudot | Software Architect | Founder & Owner at STUDIO BODs | DQMH® Consortium Board Member & Trusted Advisor

STUDIO BODs     LabVIEW Champion     Certified Professional Instructor     DQMH Trusted Advisor     DQMH Consortium Board Member     GCentral Sponsor

 Check out my LabVIEW presentations and videos!

0 Kudos
Message 1 of 3
(3,740 Views)

Hello Matthias,

 

There are a few ways that you could do this.

 

1.  Use the WAV file to Waveform VI to open the WAV files on your RT system

 

2.  On your Windows system use the Sound File Read VI to open your WAV file and then save this file to the TDMS file format.  Then you can use the TDM Streaming VIs on your RT system to open the TDMS file and write it to your analog output.

 

I have personally done this using both methods and if you're going to be opening larger WAV files or using this extensively I would highly recommend using option two.  I used to have a VI that converted WAV files to TDMS files, but I can't find it at the moment.  I will look around for my VI more tomorrow, but if this issue is urgent I would recommend that you go ahead and start developing your own solution because even if I find my VI it may not meet your exact needs.

 

Here are a couple of articles that give more details on TDMS files:

VI-Based API for Writing TDMS Files

Introduction to LabVIEW TDM Streaming VIs

 

I hope this helps, and I'll post back if I'm able to find my VI.

 

Cheers,

Message Edited by Brooks_C on 09-25-2008 05:08 PM
Brooks
0 Kudos
Message 2 of 3
(3,715 Views)

Hello Matthias,

 

I found the VI I used before and I've attached it to this post.  I cleaned it up some and made sure all the labels are relevant, but please keep in mind that it wasn't initially intended to be used my anyone but myself.  The purpose of this VI is to take a multi channel WAV file and convert it to multiple channels in the same group of a TDMS file.  My VI basically opens the WAV file, reads out a chunk of samples, and then writes them a chunk at a time to the TDMS file.  With large WAV files you have to read and write in chunks to avoid overflowing your systems memory.  The larger the number of samples you read the faster the overall conversion to TDMS will be, but you may run into a Memory is full error if you try to open a 3 minute WAV file all at once.  As a guideline, I found that reading 1000000 samples/channel on two channels offers a reasonable trade off between speed and memory usage for a WAV file that is several minutes long.

 

During the conversion process you will notice that the progress bar slows down as you get farther into the file.  This is a consequence of the ascii file format and the serial file reads from the WAV file.  A major benefit of converting to a TDMS file is the binary file format--once you convert the waveform to TDMS you will be able to access any point in the song very quickly.

 

I hope this helps get you started and have a great day!

 

Cheers,

Message Edited by Brooks_C on 09-30-2008 02:30 PM
Brooks
0 Kudos
Message 3 of 3
(3,686 Views)