Kyma Forum
  Kyma Sound Exchange
  PID Controlled Tracking Oscillator

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   PID Controlled Tracking Oscillator
David McClain
Member
posted 27 January 2002 18:54         Edit/Delete Message   Reply w/Quote

log2_66db.aif


voice_mod_fm_drone.kym

 
Here is one that implements a sound much like a person who can't sing very well. It is actually a PID control loop attempting to hone in on the frequency of an oscillator playing at !Pitch from the keyboard. It does so by implementing 3 bandpass filters which track together and which have adjustable Q's.

The trio of filters is arranged so that (approximately) the center filter is flanked on both sides at the half-power point by two other nearly identical filters. That spacing, of course, depends on the filter Q's.

These filters track an oscillator triggered by the keyboard and generating the "true" pitch. When the keyboard is not playing these filters are fed a source of white noise about 30 dB down from the nominal oscillator amplitude. Their Q is determined by how much more energy is coming from the center filter than the average (dB) from the two flanking filters. When this value increases significantly, it means you are likely centered (approximately) on the carrier frequency and hence you can increase your Q and narrow in even better. When the Q increases, it increases in all 3 filters, and so they move closer together as well. The amount that the Q is increased by is controlled by parameter KQ.

The frequency tracking is implemented as a PID control loop (proportional, integral, and derivative), with parameters KP, KI, KIScale, and KD. Also the integrator gain IScale. KP controls the amount by which the final integrator is increased, in direct proportion to the measured error signal (more about that in a minute). KI and KIScale work together to control the amount of integrated error fed to the final integrator. KIScale is chosen to avoid overflowing the KI integrator. KD controls the amount of derivative fed to the final integrator. This derivative is measured by the difference between samples spaced 100 sample intervals apart. Change that and you need to change your KD by a similar factor.

The error signal is derived as the difference of the average dB coming out of the two flanking filters. If the background were perfectly flat, and the filters perfectly symmetric, then this difference ought to be zero when the carrier signal is centered in the middle filter. Alas, reality is somewhat imperfect, made moreso by the use of background noise, so that when this difference is zero, we are not quite in tune with the carrier oscillator. That's what gives this sound its charm.

Finally the output is generated by my HotNuc oscillator driven at the frequency estimated by the PID loop. Throw your own favorite oscillator in here in place of mine.

The sample file contains a curve used by waveshapers to convert squared amplitudes to dB on a scale of -1 = -66 dBFS and 0 = 0 dBFS.

The idea for this Sound came from a story I once heard about a radio system at the US Embassy in Moscow that tracked the MUF (Maximum Usable Frequency) of the ionosphere using a trio of feeler oscillators between Moscow and Washington D.C. Using this trio of signals they could track up and down during the day while the MUF changed. The MUF is the most desirable frequency to use for radio transmissions when you want maximum distance for given power. I heard that this system could communicate between the two cities on merely 25 mW. That's a tiny fraction of the power used by a typical AA cell flashlight!

When I play this Sound with a piano accompaniment, it sounds a bit like a man humming somewhat off key... It reminds of what used to make my dog howl when I was a kid...

Enjoy!

- DM

[This message has been edited by David McClain (edited 27 January 2002).]

IP: Logged

David McClain
Member
posted 29 January 2002 14:53         Edit/Delete Message   Reply w/Quote

voice_mod_fm_drone.kym

 
After looking more closely at the mathematics of PID control loops, one finds that they are expressible as simple FIR filters followed by an integrator.

In general the "physical" solution has zeros in the Z-plane that lie very near the pole of the integrator at DC. It turns out that using the entire Z-plane, at least everywhere in the unit circle, offers considerable advantages for this particular problem. In fact, I find that a simple 3-term integrator does best of all in terms of no overshoot and minimum portamento time.

So the attached sound contains an improvement in this regard. There is no internal integrator to wind up and possibly overflow. No overshoot, depending on the loop gain !Kc.

The filters are still imperfect in the tracking trio, and so I slightly retuned the oscillator by backing off by 1 semitone. The result is still charmingly off key, but not quite as bad as before.

Using better filters improves this situation enormously. By better filter, I mean a BPF explicitly constructed to be a bandpass filter, instead of the difference between a high-pass and a low-pass filter. But until SSC offers such a Sound block, this is left as an exercise to the reader...

- DM

IP: Logged

Bill Meadows
Member
posted 31 January 2002 02:44         Edit/Delete Message   Reply w/Quote
David, your stuff never ceases to amaze me! I don't pretend to understand it much of the time, but I certainly enjoy reading about it.

One of your Sounds uses a "DBMeter" which is evidently of your own construction. When expanded, I found a very interesting prototype called "DSPProgramWithInputs". Can you tell us about this, or did you intend to remove it before posting? (a dB meter would be a useful thing...)

IP: Logged

David McClain
Member
posted 31 January 2002 17:19         Edit/Delete Message   Reply w/Quote

voice_mod_fm_drone.kym

 
Ah well, that was a sound I created a long time ago, and I forgot all about it... It should have been removed. You can achieve the same effect using my Log2(x)/66 sounds for dB conversion and then feed that into a peak or averaging readout.

Sorry,

(maybe someday SSC will come out with a DSP programming kit?)

- DM

[ Hmmm... I just checked my copies and I don't have such a sound in them. But the attached Sound file now includes a prototype and a class for a peak reading dB meter. The only dB meter I could find in this collection uses exactly this same one... ??? ]

[This message has been edited by David McClain (edited 31 January 2002).]

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply

Contact Us | Symbolic Sound Home

This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.


Ultimate Bulletin Board 5.45c