Hi Ivano,
> I'm trying to include a time delay line in a tool dedicated
> to audio in real time built with PortAudio.
> I'm not sure I should have to try with
> Fl::add_timeout. Could someone give some suggestions about that?
> Thank you in advance
How much of a delay do you want to introduce?
I don't think ::add_timeout() is the way to go.
If we are just talking about fairly short delays, e.g. for chorus /
flange effects, or perhaps even quite long delays for echo effects, then
I'd proceed as follows...
- I'd be driving the PA (PortAudio) stream from a large circular buffer.
- Normally, we'd read out of that buffer at just one point (the "head"
of the buffer) and feed that into the PA output.
- To introduce a delay, we instead read out of the buffer at 2 points,
the "head" and some point that was already passed. We then add these two
values together before writing them to the PA output.
- Assuming we are sampling at 44.1kHz (safe guess!) then to introduce a
100ms delay we'd sample from the two positions "head" and "head - 4410"
in the buffer. That should produce a nice "chorus" effect.
- If we assume the buffer has 64K samples, then we are good for any
delay up to about 1.5 seconds, so we can get a nice echo effect by
simply doing the above with a bigger offset.
- For more subtle effects, we can read out from more than 2 points, and
scale each by a small factor before summing them all together. We can
get a nice "room ambience" by reading out from 5 or 6 points, then
summing them like:
(head * 1.0) + (p2 * 0.4) + (p3 * 0.3) + (p4 * 0.2) + (p5 * 0.1)
- If we do the above, but slowly vary the offset from head to the
sub-points P2 to P5, we can get a nice flanging effect. Vary the offsets
more quickly (and by differing amounts) and you can get some nice spacey
phase effects...
- If you can cope with a lower quality, then a lower sampling rate means
a smaller buffer can be used quite safely. The "CD" quality 44.1kHz is
probably higher than is really needed for simple effects processing...
Hope that helps,
--
Ian
SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14
3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk