10-02-2009 01:40 PM
Hi there, I am trying to use Producer/Consumer pattern to record sound and play back with loudspearker.
I have data acquisition in the producer loop, and play sound in the consumer loop.
As I want it be real time (dont want too much delay from record time to playback time), so I set it as just take 0.1 second sound in the loop, and then play it back.
Now the problem is: when I run the program, there s a significant gap sound, like "ta...ta...ta..." every 0.1 second. Is there a way to solve the problem?
Attached is my VI, I replaced the data acquisition by a sine wave, thus you can run my VI without a microphone.
10-05-2009 11:44 AM
Hey Linda,
Is there any specific reason on why you are using producer consumer architecture. I tried changing your code a bit it seems to be working fine. Have a look at it. Hope this works for you.
Cheers
lab
10-05-2009 11:50 AM
hi, lab_boy,
Thank you for your reply, I use the producer consumer architecture because I want to add some signal processing later and that might cost some time.
I tried your modified VI, there is still some noise there. Is there a way make it play as smooth as playing a long waveform, (eg, 5 second) w/o loop?
Thanks again
10-06-2009 02:26 PM
Hi linda_zhuna,
May I ask why will constantly generating/acquiring data not work? You mentioned you take only .1 second intervals because you want the data to be close to real time as possible. However, Producer/Consumer design pattern writes the data to the queue in the producer loop, while the consumer loop polls the dequeue waiting for data. As soon as there is data available then the consumer loop executes its process. The queues are similar to a buffer and the first data into the queue is the first data out. You are hearing a break every .1 seconds because the data is being generated again from the very beginning rather than picking up where it left off. What happens when you set the duration to 5 seconds rather than .1 seconds?
10-06-2009 02:33 PM
Hi, h_baker
Thanks for your reply:)
I use the sine wave here just for simple. In my real application, I will use microphones for sound acquisition of real time sound.
So if I use 5 seconds instead of 0.1 second, then when I hear it, it will be 5 seconds delay... Thats why I set it as 0.1 second, thus I will not feel the delays if its only .1s.
10-07-2009 05:04 PM
10-07-2009 07:24 PM
Hi, I think I didn't explain my VI well. The sine waveform generator and the waveform subset vi are both used as simulation. In my real program, that part will be replaced by data acquisition with microphones.
The only reason I use the sine and waveform subset here is because I am afraid not everyboday on the forums has a microphone to play with my program!
Again, as I mentioned before, what I want is a real time playback, which means I want to collect data every 0.1 seconds, and at the same time play back, this is my idea to keep it "REAL TIME", although there is 0.1 second delay at the beginning.
If it is set as 1 second, of course there will be no gap noise, but that is not what I want, because there will be 1 second delay, thats too long for me.
Is there anybody can help me?
10-12-2009 02:42 PM
10-12-2009 03:13 PM
As I said, the sine generator and the waveform subset are all my simulation part.
Well, please ignor them and see this VI, question2.vi.
Here I deleted all the sine part but use my data acquisition as the input. It get a 0.1 second long waveform every 0.1 second from the microphone, and at the same time playing it back using the loudspeaker. If you run it, u will found there s significant noise.
I hope this time you could understand my problem, thanks:)
10-12-2009 03:13 PM