/************************************************************************************************/ /* */ /* Additive synthesis assignment example */ /* */ /************************************************************************************************/ GUI window coordinates are absolute and subwindows such as sliders are relative to main GUI Window ( //Variable Decleration var w, numberOfCol; var leftEnd, topEnd, rightEnd, bottomEnd, xOffset, yOffset; var minKnobFreq, maxKnobFreq, minKnobAmp, maxKnobAmp, minKnobPhase, maxKnobPhase; var link1,link2, controls; var ran, left, top, right, bottom; //Setup variables and parameters numberOfCol = 16; xOffset = 574; yOffset = -20; minKnobFreq = 20; maxKnobFreq = 2000; minKnobAmp = 0; maxKnobAmp = (1/numberOfCol); minKnobPhase = 0; maxKnobPhase = 359.9; // these are absolute values on screen(monitor) leftEnd = 40 + xOffset; topEnd = 80 + yOffset; rightEnd = 350 + xOffset; bottomEnd = numberOfCol*36.5 + yOffset; // Make sliders and String views w = GUIWindow.new("Multi Sliders", Rect.new(leftEnd, topEnd, rightEnd, bottomEnd)); // makes link macro link1 = { arg in, out; w.views.at(in).action = { w.views.at(out).value = w.views.at(in).value }}; link2 = { arg in, out; link1.value(in, out); link1.value(out,in)}; controls = { arg j, minVal, maxVal, color, type0; numberOfCol.do({ arg i; // i will increment by 1 n times left = 20 + (240*(j/3)); top = 28 * i + 8 +20; right = 240*((j+1)/3); bottom = 28 * i + 24+ 20; if(type0 < 1, { ran = minKnobFreq+(maxKnobFreq-100).rand; NumericalView.new(w, Rect.new( left, top, right-20, bottom), nil, ran, minVal, maxVal) .backColor_(color).labelColor_(color); SliderView.new(w, Rect.new( 50 +left, top, right + 50 , bottom), nil, ran, minVal, maxVal) .knobColor_(color); link2.value(i*2,(i*2)+1); // link nums and sliders }, { ran = 0; SliderView.new(w, Rect.new( 50 +left, top, right + 50 , bottom), nil, ran ,minVal,maxVal) .knobColor_(color); } ); }); }; controls.value(0, minKnobFreq, maxKnobFreq, rgb(37,53,176), 0); controls.value(1, minKnobPhase, maxKnobPhase, rgb(54,176,56), 1); controls.value(2, minKnobAmp, maxKnobAmp, rgb(176,22,43), 1); // string view setup StringView.new( w, Rect.newBy( 38, 5, 60, 19 ), "Frequency") .labelColor_(rgb(50,44,176)); StringView.new( w, Rect.newBy( 148, 5, 60, 19 ), "Phase") .labelColor_(rgb(50,122,31)); StringView.new( w, Rect.newBy( 227, 6, 60, 19 ), "Amplitude") .labelColor_(rgb(176,17,20)); StringView.new( w, Rect.newBy( 107, 473, 140, 18 ), "'Additive Synthesis'"); // make controls and mix each signal together Synth.scope({ Mix.ar( Array.fill(numberOfCol, { arg i; SinOsc.ar( ControlIn.kr( w.views.at((i*2)+1)), // freq ControlIn.kr( w.views.at(i+(2*numberOfCol))), // phase ControlIn.kr( w.views.at(i+(3*numberOfCol))) // amp ) } ) ) }); //w.close; )