amplitude array

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

amplitude array

madalyn-m
hello Forum,

I am looking to insert lists of amplitude points into my supercollider code.  
I have two SynthDefs, a pulse ("directionB") and a sine tone("directionA") that play a sequence of 10 glissandi. The composition plays correctly, but I forgot to add the list of amplitude points, and its my first time coding, so I lack a strategy to insert the list.  What should happen: there is a "~step" number that counts from 1 to 10. the "/* comment at the bottom of the code */" specifies the unique amplitude envelope of each voice as a list of 11 numbers, that should occur in sequence across the duration of the voice (denoted as "ttempoA" or "ttempoB").  The amplitude array lists have light syntax: the initial number denotes the step or voice number, followed by the array in braces. Please let me know if you have any questions or can make a suggestion to my query.

see you soon, madalyn.

//----------------------------------------------------//
// Composition "Q 110" (1968) by Enore Zaffiri
//SuperCollider version by madalyn-m
//----------------------------------------------------//

(
( s.plotTree; (
(a = SynthDef.new("directionA",
        { arg hzA1 = 100, hzA2 = 1000, ttempoA = 45, ampA = 0.15;
                var sndA, envA;
                sndA = SinOsc.ar( Line.kr(hzA1, hzA2, ttempoA), 0, ampA);
                envA = EnvGen.kr(
                        envelope: Env.new([0, ampA,  ampA, 0 ], [0.3, (ttempoA - 0.6), 0.3] ),
                        doneAction:2);
                Out.ar(0, [sndA, sndA] * envA );
                }).add;);
(b = SynthDef.new("directionB",
        { arg hzB1 = 100, hzB2 = 1000, plusePeriod = 1, ttempoB = 1, ampB = 0.9;
                var sndB, envB;
                sndB = BPF.ar(
                        in:LFPulse.ar(freq:plusePeriod,width:0.5),
                        freq:(Line.kr(hzB1, hzB2, ttempoB)),
                        rq:0.05,
                        mul:(ampB * 2));
                envB = EnvGen.kr(
                        envelope: Env.new(levels:[0, ampB,  ampB, 0 ],
                                times:[0.01, ttempoB , 0.01] ),
                        doneAction:2);

                Out.ar(0, [sndB, sndB] * envB );
                }).add;);
);

( // 1.2 set number of ~steps
~steps = 10 ;

// 2. play sound
(
Pbind(
        \instrument, "directionA",
        \hzA1,Pseries(2000, -200, ~steps),
        \hzA2, Pseries(2200, 200, ~steps),
        \ttempoA, Pseries(95, -10, ~steps),
        \dur, 5).trace.play);
(
Pbind(
        \instrument, "directionB",
        \hzB1,Pseries(200, 200, ~steps),
        \hzB2, Pseries(4000, -200, ~steps),
        \plusePeriod, Pseq({ var a = 1; Array.series(10, 0, 0.05).collect({ arg inc; a = a + inc; 1 / a;}) }.value.reverse ),
        \ttempoB, Pseries(95, -10, ~steps),
        \ampB, 0.9,
        \dur, 5).trace.play);););
)

/*


"directionB" // Pulses  

1, [1.0, 0.316228, 0.27227, 0.27227, 0.27227, 0.27227, 0.269153, 0.223872, 0.211349, 0.211349, 0.211349];
2, [0.431519, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.986279, 0.211349, 0.211349, 0.211349];
3, [0.298538, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.245471, 0.211349, 0.211349, 0.211349];
4, [0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.254097, 0.218776, 0.211349, 0.211349];
5, [0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.266073, 0.237137, 0.213796, 0.211349];
6, [0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.25704, 0.226464, 0.211349];
7, [0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.266073, 0.251189, 0.229087];
8, [0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.266073, 0.260016];
9, [0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227];
10, [0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227, 0.27227];



"directionA" //Sine Tone Voice


1, [0.316228, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.138038, 0.124451, 0.124451, 0.124451];
2, [0.186209, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.151356, 0.124451, 0.124451, 0.124451];
3, [0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.141254, 0.125893, 0.124451, 0.124451];
4, [0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.160325, 0.136458, 0.124451, 0.124451];
5, [0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.164059, 0.153109, 0.128825, 0.124451];
6, [0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.160325, 0.139637, 0.125893];
7, [0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.164059, 0.160325, 0.144544];
8, [0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.162181];
9, [0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959];
10, [0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959, 0.165959];
*/


Reply | Threaded
Open this post in threaded view
|

Re: amplitude array

cloudhopper
Think you can use Control busses to do this.


~amp1 = Bus.control(s, 1); for gathering the date
In.kr(~amp1), for using it.
If you want to list it... just simply do [In.kr(~amp1), In.kr(~amp2), etc...];

Hope this will help you out.

Greetings.