[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] Dust variant
Hello All,
I have a what I think of as a Dust variant and am wondering if:
a) this UGen exists already,
b) it is possible to write using existing UGens, or
c) failing that what the rules are for suggesting UGens
I mention c) because I am trying to rewrite a semi-complicated UGen as
a UGen graph and am wanting to use only 'standard' UGens.
DustR(lo,hi) generates triggers where the inter-offset times are
generated randomly in the specified range (seconds) with linear
distribution.
It is trivial but I can't see how to do this using existing UGens
(TRand & Impulse look likely but require a cycle) and it has quite
different properties to Dust (perhaps it is misnamed, R is for range,
though it pronounces well, B is for bound?).
For instance, compare:
Dust.ar(1)
DustR.ar(0,2)
Impulse.ar(1,0)*WhiteNoise.ar
DustR.ar(1,1)
Dust.ar(0.025.reciprocal)
DustR.ar(0, 0.1)
Regards,
Rohan
struct DustR : public Unit
{
int32 mCounter;
};
void DustR_next(DustR *unit, int inNumSamples);
void DustR_Ctor(DustR *unit);
void DustR_Ctor(DustR *unit)
{
SETCALC(DustR_next);
unit->mCounter = 0;
DustR_next(unit, 1);
}
void DustR_next(DustR *unit, int inNumSamples)
{
float *out = ZOUT(0);
float iot_min = ZIN0(0);
float iot_max = ZIN0(1);
int32 counter = unit->mCounter;
RGET
LOOP(inNumSamples,
if (counter <= 0) {
float z = frand(s1,s2,s3);
ZXP(out) = z;
z = (z * (iot_max - iot_min)) + iot_min;
counter = (int32) (z * unit->mRate->mSampleRate);
} else {
ZXP(out) = 0.f;
}
counter -= 1;
);
unit->mCounter = counter;
RPUT
}
DefineSimpleUnit(DustR);
DustR : UGen {
*ar { arg lo = 0.0, hi = 1.0, mul = 1.0, add = 0.0;
^this.multiNew('audio', lo, hi).madd(mul, add)
}
*kr { arg lo = 0.0, hi = 1.0, mul = 1.0, add = 0.0;
^this.multiNew('control', lo, hi).madd(mul, add)
}
}