LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Variable sampling rate in lvsound2.dll

Folks,

 

I am using labview sound output VI's to develop a audio over ethernet application.

 

In my app i have a variable sampling rate requirement without closing and reopening the sound VI.

currently what i see is only way to set sample rate is in the Sound output Configure VI.

 

any ideas?

 

 

Thank you,

Shridhar

0 Kudos
Message 1 of 4
(2,594 Views)

Your correct, the only place to set the sample rate for the sound is the "Sound Output Configure.vi"  and it cannot change while the task is running.  You would have to use the "Sound Output Clear.vi" to stop the task, and then use another "Sound Output Configure.vi" and set it up with a different sample rate.  This is more a limitation on the library.

 

What are you trying to accomplish with a variable sample rate?

Systems Engineer
SISU
0 Kudos
Message 2 of 4
(2,585 Views)

Hi Nathan,

Here is brief explaination of the application.

8khz sampled data arrives on the ethernet packet (512 bytes) at every 63msec and scaled and  sent to the  soundcard using producer consumer architechure with  queues(FIFO).

 

eventhough consumer loop  runs at same rate as 63msec due to SOWrtie in lvsound2.dll sometimes the loop rate varies with processes and PC.

resulting in the FIFO bulding up. as time goes by the FIFO build up is larger and larger.

 

To avoid this  i was experimenting with different sample rate (8khz+-200Hz), what i noticed is queue build up increases or decreases depending on lower sample rate or higher sample rate respectively.

 

what i am trying to achieve is using a variable rate of sampling to avoid overrun or underrun of the queues.

 

if there is any elegant solution to this i would really appreciate

 

Thank you,

Shridhar

 

0 Kudos
Message 3 of 4
(2,579 Views)

You can run your consumer loop at a faster rate, then when the buffer gets larger due to system processes, when you get control back you can just write what you got to the sound output.  Then to prevent buffer underrun you would not write data when the buffer size is smaller than X.  

 

Are you using timed loops? What timing are you using to ensure the consumer is running at the same rate as the data being produced?

Systems Engineer
SISU
0 Kudos
Message 4 of 4
(2,569 Views)