/* David and Connor Smith, Assignment 3. "Warp" a friend of mine has a delay box on his electric guitar that has a dial on it to change the delay time. when you twist the dial while he's playing, it makes a strange sound as you turn it because it's speeding up the sound that is already repeating in the box. when he plays again after the dial is turned, it is a normal delayed sound. i wanted to try to make that sound, and combine it with a random sine wave generator. there is an added feature in the patch. instead of manually turning the dial all the time, like i'd have to with a delay pedal, there is an automatic function that warps the pitch at a steady rate. the nice thing about the comb filter is that you get a richer sound by echoing the sine waves as well as the option of warping the sound. the sine waves don't exactly line up all the time with their doubles, so they interfere with each other at times, and make a slightly dirtier sound, although the difference is not extreme. we have 5 variables: w, the window variable echoSlider, which is a slider in the gui that enables the user to manually warp the sound, and it determines the delay time, and thus the added quality given by the delay. ampSlider is a general volume control. box is used for the automatic oscillation of the delay time. number_of_sines dictates to Mix.ar how many random sines there are. if number_of_sines wasn't there, there would be only one. this is how the patch works: the only real UGens are 7 randomly panning sine wave generators. the ugen SinOsc creates random pitch sine waves, which are planning constantly because of the pan2 function. the mix function creates an array of number_of_sines randomly panning sine waves, and they continue for a length of time dictated by the XFadeTexture function, which then fades them into the next group of sine waves. the ampSlider is connected directly into the comb function, which controls how much sound goes to the panning function. echoSlider is connected into the delay time parameter of the comb function. */ ( var w, echoSlider, ampSlider, freqSlider, box, sineAmpSlider, echoSineAmp = 0.5; w = GUIWindow.new("panel", Rect.newBy( 128, 64, 237, 334 )); echoSlider = // This slider controls the comb filter SliderView.new( w, Rect.newBy( 42, 81, 128, 20 ), "SliderView", 0.01, 0.01, 0.5, 0.01, 'linear'); ampSlider = // This slider controls the amplitude SliderView.new( w, Rect.newBy( 42, 34, 128, 20 ), "SliderView", 0.5, 0.01, 1, 0.01, 'linear'); sineAmpSlider = // This slider controls the amplitude of the auto warp sine wave. SliderView.new( w, Rect.newBy( 42, 200, 128, 20 ), "SliderView", 0, 0, 1, 0.01, 'linear'); freqSlider = // This slider controls the frequency of the auto warp sine wave. SliderView.new( w, Rect.newBy( 42, 259, 128, 20 ), "SliderView", 3, 0, 40, 0.25, 'linear'); StringView.new( w, Rect.newBy( 42, 15, 128, 20 ), "Amplitude"); StringView.new( w, Rect.newBy( 42, 61, 128, 20 ), "Manual Warp"); StringView.new( w, Rect.newBy( 42, 180, 128, 20 ), "Warp Power"); StringView.new( w, Rect.newBy( 42, 239, 128, 20 ), "Warp Frequency"); box = CheckBoxView.new( w, Rect.newBy( 42, 138, 128, 20 ), "Auto warp", 0, 0, 1, 0, 'linear'); // XLine.kr(0.0001, 0.01, 20) used to be decaytime Synth.play({ var number_of_sines, echoRate; //number_of_sines = sinSlider.value number_of_sines = 7; echoRate = ControlIn.kr(echoSlider) + abs((SinOsc.ar(ControlIn.kr(freqSlider), 0, ControlIn.kr(sineAmpSlider) * ControlIn.kr(box)))); XFadeTexture.ar({ Mix.ar(Array.fill(number_of_sines, { Pan2.ar( CombN.ar(FSinOsc.ar(80 + 2000.0.linrand), 1, echoRate, 0.01, ControlIn.kr(ampSlider)), //LFNoise2.kr(0.4 + 0.8.rand), Dust.kr(2000, 2), LFNoise2.kr(0.4 + 0.8.rand, 0.4, 0.5) ); })) * (0.4 / number_of_sines); }, 8, 8, 2); } ); //w.close; ) ( var w, amp = 0.0, box; w = GUIWindow.new("panel", Rect.newBy( 128, 64, 252, 213 )); box = CheckBoxView.new( w, Rect.newBy( 40, 15, 128, 20 ), "Auto warp", 0, 0, 1, 0, 'linear'); { box.action = { if(box.value == 0, { amp = 0.5; } ); }; SinOsc.ar(220, 0, ControlIn.kr(box)); }.play; )