A Little Chuck Script for a Pluck Sound

Chuck is a concurrent and strongly timing based audio programming language for real-time synthesis, composition, and performance. Chuck runs on Linux, Mac OS X, Microsoft Windows, and iOS. It is designed to favor readability and flexibility for the program over other considerations such as raw performance. https://en.wikipedia.org/wiki/ChucK

If you are not familiar with Chuck, below is a tutorial for ChucK beginners :

It is a lightweight programming language, aiming for audio programming and sound synthesis.

Today, I am going to explain a little ChucK script for generating a pluck sound. The script has been downloaded from https://chuck.cs.princeton.edu/doc/examples/deep/plu.ck

THE ACTUAL ChucK SCRIPT.

// karplus + strong plucked string filter
// Ge Wang ([email protected])

// feedforward
Noise imp => OneZero lowpass => dac;
// feedback
lowpass => Delay delay => lowpass;

// our radius
.99999 => float R;
// our delay order
500 => float L;
// set delay
L::samp => delay.delay;
// set dissipation factor
Math.pow( R, L ) => delay.gain;
// place zero
-1 => lowpass.zero;

// fire excitation
1 => imp.gain;
// for one delay round trip
L::samp => now;
// cease fire
0 => imp.gain;

// advance time
(Math.log(.0001) / Math.log(R))::samp => now;

 

EXPLANATION

  • Under “feedforward”, a Noise object is being created. Noise is a standard ChucK Unit Generator Class. A Noise object will be used to produce white noise. OneZero is a protected Filter subclass implementation of one-zero digital filter. “lowpass” is the object which has been created which is then attached to the “dac”. “dac” is the abstraction of the underlying audio output device.
  • “lowpass” is now a Noise object which will produce a white noise with a one-zero filter enveloped on it through the audio output unit of your device.
  • Under “feedback”, a feedback chain is being created on the “lowpass” object implementing a Delay Class object called “delay”. The “delay” object is getting its input from the “lowpass” object and the output of the “delay” object is then being fed back into the “lowpass” object to create a delay effect on the generated audio.
  • Now we are setting some delay parameters. Under “our radius”, we are creating a floating point variable “R” and are assigning it a value of “0.99999” and “our delay order”,  we are creating a floating point variable “L” and are assigning it a value of “500”.
  • Under “set delay”, we are setting the delay order for each sample (L::samp => delay.delay), as the delay length for the “delay” object (delay.delay). Doing this we are setting the delay length for the delay object for each sample of the audio generated.
  • Under “setting dissipation factor”, we are setting the delay gain (delay.gain), the gain parameter for the “delay” object as R to its L’th power. This will decrease the delay gain as time passes and the delay effect will dissipate over time as the value touches zero.
  • Under “place zero”, we are setting the zero position to the “lowpass” object (lowpass.zero).
  • Then we are firing the excitation, by setting the gain of the Noise Class object “imp” to 1.
  • Then we run the noise unit generator by advancing the time by each sample and then we stop the fire by setting the gain value of the noise object “imp” to 0. This will let only one sample of the noise to generate.
  • Then we advance the time by each sample to let the delay work its way down to when it completely diminishes.
  • When we run this script, it generates a pluck noise which we can hear. The Sound slowly fades away and the delay effect which has been put on the generated noise is what actually is making it feel like a tail to the one sample of the noise we generated.
  • If we remove the delay part from this script, we will only be able to listen to a single sample of noise, which we actually would not be able to hear. Chuck is a very interesting programming language for those who have an interest in sound and audio. You should check it out once.

Don’t forget to share your views in comments below what you think. Feel free to comment and share. Thanks for reading. Stay connected for more post like this coming.

krizillox_krizi

music is love bass love its all about the bass