LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous audio output and input

Hi,

 

I'm trying to do a continuous audio generator and analyzer. I'm using an USB sound card. It currently working but I'm not really satisfied with the overall reactivity of the VI.

 

The buffer size used for audio vi is set to be one second of audio signal (44100 samples as my sampling rate is 44100 S/s). The result of this is that the running loop takes 1 second to be executed and when changing any parameter (frequency or amplitude) it takes one second to change.

 

I've tried to reduce the buffer size but I start to have some breaks in audio signal.

 

Is it possible to optimize it ?

 

Thanks

0 Kudos
Message 1 of 5
(10,487 Views)

Hi Alexandre,

 

in the NI-Example Finder there is a good sound generation VI called Generate Sound.vi. For the number of samples for the sound output configure.vi the example has choosen 5000. So far i see that's the mayor difference. Anyway when you change the frequency or amplitude there is no 1-sec-delay. Take a look at the Generate Sound.vi in the Example Finder (Hardware Input Output>Sound) and let me know if it works!

 

Thanks,

cheggers

Sascha
0 Kudos
Message 2 of 5
(10,452 Views)

Try this

Message Edited by t06afre on 03-25-2009 05:40 PM


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 3 of 5
(10,443 Views)

Using the NI Generate Sound.vi example, I'm able to generate continuous sound without any problem.

 

However, if I try to read input while generating sound, I start to have those audio breaks...

 

I'm using same sample numbers for audio output and for audio input. Is that right ?

0 Kudos
Message 4 of 5
(10,423 Views)

Hi

This worked for me (see attached picture). But I am sitting on a desktop using a internal PCI sound card. Also have in mind that the value used in "number of samples/ch" (Sound Output Configure VI) specifies the buffer size used then values are written to the sound card with the "Sound Output Write VI" So in your case then you select the 44100 as sample rate and buffer size, and only write 22050 samples with the "Sound Output Write VI" you will get .5 seconds with the sound of silence. But I also think NI could have done a better job then they wrote the new sound out function in Labview 8.x. The functionality was downgraded from version 7.1. In 7.1 you could specify a number of output buffers used in sound output, This ensured a continuous audio output, but with some latency. I think NI did not like the thought of a inexpensive sound card used as an analog output device. So they crippled the functionality. But this fear is unfounded, because a sound card as a analog output device may be great for the hobbyist. But not for commercial applications. The output level of a sound card is not very accurate, unless calibrated. And the output level is also in many cases to low.

As I mentioned before the sound system used in Labview 7.1 was better regarding sound output. But the good thing is that you still have access to it in Labview 8.x via the sound.llb and sound.dll (...\National Instruments\LabVIEW 8.6\vi.lib\sound). You will find an example here http://zone.ni.com/devzone/cda/epd/p/id/1615. You could also try this API for sound. I have not tested it. http://zeitnitz.de/Christian/WaveIO/waveio.html 

 

Message Edited by t06afre on 03-26-2009 04:01 PM


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 5 of 5
(10,398 Views)