logo       

Re: input error(?) on plugin: msg#00196

audio.supercollider.devel

Subject: Re: input error(?) on plugin


On Aug 22, 2004, at 12:04 PM, adam overton wrote:

hello there.

i think i might be going crazy...

so below is a super tiny plugin that just prints out the input samples that it's given to the message window. i'm just giving the Ugen a static input value of 0.0, yet it reports a value of 8.0000000 on the 5th sample and the 17th sample ... for every block...

If the input is a scalar there will be only one value at the input, there will be no 5th sample or 17th sample. You're lucky you didn't just crash.

// A Ctor usually does 3 things.
// 1. set the calculation function.
// 2. initialize the unit generator state variables.
// 3. calculate one sample of output.
void TestInput_Ctor(TestInput* unit)
{

// 1. set the calculation function.
SETCALC(TestInput_next);

You need to have a separate calculation function for whether the input is a buffer (audio rate) or a scalar (control rate, scalar rate).
Look to see how other ugens test the input rates and select a calculation function this. For example:
if (unit->mCalcRate == calc_FullRate && INRATE(0) != calc_FullRate) {
SETCALC(Trig_next_k);
} else {
SETCALC(Trig_next);
}


Or alternately you can implement a checkInputs method in your SC class to disallow scalar inputs if the ugen is audio rate. For example:

checkInputs {
if (rate == 'audio' and: {inputs.at(1).rate != 'audio'}, {
^("phase input is not audio rate: " + inputs.at(1) + inputs.at(1).rate);
});
^nil
}



--
--- james mccartney james-M9HdPQXNfxq9Zq0HfjR8jw@xxxxxxxxxxxxxxxx
<http://www.audiosynth.com>
SuperCollider - a real time audio synthesis programming language


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise