09-05-2012 09:56 AM
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
09-06-2012 08:55 AM
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?
09-06-2012 09:27 AM
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
09-07-2012 01:03 PM
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?