[chuck-users] Sound glitches at the start of descending tones

Forrest Cahoon forrest.cahoon at gmail.com
Wed Jun 20 00:22:19 EDT 2018


I'm attempting to play with descending tones, but I'm having artifacts at
the beginning of the sound. I tried to start with a gain of 0 but this does
not prevent the glitch.

I've used various sorts of oscillators; when I use SinOsc there is just a
glitch at the very beginning of the sound, but with SqrOsc and others there
is what sounds sort of like LFO amplitude modulation for maybe even a
second into the sound.

Here is my code. How do I fix this?

SqrOsc r => dac;  // also try SinOsc, TriOsc, and SawOsc

300.0 => float STARTING_FREQ;
10000 => int OCTAVE_STEPS;
for (0 => int i; i < OCTAVE_STEPS ; i++) {

    // making an envelope by manipulating the gain
    if (i < 100) {
        i * 0.005 => r.gain;
    } else if (i > OCTAVE_STEPS - 100) {
        (OCTAVE_STEPS - i) * 0.005 => r.gain;
    } else {
        0.5 => r.gain;
    }

    // constantly falling frequency
    if (i == 0) {
        STARTING_FREQ => r.freq;
    } else {
        STARTING_FREQ *
        Math.pow(2.0, -1.0 * Math.log2((1.0*i)/(1.0*OCTAVE_STEPS))) =>
r.freq;
    }
    1::ms => now;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20180619/0ea6474a/attachment.html>


More information about the chuck-users mailing list