LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real time audio and queues

Hi all,
I have a problem with my project. I need to acquire sound from my soundcard (16 bit, 22050Hz) for later processing. I´m using a queue with consumer-producer structure. The thing is that I need to get a constant flow of 'sample packets' of 20ms length (441 samples) at the consumer loop and now data jerks every 1 second. I've posted a picture of my code. Any help will be welcomed.

 

Thank you!

 

Captura de pantalla 2014-04-05 a la(s) 21.06.58.png

0 Kudos
Message 1 of 6
(1,139 Views)
Hi. I dont have any experience with these vi's but I am guessing the 1ms waits may be the problem. Take them out of both loops. The top loop will then be timed by the sound acquisition and the bottom loop will wait for data at the dequeue function. I suspect the 1ms delays add up and you miss a **bleep** of data each second or so. Try it and see what happens, post back when you do.
Michael
0 Kudos
Message 2 of 6
(1,126 Views)
What! I must have made a typo and the forum thinks I was being rude 😉 never seen that before! I tried to write chunk, im sure that is not an expletive in english...
0 Kudos
Message 3 of 6
(1,124 Views)

OK, as the wait is only 1mS and the sample rate is 20mS and there is no dataflow between the aquire vi and the wait(ms) the wait will not have an affect on the timing.  Unless the sound input dll is somehow blocking, but i doubt that.  If you post the actual VI (in LV2011/12) I will run it and see what happens.  I also suggest you put a tick count (ms) in the top loop and look at the itteration timing, this may help to identify the cause of the glitch.

Michael

0 Kudos
Message 4 of 6
(1,101 Views)

Thank you for your quick answers. I have changed the timer values and now the flow is constant but the retardation in the consumer loop is too long for this real time project. 

 

 

0 Kudos
Message 5 of 6
(1,090 Views)

Ok, so the timer bit has helped.  Its 2am here so i'll keep this quick.  The file write is taking too long. maybe you could try writing the waveform to a binary file, i think that is fastest.  Then write another vi to post-process the binary file to the correct sound file format.  That is a bit more work but cheaper than a RAID array of SSD's Smiley Wink

If this helps please mark as solution/kudos

Thanks!

Michael.

Message 6 of 6
(1,068 Views)