Re: Glissando: smoothing touch drags
Re: Glissando: smoothing touch drags
- Subject: Re: Glissando: smoothing touch drags
- From: Morgan Packard <email@hidden>
- Date: Tue, 14 Feb 2012 18:52:28 -0500
You can think of this smoothing as a low pass filter on your control signal. If the sound generator can only update the pitch once per buffer, you may still get some audible leaps. In my own framework, I'm able to pass a buffer of frequencies to a tone generator, and frequencies are updated on a per-sample basis.
-Morgan
On Tue, Feb 14, 2012 at 4:51 PM, Jean-François Brouillet
<email@hidden> wrote:
Think of a glissando or portamento effect as the user moves a finger along some key.
At 44.1 K, my 16 bits/mono AU generator kicks in every 43ms or so on an iPad 1. Let's make it 50ms to simplify the discussion, or 20Hz.
As the sound is being produced, the user moves a finger over some key. I keep track of where the touch down started and where the finger is to deliver a number between 0 and 1. This applies to both horizontal and vertical movements, but lets pick one direction.
The AU gen runs in some "AU thread", the touches detection in the main "UI" thread. Let's set aside the thread communication issues right now (I don't use locks, and pray that my ObjC side "atomic" property is seen as atomic too by the C++ side AU thread, but that's a discussion for another topic)
Right now, if I move the finger "slowly" enough, I hear a nice continuous shift of the sound as the finger moves up and down.
But if I move the finger "fast enough", I hear discontinuities, and I guess I understand why. When the finger moves "slowly" over, say 200 pixels/points my [0..1] range is divided into about 20ish steps resulting in
0.00, 0.05, 0.10 ... 0.90, 0.95, 1.00 for my parameter.
When the finger moves "fast enough" the 200 or so pixels are spanned much faster resulting in many less values for my parameter, ie
0.00, 0.25, 0.50, 0.75, 1.00
And at that point I can hear the discontinuity.
What I am thinking of is "smoothing" those values (which will introduce some latency of course) as follows: start an NSTimer to kick in at about twice the rate of the AU callback, and whenever the parameter changes, the NSTimer would have a "time budget" of, say 100ms, to "glide" from the current value to the target value. A bit like CoreAnimation, but for sounds! :-)
My expectation is that this would transform the series
0, 0.25, 0.50, 0.75, 1.0
into, say:
0, 0.12, 0.25, 0.37, 0.50, 0.62, 0.75, ... 0.87, 1.00
Intuitively, I'd run that timer at twice the AU callback rate (Shanon/Nyquist)?
Any experience? Ideas or comments on the validity of that approach?
Many Thanks
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
===============
Morgan Packard
cell: (720) 891-0122
aim: mpackardatwork
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden