[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] Re: Quickly repeated message



I forgot the main question. What I can do to fix this?


2013/10/30 Lucas Samaruga <samarugalucas@xxxxxxxxx>
Hi

(I don't know if to post this here, maybe something is wrong with the synth.release message?).

There is something wrong either with my code or the server messages. The variables are the jackd buffer size and the complexity of the draw function. When one of these increases there are synths that last active in silence in the server. This happens only when using the .release method not with .free.

The gui just fires a synth on key down and releases it on key up. The gui and sclang does what I want but the server fills up of silent synths after a while of holding down a key (key press repeat when key is held down).

A simplified version:

// p = 2048!
"jackd -d alsa -d hw:1,3 -r 44100 -p 2048 -n 3".unixCmd;
s.reboot;

(
w = Window.new("keytest");
x = nil;

w.view.keyDownAction = {
    if(x.isNil, {
        "new".postln;
        x = Synth(\default);
        w.refresh;
    });
};

w.view.keyUpAction = {
    if(x.notNil, {
        "release".postln;
        x.release; // some nodes last in silence
        //x.free; // ok inmediate
        x = nil;
        w.refresh;
    });
};

w.drawFunc = { arg view;
    var width = view.bounds.width;
    var height = view.bounds.height;

    if(x.isNil, {
        Pen.color = Color.gray;
    }, {
        Pen.color = Color.red;
    });

    Pen.fillRect(
        Rect(
            10, 10,
            width - 20, height - 20
        )
    );
};

w.front;
)

Best
Lucas




--
"freedom does not come from doing what one likes, but from mastering the rules. Doing what one likes is too close to indifference.” Erhard Karkoschka