LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

sound acquire

thank you very much. I changed my sound card and now it works
0 Kudos
Message 11 of 13
(1,663 Views)

hello

 

I tried the projects and I would have a couple of questions

what the "handle" does?

I would like to send sound for 20sec max.

how would it be possible to control it through User Interface with 3 buttons?

for example:I press a button and the recording begins, the second button will end the recording, end the third button replays the the recorded sound

for example: Start, Stop and Replay buttons

would be able to help me with this?

 

0 Kudos
Message 12 of 13
(1,412 Views)

Hello Peti,

 

1. Unfortunately, I have used a generic and undescriptive name "handle" to identify the audio device that you are using in your program. "audioDevice" would have been a better choice. You have pass this reference to all the waveIn/Out functions so that the operating system knows which audio device you want to work with.

 

2. My example plays a sound for one second. Either you play this sound 20 times in a for-loop, or you can generate a longer waveform for the entire 20 seconds. In the latter case, you will have to increase the sample buffer sizes and modify the for-loops that generate the signal accordingly.

 

3. If you want to record waveforms of arbitrary length, you have to figure out where to store the data. One option is to malloc a large memory buffer that you will gradually fill up. You can expand the memory buffer with realloc when necessary, but this will become rather slow as the memory buffer grows larger. Another option is to write the audio data to disk with the TDMS library for high-performance streaming of data.

 

Main program: create a memory buffer to hold one second of waveform data

create a suspended async timer with a loop rate of 1 second

(async timers give better accuracy than UI timers)

 

Start button: delete any existing TDMS files with previous recordings (if you want)

open a new TDMS file for recording

  resume the async timer

 

Stop button: suspend the async timer

close the TDMS file

 

Replay button: reopen the TDMS file

read the audio data from the TDMS file in one second increments

send the data to the audio output device for playback as in my example


  Async Callback: retrieve audio input from the audio device as in the example program

append the audio data to a TDMS file

 

You can find more information about TDMS in samples/TDM Streaming/...

 

Best regards,

 

Peter

0 Kudos
Message 13 of 13
(1,370 Views)