09-08-2011 03:38 PM
I am trying to save a waveform that was recorded by a DAQmx device into a .wav file. I have found two sample vi's that I used to start with.
Sound Input to File.vi
This vi saves the waveforms from a microphone input to a .wav file. The nice thing about this vi is it has no limit on how long you can record.
SVXMPL_WAV Record (DAQmx).vi
The vi saves the waveforms from the DAQmx input to a .wav file. The nice thing about this vi is it shows how to get the waveform through the DAQmx device, but you can only record for just over 1 minute.
DAQmx Input to File.vi
This was my attempt at combining the best things of the above vi's, but it doesn't work and I don't know why. I'm hoping somebody can tell me where I went wrong and/or how to improve my vi.
Solved! Go to Solution.
09-09-2011 02:34 PM
When you try to acquire more than a few minutes of data are you getting an error message that states the requested memory could not be allocated?
This error appears because the program tries to all acquire data in a single DAQmx read call (1 channel N sample). You will need to instead, modify the program such that you call DAQmx read multiple times so you can use a smaller buffer size. The best way to change this would be to implement a producer/consumer loop where the producer queues all the samples and the consumer dequeues them and feeds them to the Sound Write Waveform VI.
Application Design Patterns: Producer/Consumer
09-09-2011 02:55 PM
The error message that I am getting is similar, but not quite an out of memory error:
Error -50005 occurred at DAQmx Input to File.vi
NI Platform Services: The specified data width is not supported or cannot be transferred on the bus. The operation could not be completed as specified.
Task Name: _unnamedTask<0>
This error message happens right after the program tries to execute the DAQmx Read (Analog Wfm 1Chan NSamp).vi.
Would your solution solve this problem as well?
09-12-2011 12:52 PM
From your original post it sounds like creating a producer/consumer loop will help you. What is the acquisition duration you are using? Do you receive this message when using a smaller value like 1 second?
09-12-2011 01:56 PM - edited 09-12-2011 02:01 PM
This happens the very first time the DAQmx Read (Analog Wfm 1Chan NSamp).vi tries to execute. It doesn't matter what sample duration I try to use.
09-12-2011 06:26 PM
What device are you using to acquire data? It looked like you were using a myDAQ in one of the VIs, is this correct?
I have acquired data with a myDAQ here and it works fine. Check your settings against mine
09-13-2011 07:47 AM - edited 09-13-2011 07:48 AM
Thank you for showing me that the SVXMPL_WAV Recorder (DAQmx).vi works fine. I can run that vi with the myDAQ device as well and it works with pretty much any values that I want to put in it.
The problem is with the DAQmx Input to File.vi that I wrote. The vi is included in my first post.
09-13-2011 10:39 AM
It looks like you have a numeric constant of 2147483647 going to the samples per channel VI, what are you trying to do with this constant?
09-13-2011 10:57 AM
If you remove the numeric constant, and adjust your max and min values to +/-1 volts your VI seems to work correctly. The +/-1 volt limitation is defined in the detailed help of the sound file write VI.
09-14-2011 08:21 AM
Yes that works and seems to solve the problem. Thank you. I did have to connect the Number of Samples/ch input to the Sample Clock instead of the numeric constant that I had in order to prevent a different error message.
I can see that the producer/consumer solution would be more elegant than my method, however I have attached my solution in case anyone else ever wants to look at it.