LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with a real time audio delay program

I'm trying to make a delay program so that audio inputted from a guitar has an echo/reverb effect in real time. See the attached file to understand better what I mean. It currently does work to a point however it keeps crashing after 5-10 seconds. Would anyone be able to suggest why it does this? I'm guessing its something to do with storing the audio when doing the delay and its causing it to overload and crash.

This may not be the best way of achieving this effect so alternatively if anyone could suggest another method that would do the same thing that would be good.

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

You're overflowing the audio input buffer. Every cycle, Sound Input Read returns 10000 samples (apparently the default, about 450 ms) of audio, but then the combination of the 200 ms wait and Play Waveform2 takes 650 ms to play back the audio. So the next cycle, Sound Input Read returns another 450 ms of audio, leaving about 200 ms unread in the buffer. Each cycle through the buffer gets fuller by another 200 ms, until eventually it overflows. You need to separate the reading and the playing into two separate loops that run in parallel, and pass the data between them using something like a queue or channel wire.

 

edit: I realized my explanation wasn't quite right, so I've rewritten it a bit.

Message 2 of 4
(2,606 Views)

I'm surprised, this "kinda works at all" ... if you look up error 4822, this is due to a timeout

 

I messed a bit around, 

you can "improve" the audio output result by setting the "Sound Input.vi" 's Timeout Parameter from the default 10s to 0,5s

sound-input_read.PNG

 

However, if I was you I would try to understand the "Play Waveform"-Express VI 

RightClick>Open Frontpanel

 

 

There, you will find this note from National Instruments, telling you how to convert an Express Vi to a set of standard .vis (by saving them to a file)

 

This Express Source VI is a
wrapper around the subVI here.

If you are converting a VI to an
Express VI, then this subVI is the
VI you chose. Open it and make
sure it works properly.

If you are creating a new
Express VI, finish these steps:

1. Open the subVI and
complete it first according
to instructions on its panel.

2. Drag the bottom the subVI
to show all the input and
output terminals.

Create controls, indicators, and
constants for each terminal as
needed for the functionality of
this Express Source VI.

 

 

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

Did you solve your problem? I am trying to do guitar delay too.

0 Kudos
Message 4 of 4
(2,227 Views)