01-26-2015 02:37 PM
01-26-2015 03:10 PM
Hi ajapyy,
It sounds like what you want to do is play back sound as you acquire sound samples from some source. You want to stream the sound. The Play Waveform express VI is not a good choice for this. It expects an array that has all the sound samples in it. It is great if you have a sound created from somewhere, but not so good for the point by point operation you want. Part of the reason is that everytime you call it, it configures the sound device, plays the sound samples you give it, and then closes the sound device.
One obvious option is to collect samples from your source in an array and then pass the entire array to the Play Waveform vi. I am geussing this is not what you want. It sounds like what you want is a continuous playback of sound from your source.
To do a point by point sound output you want Sound Output Write.vi This will require some more setup. You have to call Sound Output Configure to setup your sound device (speaker?). This creates a task ID that you pass to the Sound Output Write.vi. Get the task ID in an initialize step, and in the consumer loop call Sound Output Write.vi with the latest sample from the producer loop.
One thing to note about this. The producer consumer loop with ordinary while loops does not guarantee timing. So the playback of your sound may not be smooth. For your application it may be good enough.
01-26-2015 03:48 PM
If you intend on playing the audio as it comes in you will have problems. What is the sampling rate of the audio beng sent over serial? What is the baud of your serial port? It looks like it defaults to 9600, and it takes 4 bytes to serial data, to get a single point of audio. This means that if there is no time needed to process the serial data, and there is no time in giving that data to the output, then you will get 2400 points of data per second.
According to this wiki article audio sampling rates of 8Khz is only suitable for human speak without sibilance, I imagine 2K is just noise.
http://en.wikipedia.org/wiki/Sampling_(signal_processing)
But even with all of this you must take into account some processing time. You'll also want to buffer it into some kind of queue or array, so your data points are evently spaced appart.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
01-27-2015 02:45 AM
my data is not sound, is another signal. sampling rate is 2K and baudrate is 500000bps which it achieved with using a PL2303 adaptor.
Hooovahh wrote:
But even with all of this you must take into account some processing time. You'll also want to buffer it into some kind of queue or array, so your data points are evently spaced appart.
this is my problem, how I can buffer them to create array ?
I use producer/consumer in my VI.
01-27-2015 02:52 AM
clendon.gibson@canrig.com wrote:
Hi ajapyy,
It sounds like what you want to do is play back sound as you acquire sound samples from some source. You want to stream the sound. The Play Waveform express VI is not a good choice for this. It expects an array that has all the sound samples in it. It is great if you have a sound created from somewhere, but not so good for the point by point operation you want. Part of the reason is that everytime you call it, it configures the sound device, plays the sound samples you give it, and then closes the sound device.
One obvious option is to collect samples from your source in an array and then pass the entire array to the Play Waveform vi. I am geussing this is not what you want. It sounds like what you want is a continuous playback of sound from your source.
To do a point by point sound output you want Sound Output Write.vi This will require some more setup. You have to call Sound Output Configure to setup your sound device (speaker?). This creates a task ID that you pass to the Sound Output Write.vi. Get the task ID in an initialize step, and in the consumer loop call Sound Output Write.vi with the latest sample from the producer loop.
One thing to note about this. The producer consumer loop with ordinary while loops does not guarantee timing. So the playback of your sound may not be smooth. For your application it may be good enough.
if there is no way to play scaller samples, I must collect samples and then play them,. so this method can be good if other ways can not worked.
could you place a snippest from a VI that used Sound Output Write.vi ?
01-27-2015 08:37 AM
@ajapyy wrote:
if there is no way to play scaller samples,
Only if your sample rate is much higher, and your ability to output a value can occur much faster. Maybe with real-time you could do this. A simple solution is to build your samples into an array, then when your array is so large, put the whole array down to be played. Depending on the size of the array you'll probably want to pre-allocate the values and use replace array.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
01-27-2015 11:22 AM
@ajapyy wrote:
my data is not sound, is another signal. sampling rate is 2K and baudrate is 500000bps which it achieved with using a PL2303 adaptor.
Hooovahh wrote:
But even with all of this you must take into account some processing time. You'll also want to buffer it into some kind of queue or array, so your data points are evently spaced appart.
this is my problem, how I can buffer them to create array ?
I use producer/consumer in my VI.
Could you tell us why you want to do this? Maybe if we understood the why, we might be able to come up with a better solution. 🙂