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

Re: [sc-users] .range instead of add



Since there are 2 nested UGens both with muls and adds, I don't know of a way to do it with a single call to range, but here is a version with 2 calls to range that produces the same result as the SC book example:

(

play(

        {

                CombN.ar(

                       SinOsc.ar(

                               midicps(

                    LFNoise1.ar(1).range(-24, 24) +  LFSaw.ar([5, 5.123]).range(-3, 3) + 80

                               ),

                               0, 0.1),

                       1, 0.1, 2,0.5)

        }

)

As a general rule, you can follow this algorithm:

SomeUgen.ar(freq, mul, add) == SomeUgen.ar(freq).range(-mul, mul) + add

If the Ugens are nested like in your example, you can still follow the same algorithm, working from the inside out. Also note that you can use the bipolar method instead of range any time the range is symmetrical around 0. For example:

bipolar(3) == range(-3, 3)

bipolar is more concise, and I find it more readable, but it depends on your preference of course. I hope that helps.

--Brett


On Fri, Dec 13, 2019 at 1:35 PM <nilswallgren@xxxxxxxxxxx> wrote:

I am trying to convert this example from the SC Book to .range instead of mul and add but I am having some trouble doing it.

This is the original:

 

(

play(

        {

                CombN.ar(

                       SinOsc.ar(

                               midicps(

                                       LFNoise1.ar(1, 24,

                                               LFSaw.ar([5, 5.123], 0, 3, 80)

                                       )

                               ),

                               0, 0.1),

                       1, 0.1, 2,0.5)

        }

)

)

 

 

 

// my first attempt

(

play(

        {

                CombN.ar(

                       SinOsc.ar(

                               midicps(

                                       LFNoise1.ar(1+LFSaw.ar([5,5.123])).range(27,104)

 

                               ),

                               0, 0.1),

                       1, 0.1, 2,0.5)

        }

)

)

 

//#2

(

play(

        {

                CombN.ar(

                       SinOsc.ar(

                               midicps(

                                       LFNoise1.ar(10,3*LFSaw.ar([5,5.123])).range(27,104)

 

                               ),

                               0, 0.05),

                       1, 0.1, 2,0.5)

        }

)

)

 

//#3

(

play(

        {

                CombN.ar(

                       SinOsc.ar(

                               midicps(

                                       LFNoise1.ar(10,3)*LFSaw.ar([5,5.123]).range(27,104)

 

                               ),

                               0, 0.05),

                       1, 0.1, 2,0.5)

        }

)

)

 

 

 

 

Sent from Mail for Windows 10