Sunday, April 27, 2008

CC3 Week 6 - Synthesiser Definitions I

I spent most of the time for this exercise just getting my SynthDef to work. The final result isn't very inspiring but I'm sure I will get the chance to create much more exciting sounds in the future.


AUDIO
SynthDef example [400KB]


//Synth Def
(
SynthDef("SinTone", {

arg cFreq = 500, cAmp = 0.5, mFreq = 3, mAmp = 0.75;

var carrier, modulator, out;

modulator = LFSaw.ar(freq: mFreq, mul: mAmp);
carrier = SinOsc.ar(freq: cFreq, mul: modulator * cAmp);

out = Out.ar(bus: 0, channelsArray: carrier);

}).send(s);
)

a = Synth("SinTone", [\cFreq, 222, \cAmp, 0.9]);
a.set(\cFreq, 800, \cAmp, 0.15);
a.set(\mFreq, 5);
a.set(\mFreq, 10);
a.set(\mFreq, 15);
a.set(\mFreq, 20);
a.set(\mFreq, 30);
a.set(\mFreq, 40);
a.set(\cFreq, 100, \cAmp, 0.15);
a.set(\cFreq, 8000, \cAmp, 0.15);
a.set(\cFreq, 50, \cAmp, 0.15);




// MIDI control
(
MIDIClient.init;

MIDIClient.sources;

MIDIIn.connectByUID(inport: 0, uid: MIDIClient.sources.at(0).uid);
)



(
MIDIIn.noteOn = {

arg src, chan, num, vel;

[chan,num,vel].postln;

a.set(\cFreq, num.midicps);
};
MIDIIn.noteOff = {};
)
(
MIDIIn.control = {

arg src, chan, num, val;

[src, chan,num,val].postln;

a.set(\mFreq, (val * 1.5));
};
)




[1] Christian Haines. "Creative Computing: Semester 1 - Week 6 - Synthesiser Definitions I". Lecture presented at the Electronic Music Unit, University of Adelaide, South Australia, 10th April 2008

No comments: