chuck icon indicating copy to clipboard operation
chuck copied to clipboard

interruption/stutter in audio

Open George3d6 opened this issue 3 years ago • 1 comments

I have the following piece of code, built for the purposes of following along with the chuck docs:

1.ck

fun void harmonize(float fq) {
    SinOsc s => dac;
    fq => s.freq;
    122 => float fq1;

    [ 1, 2, 3, 4] @=> int octaves[];

    for(0 => int it; it < octaves.cap(); it++) {
        it == octaves[it] - 1;
        it => float i;
         %(2/(i+1), .2*pi) => polar pol;
        
        SinOsc s5 => dac;
        2/(i+2) => s5.gain;
        pol.phase*1.2 => s5.phase;
        fq * Math.pow(2,i+(5/12)) => s5.freq;

        SinOsc s7 => dac;
        2/(i+2) => s7.gain;
        pol.phase => s7.phase;
        fq * Math.pow(2,i+(7/12)) => s7.freq;

        SinOsc s12 => dac;
        pol.mag => s12.gain;
        fq * Math.pow(2,i+1) => s12.freq;
    }
}

harmonize(40);
#(2,4) => complex bam;
bam $ polar => polar test;
bam.re::second => dur bar;
bam.im::bar => dur measure;

<<< "Start section 1" >>>;
measure => now;

When executing the file as: chuck 1.ck

I sometimes get an interruption in the audio being played, sometimes several, and sometimes it seems continuous. These interruptions are maybe 0.01 to 0.1 seconds in length and would obviously make creating any "real" music close to impossible. They don't seem to be deterministic, they happened randomly and sometimes not at all.

The laptop I am running this on is not the best but I'd expect it to be "good enough" for simple DSP tasks, however, I am running PulseAudio, not jack, so it might be that this is causing the issue.

My question[s] here are:

  1. Is stuttering expected?
  2. Are there ways to get rid of it? (Either when executing chuck live or by generating a file and playing the audio from that)

Version info:

chuck version: 1.4.0.1 (numchucks)
   linux (pulse) : 64-bit
   http://chuck.cs.princeton.edu/
   http://chuck.stanford.edu/

George3d6 avatar May 02 '21 09:05 George3d6

Hi George, since reporting this issue, have you tried increasing the bufsize or the verbosity level when running ChucK from the command line?

Have you tried Jack yet?

benrogmans avatar May 23 '21 09:05 benrogmans