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

Re: [sc-users] Immediate Pattern Update via Environment



Hi -

Here's a different approach... maybe it does what you want:

s.boot

SynthDef("bass",
{
        arg freq = 440, gate = 1, amp = 0.5, slideTime = 0.17, ffreq = 1100,
                width = 0.15, detune = 1.005, preamp = 4;
        var sig,
        // --------------------------------------------------
        env = Env.adsr(0.01, 0.3, 0.4, 0.1);
        freq = Lag.kr(freq, slideTime);
        sig = Mix(VarSaw.ar([freq, freq * detune], 0, width,
preamp)).distort * amp
        * EnvGen.kr(env, gate, doneAction: 2);
        sig = LPF.ar(sig, ffreq);
        // --------------------------------------------------
        Out.ar(0, sig ! 2)
}).memStore;


~mynotes = { 40 };

~pattern1 = Pbind(
                \instrument, "bass",
    /* Pfunc dynamically evaluates things; Pflatten unpacks arrays if
we supply them */
                \midinote, Pflatten(1, Pfunc({~mynotes.value})),
                \dur, Pseq([1.0,1.0,1.0,1.0], inf),
                \legato, Pseq([0.9, 0.3, 0.3, 0.3, 0.3], inf),
                \amp, 0.5,
                \detune, 0.005
        );


~pattern1.play;

// Now because of the Pfunc (which will dynamically
// query the ~mynotes variable), you can update on-the-fly:

~mynotes = { [40, 50] }

~mynotes = { (41..69) }


HTH
Dan




2009/3/10 Ataxian <rhysperkins@xxxxxxxxxxxxxxx>:
>
> If I have the following PDefn:
>
>        // Set Pattern1 environment first with initial values
>        Pdefn(\Pattern1).set
>                (
>                        \instrument, "bass",
>                        \midinote, 40,
>                        \dur, Pseq([1.0,1.0,1.0,1.0], inf),
>                        \legato, Pseq([0.9, 0.3, 0.3, 0.3, 0.3], 1),
>                        \amp, 0.5,
>                        \detune, 0.005
>                );
>        // Need to refer to Pattern1 environment in some way so create a variable =
> envir
>        e = Pdefn(\Pattern1).envir;
>        // Define Pattern1
>        Pdefn //(key,Pattern)
>        (
>                \Pattern1,
>                {
>                        arg e;
>                        Pbind
>                        (
>                                \instrument, e.instrument,
>                                \midinote, e.midinote,
>                                \dur, e.dur,
>                                \legato, e.legato,              // /legato is a common synth parameter (find out
> others)
>                                \amp, e.amp,
>                                \detune, e.detune
>                        )
>                }
>        );
>
> Which is played via instrument:
>
>                SynthDef("bass",
>                {
>                        arg freq = 440, gate = 1, amp = 0.5, slideTime = 0.17, ffreq = 1100,
> width = 0.15,
>                        detune = 1.005, preamp = 4;
>                        var sig,
>                        // --------------------------------------------------
>                        env = Env.adsr(0.01, 0.3, 0.4, 0.1);
>                        freq = Lag.kr(freq, slideTime);
>                        sig = Mix(VarSaw.ar([freq, freq * detune], 0, width, preamp)).distort *
> amp
>                        * EnvGen.kr(env, gate, doneAction: 2);
>                        sig = LPF.ar(sig, ffreq);
>                        // --------------------------------------------------
>                        Out.ar(0, sig ! 2)
>                }).load(s);
>
> Using the command:
>
> Pseq([Pdefn(\Pattern1)], inf).play;
>
> How do I change the environment for the next note in the sequence rather
> than when the pattern is repeated?
>
> For example setting a new \midinote:
>
> Pdefn(\Pattern1).set(\midinote, 70);
>
> Will only update once the pattern has come to the end of a repetition.  How
> can I update it immediately, or when it is next safe to do so?
>
> Thanks
>
>
>
> --
> View this message in context: http://www.nabble.com/Immediate-Pattern-Update-via-Environment-tp22427171p22427171.html
> Sent from the Supercollider - User mailing list archive at Nabble.com.
>
>
> _______________________________________________
> sc-users mailing list
>
> info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
> archive: https://listarc.bham.ac.uk/marchives/sc-users/
> search: https://listarc.bham.ac.uk/lists/sc-users/search/
>



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

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/