Wednesday, February 11, 2009

More drum machine

I've been fiddling with my maliciously inept drum machine a bit more and using a couple of the enormous selection of pattern classes I've added some new features. 

A lot of real drum machines both hardware and software have a 'swing' or 'shuffle' which add a bit of syncopation though I suspect most of them do it in a more sophisticated way than what I've done here.   

e = Pwhite (0.14, 0.16);

 \dur, e,

I've used a Pwhite pattern to randomly select the \dur interval. 

The Pwhite pattern randomly generates values from a range provided by the first two parameters and repeats this a number of times set by the third value entered, with inf being the default. Sticking this into my drum sequence means that the interval between each drum sound will be random, givning it a possibly more 'organic' feel. Or maybe just making it sound wonky.

I've seen some software synths that let the user generate random patterns, I've done something similar using a Pwrand.

 f = Pwrand ([0, 1], [75, 25].normalizeSum, inf);

 \bassLevel, Pseq ([f], inf), 

 A Pwrand pattern generates random numbers from a list with a weighted probability. The above line generates a pattern with a 25% chance of each step having a drum sound  and a 75% chance of being silent.

Pwrand takes two arrays as arguments, the first one being the list of numbers to select randomly from, the second one being a list of probabilities, which should add up to one. Passing the second array a .normaliseSum message neatly side steps my poor mental arithmetic and automatically normalises the array elements to sum to one. Being able to weight the results makes the resulting pattern sound more rhythmic, without long silences or rolls that an unweighted probability would lead to.   

Here's the full pattern with these two bits added. 

 (

 a = Pseq ([1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]);
 b = Pseq ([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0]);
 c = Pseq ([0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0]);
 d = Pseq ([0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1]); 
 e = Pwhite (0.14, 0.16);
 f = Pwrand ([0, 1], [75, 25].normalizeSum, inf);
 
 
 p = Pbind(
  \instrument, \drums,
  \dur, e,
  \bassLevel, Pseq ([f], inf), 
  \snareLevel, Pseq ([b], inf),
  \hatLevel, Pseq ([f], inf),  
  \tomLevel, Pseq ([d], inf)
   
  ).play;
   
   
  )

1 comment: