/* *********************************************************************************** HW1 Solution - Problem 1 Implementation of Figure 6.14 - Computer Music Tutorial. Created by Juan-Pablo Caceres, January 2007 Under Subversion Control System *********************************************************************************** */ s = Server.default.boot; //SynthDef (Definition of the instrument) //-------------------------------------- ( SynthDef("envFM_hw1", { // Define arguments and default arg out=0, gate = 1.0, amp = 0.1, carrier_freq = 440.0, carrier_amp = 1.0, mod_freqM = 75.0; //Variables for oscilators and evelopes var osc_car, env_car, osc_mod, env_mod; //Define triangular envelope for Index env_mod = Env.triangle( dur: 10, level: 13); //ADSR Evevelope for Carrier env_car = Env.adsr( attackTime: 3.0, decayTime: 2.0, sustainLevel: 0.5, releaseTime: 1.0, peakLevel: 1.0, curve: 'linear'); //Create the Modulation Oscilator osc_mod = SinOsc.ar( freq: mod_freqM, mul: EnvGen.kr(env_mod) * mod_freqM ); //Create the Oscilator Modulator osc_car = SinOsc.ar( freq: carrier_freq + osc_mod, mul: EnvGen.kr(env_car, gate, doneAction:2) * amp ); //Send the output Out.ar(out, osc_car); }).load(s); ) //Now we play our instrument. We use a Routine just to schedule the gate at 9 seconds //for the ADRS envelope. ( Routine( {a = Synth("envFM_hw1"); 9.0.wait; a.set(\gate, 0); }).play )