Quick sound synthesis without physical modeling in PD

From CCRMA Wiki
Jump to: navigation, search

This is a quick tutorial on how to make some pleasant but complex sounding tones for use with either impulses or audio rate signals. Impulses are obviously the most simple of the options, and are still great to use for testing the patch, however if you simply want to use a tone as a signal to signify something in a patch or program, the impulse works well. This method works particularly well for unconventional setups, like using a sensor for audio rate input. This works well with that have a high signal voltage with a quick drop off, like a piezo, or even with sensors that have a relatively constant voltage ouput, such as an IR or hall-effect sensor.

But Why?

For most applications using sensor, the standard sonification method is to design some sort of physical modeling (be it string modeling, wind instrument modeling, etc) to create the sound, using the sensor output only to deal with the envelope of the signal or the attack velocity. In that method, the decay, feedback, depth of tonality, etc all to be neatly designed, programmed and routed, which in Pd is no small feat. Along with that, however, our sense of expectation of sound may lead to disappointment if the sound isn't doing what you'd hoped...even if it sounds good! It can be an extremely difficult and time intensive process, which sometimes is worth it, but sometimes, just isn't necessary if it isn't part of the design concept.

The goal for this patch is to create a complex, pleasing tone that has natural sounding attack and decay without having to deal with feedback, delay lines, or any other complex process.

Thus, for time when you are more concerned about the physical interaction of whatever you have designed, but still want it to sound delightful, this method is quick and dirty, and can sound as pleasant or as raunchy as you'd like.

Basic Concept

