Defining affective musical parameters
Much of the current music&emotion research uses the circumplex model of emotion, which consists of two components on a 2d scale: valence (positive or negative) and arousal (amount of energy). This model can be easily mapped out in SC using a 2dSlider object. The PAD model extends this further, adding a 3rd axis called dominance, which is a measure of approach and avoidance response, ie the difference between anger and fear. Also mentioned are different 'types' of tempo: score tempo (absolute, eg bpm), preferred tempo (the speed at which people tap along - "60 to 120 bpm, no matter what the score tempo is", and perceived tempo, which relates to the sparsity of the music. They also note that staccato articulation (glitchiness plz) is higher in arousal levels whereas legato tends to be low. Harmonic modes can be ordered from brightest to darkest according to Persichetti, in this order: Lydian, Ionian, Mixolydian, Dorian, Aeolian, Phrygian and Locrian.
So all of these elements can be introduced into my musical grammar. So far I have chosen three polarities: happy/sad, bored/excited, euphoria/dysphora. Happy/sad is simply determined by mode. Bored/excited determined by perceived tempo/staccato-legato. Euphoric/dysphoric would be how the melody is reolved as well as increasing aleatory/glitchy elements.
These were the initial ones I wanted to use, however from this research I have found out the placing of emotions such as anger and fear on the valence-arousal-domination scale and so will try to include this information somehow.
A more scientific approach
Much of the research on music and emotion is based on subjective descriptions of both the music and the response, although the valence-arousal-domination scale is good more precise methods could be found. It would also be more appropriate to measure the participant's neural activity as opposed to asking them to verbalise their responses. Music programming languages provide a good environment to study the effects of frequencies on brainwaves, as the level of control over the sonic output is roughly equivalent to the level of feeeback we can measure, ie its all numbers now.
A possible example is the solfeggio scale [396 417 528 639 741 852 963 Hz], which is said to have a soothing and healing effect due to the 'sacred geometry' of the frequencies, and is used for meditation. Ignoring its nebulous origins (bible code), it does provide an interesting and precise hypothesis which could be tested using SC & a ECG machine very easily...eg create a sequence based on these specific frequencies and see if brainwave patterns differ with random mutations (could even use a genetic algorithm to create The Most Trancey sequence ever by creating a GUI for real-time user feedback). Also, on the trance-state aspect of music, gong and bell sounds are used for meditation all over the world due to their wide spectrum of harmonicity, and it is relatively easy to recreate these kinds of sounds using additive synthesis.The harmonics could then be fine-tuned to precise mathematical formulas. I like the idea of music as 'brain food'. Juslin et al note that it is very important to young people in defining self-identity, and essentially listening to bad music is like feeding children junk food for the soul (sort of). Music that is attuned to creating mental states would be like eating wholegrains/pure vitamins except mainlined straight into ur brainz..............
So to recap: there is plenty of research on affective music using conventional means, and lots of room to explore non-conventional means.
Friday, 30 April 2010
stuff ive found out from research papers on music and emotion
Posted by Niadzi at 13:13 0 comments
Friday, 23 April 2010
physical modelling in supercollider
supercollider offers a lot of possibilities for physical modelling of real-life sounds. this is interesting because of the options to sonify situations that we can barely imagine, eg a string the length of the path from earth to the sun being plucked by a subatomic astronaut, or a drum as big as jupiter, or a guitar the size of the milky way...
whilst there might not be a particularly pressing need for humans to hear such sounds, the technology could be useful in sound design for games, in creating a dynamic soundtrack that is based on the user interacting with the physical modelling of the game.
this topic reminds me of dr fiorella terenzi's work on sonifying galaxies; as extensions, data from "outer space" combined with visual representations would be an interesting way to look at physics and may aid understanding from beyond a theoretical maths perspective, and it would be fascinating on a smaller scale, using high-musicality algorithms to render the theories of subquantum kinetics. the effects of music/sound on thought patterns and cognitive activity is well-documented, and sonifying theoretical science may well lead to interesting scientific breakthroughs via altered mental states (eg kekule seeing the uroborus in a dream). so we may yet come closer to a theory of everything with supercollider (but not the one at cern)
Posted by Niadzi at 10:25 0 comments
Thursday, 22 April 2010
research papers on music and emotion
http://www.acoustics.hut.fi/dafx08/papers/dafx08_02.pdf
http://portal.acm.org/citation.cfm?id=1180665
http://books.google.co.uk/books?id=HuWCVGKhwy0C&dq=music+emotion&lr=&source=gbs_navlinks_s
http://www.stefan-koelsch.de/PeMS_lectures/Juslin+_BehavBrSci31_2008_emotional-reponses-to-music.pdf
http://www.stefan-koelsch.de/PeMS_lectures/Koelsch_2009_12-Juslin%20&%20Sloboda-Ch-12_in-press.pdf
http://www.psy.mq.edu.au/me2/uploads/publications/a_cross_cultural_investigation_of_the_perception_of_emotion.pdf
http://www.wisegeek.com/what-are-the-seven-modes-of-music.htm
Posted by Niadzi at 09:04 0 comments
algorithmic composition
algorithmic composition is the technique of using predetermined rules to create music. the algorithms can be aleatory or totally predetermined, derived from fractals, L-Systems or other statistical models, evolutionary methods (ie mutation/selection processes from genetic algorithms) or a musical grammar could be explored.
it is essentially music which is created using consciously mathematical processes as opposed to a more intuitive 'jamming' state...although most musicians will use algorithms in some form, a guitarist soloing thru a particular scale could be thought of as using aleatory algorithms.
algorithmic composition seems to be a more 'left-brain' approach to composition, i think a 'right-brain' approach would encompass the composer/listener's emotional state as well, this is what i want to try and do with my algorithmic piece, by making it interactive as well as a little bit aleatory. first i would have to create a musical grammar of emotion, a simple start is happy=major key, sad=minor; excited=fast, tired=slow; etc....using polarities so that a slider could be used as a gui. the gui would initialise the piece, which would then run itself through varying possibilities based on the initial inputs.
Posted by Niadzi at 07:04 0 comments
Thursday, 4 March 2010
SwingOSC.default.boot;
(
var
// GUI elements
w, slider1, slider2, slider3,
kickcs, cymbalcs, hatscs, snarecs, melodycs, bubblecs,
makewindow,
// Timing elements
bps, clock, bar, beat,
//Drum patterns
kickpattern, snarepattern, hatspattern, cypattern,
kickp, snp, hhp, cyp, hatsdecay,
//Melody patterns
wholepattern, bassline, baseline, mela, melb, melc, meld, mele, melody,
//colors
rainbow,highpink,sunset,amethyst,emerald,skyfi,
//synths
bfcs, bassfreq;
bps = 6;
clock= TempoClock(bps);
bar= 4/bps;
beat= bar/4;
//drumSynths
SynthDef(\kick,
{arg vol= 1, decay= 1, pitch= 1, filter= 1, on=0;
var sin, pw, kik, kikfilter, volon;
volon= vol*on;
sin= LFTri.ar(freq: Line.kr(40,20,0.1*decay,doneAction:2)*pitch+2,
add: 0, mul: 0.3*volon);
pw= Pulse.ar(freq: 40, add: 0,
mul: EnvGen.ar(Env.perc(0,0.07,0.3*volon)));
kik= Mix.new([sin,pw]);
kikfilter= LPF.ar(in: kik, freq: XLine.kr(200,30,0.1*decay)*filter);
Out.ar(0, Pan2.ar(kikfilter, 0))}).store;
SynthDef(\snare,
{arg vol= 1, on= 0, decay= 1, pitch= 1, filter= 1, filter2= 1;
var noise, filtap, volon, tri, snare, snaref, snaref2;
volon= vol*on;
filtap= EnvGen.ar(Env.perc(0,0.2*decay,0.2*volon,1));
noise= WhiteNoise.ar(mul: filtap, add: Line.kr(-3.5,2,1));
tri= Pulse.ar(freq: Line.kr(60*pitch,228,0.3,doneAction:2),
mul: Line.kr(0.1,0.00,0.1)*volon);
snare= noise+tri;
snaref= HPF.ar(in: snare, freq: Line.kr(800,200,0.22)*filter);
snaref2= LPF.ar(in: snaref, freq: Line.kr(600,1000,0.81)*filter2);
Out.ar(0, Pan2.ar(snaref*on, 0))}).store;
SynthDef(\hats,
{arg vol= 1, decay= 1, on=0, pitch=1;
var noise, filter, envel, menv,onvol;
onvol= -1*on*vol;
menv= EnvGen.ar(Env.perc(0.3,0.01,1,4));
noise= PinkNoise.ar(mul: menv*onvol*7, add: Line.kr(1*pitch,0,0.03*decay,doneAction:2));
envel= EnvGen.ar(Env.adsr(0.00001,0.2*decay,0.7,0.2,2900));
filter= HPF.ar(in: noise, freq: envel);
Out.ar([0,1], Mix.ar(filter))}).store;
SynthDef(\cymbal,
{arg vol= 0.5, decay= 1, pitch= 1, on= 0;
var sq1, sq2, volon;
volon= vol*on;
sq1= Pulse.ar(freq: Line.kr(623*pitch,223,0.2*decay,doneAction:2)*pitch,
mul: 0.3*volon);
sq2= Pulse.ar(add: 0,
freq:EnvGen.ar(Env.triangle(0.8*decay,300)),
mul: 0.3*volon);
Out.ar([0,1], Mix.ar(sq1*sq2))}).store;
//synthSynths
SynthDef(\lead,
{ arg note=60, amp=4, clock=bps, filfreq=2, length=1, pan=7;
var freq, sin, saw, sinsaw, panner, filterenv, beat, sinres;
freq= note.midicps*2;
beat= bps;
sin= SinOsc.ar
(freq: Line.kr(freq-3,freq,beat,doneAction:2),
mul: Line.kr(0.2,0.01,beat+1));
saw= LFTri.ar
(freq: Line.kr(freq-1,freq,beat,doneAction:2),
mul: Line.kr(0.2,0.01,beat+1));
filterenv= LPF.ar(in: saw, freq: filfreq*1000+70);
sinres= Resonz.ar(in: sin, freq: SinOsc.ar(freq: 0.3, mul: 0.6,add:700));
panner = Pulse.ar(freq: (pan*3), mul:0.5);
Out.ar(0, Pan2.ar(in:filterenv+sinres, pos:panner))
}).store;
SynthDef(\bass,
{ arg note=44, bubble=0, bubblelength=3;
var env2, freq, pulse, tri, beat,env,filter, out1, sin;
freq= note.midicps;
beat= (4/18);
pulse= Pulse.ar(freq: freq, mul:0.4);
tri= LFTri.ar(freq: freq, mul: 0.3);
sin= bubble*SinOsc.ar(freq: Line.kr(freq*16,freq*2, beat*bubblelength), mul:0.3);
env= Line.kr(0,1,beat,doneAction:2);
env2= EnvGen.ar(Env.triangle(1,beat));
out1= MoogFF.ar(in:tri+pulse, freq: 1900*env);
Out.ar(0, Pan2.ar(in:out1+sin, pos:0)) } ).store;
SynthDef(\am,
{ arg am= 1, arp=0, bubble=0;
var freq, ampmod, sin, sin2, arparray, bubbles, pan;
freq= 622;
ampmod= SinOsc.ar(freq:Line.kr(4,1,4,doneAction:2), mul:0.1);
sin= Pulse.ar(freq: 622, mul: 0.3*ampmod);
sin2= LFTri.ar(freq: Line.kr(1245,311,4), mul:0.04);
bubbles= Resonz.ar(in:sin, freq:Line.kr(9100,00,4));
pan= SinOsc.ar(freq: 4);
Out.ar([0], (Pan2.ar(in: bubbles, pos: pan)+Pan2.ar(in: sin2, pos: -1*pan))) } ).store;
rainbow = {
highpink= Color.new255(2554194);
sunset= Color.new255(255,94,41);
amethyst= Color.new255(195,15,255);
emerald= Color.new255(41,255,94);
skyfi= Color.new255(102,255,217);
};
rainbow;
w= JSCWindow("- 0 - 0 - 0 - 0 -", Rect(100,100,510,230));
w.view.decorator= FlowLayout(w.view.bounds, 10@10, 20@20);
//w.view.background= Color.rand;
//Buttons
a= JSCButton(w,Rect(20,20,150,30));
a.states= [ ["drumsON", emerald], ["OFF", highpink]];
b= Ppar([kickp,hhp,snp,cyp]).play(clock, quant:1);
a.action= { | state |
if(state.value == 0, {b.stop});
if(state.value == 1, {b= Ppar([kickp,hhp,snp,cyp]).play(clock, quant:1);
})};
c= JSCButton(w,Rect(20,20,150,30));
c.states= [ ["leadON"], ["OFF"] ];
d= Ppar([melody]).play(clock, quant:12);
c.action= { | state |
if(state.value == 0, { d.stop } );
if(state.value == 1, { d= Ppar([melody]).play(clock, quant:12) } ) };
e= JSCButton(w,Rect(20,20,150,30));
e.states= [ ["bassON"], ["OFF"] ];
f= baseline.play(clock, quant:12);
e.action= { | state |
if(state.value == 0, { f.stop } );
if(state.value == 1, { f= baseline.play(clock, quant:12) } ) };
w.front;
w.onClose= {b.stop; d.stop; e.stop};
//Sliders
slider1= Slider2D(w,Rect(8,9,150,150));
slider2= Slider2D(w,Rect(8,9,150,150));
slider3= Slider2D(w,Rect(8,9,150,150));
kickcs= ControlSpec(1,9,'linear',1,1);
snarecs= ControlSpec(1,4,'linear',1,1);
hatscs= ControlSpec(1,10,'linear',1,1);
cymbalcs= ControlSpec(1,5,'linear',1,1);
melodycs= ControlSpec(1,7,'linear',1,2);
bubblecs= ControlSpec(-4,7,'linear',1,2);
//Drum patterns
kickpattern= Pseq([1,0,0,0, 0,0,0,0, 0,0,1,0, 0,0,0,0,
1,0,0,0, 0,0,0,0, 0,0,1,1, 0,0,0,0,
1,0,0,0, 0,0,0,0, 0,0,1,0, 0,0,0,0,],inf);
hatspattern= Pseq([1,1,1,1, 1,0,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1],inf);
snarepattern= Pseq([0,0,0,0, 1,0,0,0, 0,0,0,0, 1,0,0,0],inf);
cypattern= Pseq([0,0,0,0, 0,0,0,0, 0,0,1,0, 0,0,0,0, 0,0,1,0],inf);
hatsdecay= Pseq([1,1,3,1, 1,2,3,1, 1,3,1,1, 1,2,1,1],inf);
kickp= Pbind( \on,Pseq([kickpattern],inf),
\instrument, \kick,
\vol,1,\decay,4,\filter,115,
\pitch,Pfunc({kickcs.map(slider1.x).postln}));
hhp= Pbind( \on,Pseq([hatspattern],inf),
\instrument, \hats,
\decay,Pseq([hatsdecay],inf),
\vol,Pfunc({hatscs.map(slider2.x).postln}));
snp= Pbind( \on,Pseq([snarepattern],inf),
\instrument, \snare,
\vol,1,\decay,Pfunc({snarecs.map(slider2.y).postln}),\pitch,5);
cyp= Pbind( \on,Pseq([cypattern],inf),
\instrument, \cymbal,
\vol,1,\decay,1.5,\pitch,Pfunc({cymbalcs.map(slider1.y).postln}));
mela= Pseq([44,58,46,44,44,72,44,51],2);
melb= Pseq([56,60,46,44,42,72,46,51],4);
meld= Pseq([44,58,70,44,42,75,44,51],1);
mele= Pseq([44,58,46,44,44,87,42,51],1);
melc= Pseq([56,58,46,44,40,68,44,51],4);
melody= Pbind( \instrument, \lead,
\note, Pseq([melb,mela,meld,mele,melc],inf),
\length, Prand([0.5,0.66,0.75,1],inf),
\filfreq,Pfunc({melodycs.map(slider3.x).postln}));
bassline= Pseq( [56,44,56,44,56,44,56,44] ++ 44.dup(4) ++
[44,44] ++ [44,44] ++ [56,40,56,40,56,40,56,40]);
baseline= Pbind( \instrument, \bass,
\note, Pseq([bassline],inf),
\stretch,4);
)
Posted by Niadzi at 07:50 0 comments
Sunday, 28 February 2010
Drum sequencing with Patterns
SynthDef(\kick,
{arg vol= 1, decay= 1, pitch= 1, filter= 1, on=0;
var sin, pw, kik, kikfilter, volon;
volon= vol*on;
sin= LFTri.ar(freq: Line.kr(40,20,0.1*decay,doneAction:2)*pitch,
add: 0, mul: 0.3*volon);
pw= Pulse.ar(freq: 40, add: 0,
mul: EnvGen.ar(Env.perc(0,0.07,0.3*volon)));
kik= Mix.new([sin,pw]);
kikfilter= LPF.ar(in: kik, freq: XLine.kr(200,30,0.1*decay)*filter);
Out.ar(0, kikfilter)}).store
// Snare Drum
SynthDef(\snare,
{arg vol= 1, on= 0, decay= 1, pitch= 1, filter= 1, filter2= 1;
var noise, filtap, volon, tri, snare, snaref, snaref2;
volon= vol*on;
filtap= EnvGen.ar(Env.perc(0,0.2*decay,0.2*volon,1));
noise= WhiteNoise.ar(mul: filtap, add: Line.kr(-3.5,2,1));
tri= Pulse.ar(freq: Line.kr(60*pitch,228,0.3,doneAction:2),
mul: Line.kr(0.1,0.00,0.1)*volon);
snare= noise+tri;
snaref= HPF.ar(in: snare, freq: Line.kr(800,200,0.22)*filter);
snaref2= LPF.ar(in: snaref, freq: Line.kr(600,1000,0.81)*filter2);
Out.ar(0, snaref*on)}).store
// Hi-hats
SynthDef(\hats,
{arg vol= 1, decay= 1, on=0;
var noise, filter, envel, menv,onvol;
onvol= on*vol;
menv= EnvGen.ar(Env.perc(0.3,0.01,1,4));
noise= PinkNoise.ar(mul: menv*onvol*7, add: Line.kr(0,0,0.03*decay,doneAction:2));
envel= EnvGen.ar(Env.adsr(0,0.2*decay,0.7,0.2,2900));
filter= HPF.ar(in: noise, freq: envel);
Out.ar(0, filter)}).store
// Other thing
SynthDef(\cymbal,
{arg vol= 0.5, decay= 1, pitch= 1, on= 0;
var sq1, sq2, volon;
volon= vol*on;
sq1= Pulse.ar(freq: Line.kr(623*pitch,223,0.2*decay,doneAction:2)*pitch,
mul: 0.3*volon);
sq2= Pulse.ar(add: 0,
freq:EnvGen.ar(Env.triangle(0.8*decay,300)),
mul: 0.3*volon);
Out.ar(0, sq1*sq2)}).store
(
var clock,
hh, hhpatt, kd, kdpatt, sn, snpatt, cy, cypatt,
cypitch, hhdecay, basspitch, snrdc;
clock= TempoClock(8);
kd= Pseq([1,0,0,0, 0,0,0,0, 0,0,1,0, 0,0,0,0],inf);
hh= Pseq([1,1,1,1, 1,0,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1],inf);
sn= Pseq([0,0,0,0, 1,0,0,0, 0,0,0,0, 1,0,0,0],inf);
cy= Pseq([0,0,0,0, 0,0,0,0, 0,0,1,0, 0,0,0,0, 0,0,1,0],inf);
cypitch= Pxrand([1,2,3,0.3, 1.2,0.6],inf);
hhdecay= Pseq([1,1,2,1, 1,2,1,1, 1,3,1,1, 1,2,1,1],inf);
basspitch= Pseq([2,2,3],inf);
snrdc= Prand([1,1,1,1,1,1.3],inf);
hhpatt= Pbind( \on,Pseq([hh],inf),
\instrument, \hats,
\decay,Pseq([hhdecay],inf));
kdpatt= Pbind( \on,Pseq([kd],inf),
\instrument, \kick,
\vol,1,\decay,4,\pitch,Pseq([basspitch],inf),\filter,115);
snpatt= Pbind( \on,Pseq([sn],inf),
\instrument, \snare,
\vol,1,\decay,Pseq([snrdc],inf),\pitch,5);
cypatt= Pbind( \on,Pseq([cy],inf),
\instrument, \cymbal,
\vol,1,\decay,1.5,\pitch,Pseq([cypitch],inf));
Ppar([hhpatt,kdpatt,snpatt,cypatt]).play(clock); )
Posted by Niadzi at 12:30 0 comments
Using routines
I used a routine to sequence a pattern for the drum sounds that I made. It is however horribly longwinded to make or alter the pattern. I realise now that I could have assigned each different SynthDef to a letter variable, which would have shortened the code a bit, but the overall method is unintuitive and not very elegant. After a bit of research, I found code for a simple drum machine on this website: http://superdupercollider.blogspot.com/2009/02/simple-drum-machine.html. This uses the pattern mechanism and is a lot nicer!
This is my code (using SynthDefs from the previous post):
Routine.new({
inf.do({ arg i;
var speed, speed2;
speed=0.2;
speed2= speed*2;
Synth(\kick,[\vol,4,\decay,2,\pitch,2,\filter,112]);
speed.wait;
Synth(\hats,[\vol,3,\decay,1]);
speed.wait;
Synth(\hats,[\vol,3,\decay,3]);
speed.wait;
Synth(\hats,[\vol,3,\decay,1]);
speed.wait;
Synth(\snare,[\vol,1,\decay,1,\pitch,5,\filter2,0]);
speed.wait;
Synth(\kick,[\vol,4,\decay,2,\pitch,2,\filter,2]);
speed.wait;
Synth(\hats,[\vol,3,\decay,1]);
speed.wait;
Synth(\hats,[\vol,3,\decay,1]);
speed.wait;
Synth(\hats,[\vol,3,\decay,1]);
speed.wait;
Synth(\cymbal);
Synth(\hats,[\vol,3,\decay,1]);
speed.wait;
Synth(\kick,[\vol,4,\decay,2,\pitch,1,\filter,112]);
speed2.wait;
Synth(\snare,[\vol,1,\decay,1,\pitch,5,\filter2,0]);
speed.wait;
Synth(\hats);
speed.wait;
Synth(\hats,[\vol,3,\decay,2]);
speed.wait;
Synth(\cymbal,[\pitch,1.2]);
speed.wait;
});}).play)
Posted by Niadzi at 04:35 0 comments
Friday, 26 February 2010
Synthesising drums & creating SynthDefs for them
({
var sin, pw;
sin= SinOsc.ar(freq: Line.kr(70,40,0.1,doneAction:2),
add: 0, mul: 0.3);
pw= Pulse.ar(freq: 40, add: 0,
mul: EnvGen.ar(Env.perc(0,0.07,0.2)));
Mix.new([sin,pw]);
}.play)
SynthDef(\kick,
{arg vol= 1, decay= 1, pitch= 1, filter= 1;
var sin, pw, kik, kikfilter;
sin= LFTri.ar(freq: Line.kr(40,20,0.1*decay,doneAction:2)*pitch,
add: 0, mul: 0.3*vol);
pw= Pulse.ar(freq: 40, add: 0,
mul: EnvGen.ar(Env.perc(0,0.07,0.3*vol)));
kik= Mix.new([sin,pw]);
kikfilter= LPF.ar(in: kik, freq: XLine.kr(200,30,0.1*decay)*filter);
Out.ar(0, kikfilter)}).load(s);
a= Synth(\kick);
b= Synth(\kick,[\vol,1,\decay,2,\pitch,2,\filter,2]);
c= Synth(\kick,[\vol,1,\decay,4,\pitch,2,\filter,115]);
d= Synth(\kick,[\vol,1,\decay,2,\pitch,9,\filter,10]);
// Snare Drum
SynthDef(\snare,
{arg vol= 1, decay= 1, pitch= 1, filter= 1, filter2= 1;
var noise, filtap, tri, snare, snaref, snaref2;
filtap= EnvGen.ar(Env.perc(0,0.2*decay,0.2*vol,1));
noise= WhiteNoise.ar(mul: filtap, add: Line.kr(-3.5,2,1));
tri= Pulse.ar(freq: Line.kr(60*pitch,228,0.3,doneAction:2),
mul: Line.kr(0.1,0.00,0.1)*vol);
snare= noise+tri;
snaref= HPF.ar(in: snare, freq: Line.kr(800,200,0.22)*filter);
snaref2= LPF.ar(in: snaref, freq: Line.kr(600,1000,0.81)*filter2);
Out.ar(0, snaref)}).play(s)
e= Synth(\snare,[\vol,1,\decay,1.5,\pitch,5]);
f= Synth(\snare,[\vol,1,\decay,1,\pitch,0,\filter,0.19]);
g= Synth(\snare,[\vol,1,\decay,1,\pitch,5,\filter2,0]);
// Hi-hats
SynthDef(\hats,
{arg vol= 1, decay= 1;
var noise, filter, envel, menv;
menv= EnvGen.ar(Env.perc(0.3,0.01,1,4));
noise= WhiteNoise.ar(mul: menv*vol*4, add: Line.kr(0,0,0.03*decay,doneAction:2));
envel= EnvGen.ar(Env.adsr(0,0.4*decay,0.7,0.2,2900));
filter= HPF.ar(in: noise, freq: envel);
Out.ar(0, filter)}).play(s)
h= Synth(\hats,[\vol,3,\decay,1]);
i= Synth(\hats,[\vol,1,\decay,2]);
// Cymbals...(not quite)
SynthDef(\cymbal,
{arg vol= 0.5, decay= 1, pitch= 1;
var sq1, sq2;
sq1= Pulse.ar(freq: Line.kr(623,223,0.2*decay,doneAction:2)*pitch, mul: 0.3*vol);
sq2= Pulse.ar(add: 0,
freq:EnvGen.ar(Env.triangle(0.8*decay,300)),
mul: 0.3*vol);
Out.ar(0, sq1*sq2)}).play(s)
j= Synth(\cymbal);
Posted by Niadzi at 05:31 0 comments
Monday, 15 February 2010
Arrays
a = [1,3,5,7,9];
#[1,3,5,7,9] → fixed array;
a= Array.fill(5, {arg i; i*2+1});
a= Array.with(1,3,5,7,9);
a= Array.series(5,1,2);
x= Array.geom(10,1,2) → [1,2,4,8,16,32,64,128,256,512];
r= Array.rand(10,0,9) → Ten random numbers from 0 - 9;
Modifying/accessing arrays
a = a.add(11); → [1,3,5,7,9,11];
a.put(2,55); → [1,3,55,7,9];
a[2] → 55;
a.scramble → [ 1, 3, 5, 7, 9 ]
a.rotate(2); → [7,9,1,3,5] (rotates array around the given index);(var scr;
a= Array.fill(5, {arg i; i*2+1});
scr = {arg b; b.scramble};
b = scr.value(a);
c = scr.value(b);
a.postln;b.postln;c.postln;)
a; → [false,false,true,true,true];
a.reverse → [9,7,5,3,1];
Example code
({var stars, stars2, stars3, sky, waves, spacetime, heat, shine, shine2, shine3, sparkle;
waves= (Pan2.ar
(in: Resonz.ar
(in: WhiteNoise.ar(0.5), freq: SinOsc.ar(freq:0.5,mul:59,add: 200)),
pos: SinOsc.ar(freq:0.4, mul: 0.3)));
(in: SinOsc.ar(freq: EnvGen.ar(Env.new(
[262,262,131,131,311,311,208,208,
349,349,622,622,523,523,415,415,
1865,1865,1047,1047,622,622,523,
523,262,262,131,131,208,208,131,
131,196,196,208,208,196,196,208,
208,147,65],[0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1,0.1,0.1,0.1,0.1,0.1,0.1,
0.1,0.1,0.1,0.1,0.1,0.3],'step')),
mul: 0.3),
pos:x));
shine2= (Pan2.ar
(in: Saw.ar(freq: EnvGen.ar(Env.new(
[1865,1865,1047,1047,622,622,523,
523,262,262,131,131,208,208,131,
622,622,699,699,587,587,622,622,
523,523,587,587,466,466,392,392,
131,196,196,208,208,196,196,208,
208,147,65],[0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1,0.1,0.1,0.1,0.1,0.1,0.1,
0.1,0.1,0.1,0.1,0.1,0.3],'step')),
mul: 0.3),
pos:x));
(in: Pulse.ar(freq: EnvGen.ar(Env.new(
[49,49,52,52,49,49,52,52,49,49,52,52,
49,49,52,52,49,49,52,52,49,49,52,52,
49,49,52,52,49,49,52,52],[0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1])),
mul: 0.7),
pos:x));
stars= [523, 622, 1047, 1175];
stars2= [587, 466, 784, 8800];
stars3= [699, 294, 1568, 523];
heat= [x,x*0.7,x*2,x];
spacetime= Pulse.ar(freq:Line.kr(880,220,4,doneAction:2),mul:0.3);
sky= Array.fill(4,{arg i;
SinOsc.ar(freq: stars.at(i),
mul: heat.at(i),
add: 0)});
sparkle= HPF.ar(in: shine, freq: Line.kr(10,1000,4));
waves+Mix(sky)+spacetime+sparkle+shine2;}.play)
in this patch i used arrays to assign frequency and volume levels. the different 'stars' variables store different chords that can be changed manually, hopefully ill work out how to do that automatically. i have been experimenting with different code layouts to find a style that is comfortable for me, and also with naming variables. naming variables adds a whole new dimension to it all. i like the idea of making SC poetry...supercollider forces you to have a totally different perspective on how music and sound is created, and its really inspiring. it turns all of the emotional impact of music into numbers, which are infinite....so theres endless creative possibilities to be explored!
the swingOSC GUI stuff looks a bit lame but there seems to be a few people using it with processing, and the flosc project attempts to integrate supercollider with flash. but first i am going to start on my coursework...
Cool Stuff
http://peabody.sapp.org/class/st2/lab/notehz/ - frequency/pitch chart
http://www.benchun.net/flosc/
Posted by Niadzi at 12:56 0 comments
Hello World
Previous blog posts are at http://superkaleidoscope.wordpress.com/.
Posted by Niadzi at 06:18 0 comments