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

Re: [Sc-devel] fixing audio rate demand ugen input



Julian,

The basic idea sounds fine but that execution issue you describe
sounds tricky. I'd be scared to fiddle with scsynth's
order-of-execution code for executing a UGen graph correctly, although
it sounds like this might be what's ignoring the SinOsc if called only
by a demand. Have you peeked at the relevant scsynth code, tried to
figure out where the ignoring comes from?

This might be an issue only one person in the world can answer...

Dan


2007/11/10, Julian Rohrhuber <rohrhuber@xxxxxxxxxxxxxx>:
> I have found a simple way to allow audio rate inputs for demand ugens
> (well, they were allowed so far, but didn't work). From the Demand /
> Duty ugen I pass in 1 + i as a second argument to DEMANDINPUT, where
> i is the current sample offset. So for reset we use inNumSamples = 0,
> i.e. DEMANDINPUT(index, 0) as it is used so far, and otherwise
> inNumSamples means the current index + 1. When DEMANDINPUT is called
> on an audio rate ugen, it will return the appropriate sample. Is this
> a reasonable thing to do?
>
>
> there is a problem though still: it seems that the SinOsc is never
> called unless it has a non-demand ugen as a descendant. Is this
> difficult to change?
>
> // this outputs 1 only...
> (
> {
> var dem, audio, trig;
> audio = SinOsc.ar(440);
> dem = Drand([audio], inf);
> trig = Impulse.ar(MouseX.kr(1, SampleRate.ir / 2, 1));
> Demand.ar(trig, 0, dem).poll(trig) * 0.1;
> }.play
> );
>
>
> (
> {
> var dem, audio, trig;
> audio = SinOsc.ar(440);
> dem = Drand([audio], inf);
> trig = Impulse.ar(MouseX.kr(1, SampleRate.ir / 2, 1));
> audio + 0.01; // we somehow have to call the audio function explicitly
> Demand.ar(trig, 0, dem).poll(trig) * 0.1;
> }.play
> );
>
>
>
>
>
> here is a test that works fine:
>
> (
> {
> var dem, trig, audio, x1, x2;
> audio = LFNoise2.ar(8000);
> dem = Dseq([audio], inf);
> trig = Impulse.ar(MouseX.kr(1, 3000, 1));
> x1 = Demand.ar(trig, 0, dem);
> x2 = Latch.ar(audio, trig);
> [x1, x2] // should always correspond (and does so)
>
> }.play
> );
>
>
> the main change is the introduction of:
>
> inline float DemandInputA(Unit* unit, int index, int offset)
> {
>         Unit* fromUnit = unit->mInput[index]->mFromUnit;
>         if(!fromUnit) { return IN0(index); }
>         if (fromUnit->mCalcRate == calc_DemandRate) {
>                 (fromUnit->mCalcFunc)(fromUnit, offset);
>                 return IN0(index);
>         } else if (fromUnit->mCalcRate == calc_FullRate) {
>                 return IN(index)[offset - 1];
>         } else {
>                 return IN0(index);
>         }
> }
>
> #define DEMANDINPUT_A(index, offset) DemandInputA(unit, (index), (offset))
>
>
>
> which is used wherever this is appropriate.
>
> I think it makes the demand ugens much more valuable, because you can
> really go up to audio rate in a continuous movement.
> --
>
>
>
>
>
> .
> _______________________________________________
> Sc-devel mailing list
> Sc-devel@xxxxxxxxxxxxxxx
> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>


-- 
http://www.mcld.co.uk