A simple and computationally-light way to produce a delightful tone with natural attack AND decay is to take your input signal (be it from an impulse, such as PD's click~ object, or from the sensor input) and filter it. Any wide-band filter works to come extent- PD's bpf~, vpf~ and moog~ all work out quite well. A combination of high and low pass filters would also work, but it is much more tricky to set the parameters to make it sound pleasing.

Although I in general am a fan of the PD's in-house attempt at modeling Moog's ladder filter, it has a few problems for this use. First, it's computationally much more expensive, so utilized the way we plan to here it can bog the system down. Secondly, we are trying to avoid physical models, and while the ladder filter model isn't a physical model, it's got some more background complexity that feels a bit unfair to use. So for this implementation we'll stick with the a good old band-pass filter, the bpf~.

The trick here is slightly non-intuitive- normally, when given a frequency-rich signal, you try to keep as much of it as possible to make the sound rich and fulfilling. As it turns out, though, using that method in PD make the sound too muddy, and you don't get a natural decay sound. So instead, we will make the most of the bpf~'s Q parameter, and set the resonance at the band-pass's center frequency extremely, extremely high. When you first hear the numbers, it sounds crazy, but the end result is a very strongly pitched bell-like tone. The higher the value of Q, the sharper the attack and the longer the decay, which gives the sound a delightful sense of realism.

For most applications, values for Q might range between 1 and 5, and in more extreme cases could be up to 20. However, on paper, a Q of 20 should produce an extraordinary resonance that is highly directional and uncomfortable. But in this application, the higher Q just helps to sharpen the pitched quality of the impulse or input, sort of like a cymbal. While there are other frequencies going on underneath it, you primarily hear the band-pass' center frequency.

Thus, when used in this application, the value of Q will be between 75 and 1600 (!). If a single band-pass filter were being used, a Q of 1200-1600 seems to work best.

A simplified version of the signal flow is shown below:

(To be replaced with picture)

           adc/impulse -> bpf~ with center frequency X and Q y -> dac

With a high Q, this will already sound quite pleasant. However, the best implementation is to use a bank of band-pass filters, all run in parallel, with different center frequencies, such that when recombined the sound is much more harmonically dense.

Example:

(To be replaced with pictures)

           adc/impulse -> bpf~, X1, Y1 -> dac
                       -> bpf~, X2, Y1 -> dac
                       -> bpf~, X3, Y1 -> dac

etc.

Generally speaking, a complex tone sounds best with 4-10 filters in parallel. It is not computationally expensive and thus shouldn't cause any problems when using audio rate signals.

The Next Step

Say you've found that this method work well for you, but you want to really refine the sound for a finished product. There are a number of steps you can take.

Vary the output gain for each band-pass.

If you want it to emulate a signal with many overtones, varying the output gain in some fashion is a quick way. Pick a fundamental (or whichever frequency you would like to emphasis), and leave it alone. Then for all the other filters, use the *~ object to turn down the rest of the filters so that they are used more to color the unity-gain tone than to stand alongside it. You can make it as complex or as simple as you'd like, but quite often simple works well.

If you had four filters, for example, each one could be successively 25% less than the unity gain filter- 0.75, 0.50, 0.25, etc.

Vary the Q's for each band-pass.

Another simple method for tuning the sound is to change the Q's of each bandpass. It can be as simple or as complex as you'd like, just like the gain. Also similiar to gain is that the filter with the highest Q will become the dominate tone (assuming unity gains; it is not clear where the trade-off between gain and Q is in this application).

I like to use about 8-10 filters per sound for a really rich tone, and I tend to use Q's between about 1600 for the fundamental down to about 75 for the last filter. The Q's might decay like 1600, 1400, 1200, 1000...250, 150, 75, for example. But you may tune them how you like. The filters with the higher Q will also take longer to decay, further reinforcing the particular frequency you want to be the strongest.

Producing subtly richer noises

The standard method to choosing center-frequencies of the filters in your filter bank is to use the normal harmonic overtone progressions, of 2/3/4/5/6/7x or 3/5/7/9/11x the fundamental, etc. However, if you want it to sound a little more rich and realistic, it actually helps to stretch and compress the distances between each center frequency slightly. So instead of picking 100Hz/200Hz/300Hz/400Hz/etc, it actually produces more depth to do, say, 100Hz/199.6HZ/301HZ/400.3HZ. Small variation is key- it doesn't take much to go from a complex piano-like overtone sound to sounding largely inharmonic like a bell.

A little bit goes a long way. It does help enormously in removing some of the synthetic quality of the sound, however.

Producing bell-like noises

So, what if you want it to sound like a bell? Well, you could just pick a bunch of wacky numbers for the center frequencies, like 100Hz/231.9HZ/384.2Hz/419.7Hz, etc. This will produce the desired out-of-tune but really interesting tone you desire.

A more fun way, though, is to make it a bit more mathematically deterministic. One way I found that worked well was to take starting/fundamental frequency, and multiply it by some number taken to the root of the number of filters in the bank minus one. Then each successive filter will have a higher and higher frequency, but there will be more content around the fundamental tone due to the exponential nature of the numbers.

Example, center frequencies using a multiplier of 6 with 10 filter in the bank for a very dense tone:

  • Filter one: 440 Hz
  • Filter two: 440 * (6)^(1/9) = 536.9 Hz
  • Filter three: 440 * (6)^(2/9) = 655.2 Hz
  • Filter four: 440 * (6)^(3/9) = 799.5 Hz
  • Filter five: 440 * (6)^(4/9) = 975.7 Hz
  • Filter six: 440 Hz * (6)^(5/9) = 1190.6 Hz
  • Filter seven: 440 * (6)^(6/9) = 1452.8 Hz
  • Filter eight: 440 * (6)^(7/9) = 1772.8 Hz
  • Filter nine: 440 * (6)^(8/9) = 2163.4 Hz
  • Filter ten: 440 * (6)^(9/9) = 2640 Hz


Example, center frequencies using a multiplier of 17 with 8 filters in the bank for a very open sound:

  • Filter one: 440 Hz
  • Filter two: 440 * (17)^(1/7) = 659.5 Hz
  • Filter three: 440 * (17)^(2/7) = 988.6 Hz
  • Filter four: 440 * (17)^(3/7) = 1481.8 Hz
  • Filter five: 440 * (17)^(4/7) = 2221.1 Hz
  • Filter six: 440 * (17)^(5/7) = 3329.2 Hz
  • Filter seven: 440 * (17)^(6/7) = 4990.3
  • Filter eight:440 * (17)^(7/7) = 7480.0 Hz


Both of these will sound drastically different, but give you a lot of room to create some great sounds that, if you remember the math, you can reproduce again in the future.

Input filtering?

If you are using a audio-rate input signal some a transducer, like a piezo, it may be necessary to filter the high frequencies out of the signal to avoid excessive noise. Piezos are particularly susceptible to this because any tiny touch or breeze will produce some small chime bleed-through. In that instance, you might be best served to run a low-pass filter (such as PD's lop~ object) before the filter bank. A cut-off value between 6.5k to 10k works well, but experiment with it.

Try to avoid setting the cut-off too low, as it will negatively affect the sound. The lower the cut-off, the more mellow and dull the tone will sound, as you are effectively cutting out the highs (the brightness/brilliance of the sound).

If possible, I try to avoid the use of the low-pass altogether, however sometimes it isn't feasible to go without it.

If you do want a more dull, soft sound, this is an effective way to do it.

Then what?

The sky is the limit beyond that. Feedback (from the output of the filter banks back into themselves, other banks, or other inputs, or however you choose to set it up), reverb, delay/echo, phasor/phasing, enveloping, filtering, chorus, whatever you'd like. Any effect, if tuned well, can sound great with this method!

Enjoy!