View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

Rhythm Collages

Example Rhythm Collage

We create about a dozen small sounds of 0.5 to 1.0 seconds in length: A finger snap, a hand clap, a book slam, a stomp, a shuffle, an "OW!", and a "rest" (silence). The assignment is to put together at least four of these into a repeating pattern of at least 15 seconds in length. So, you can create a "measure" by assembling:
snap-snap-slam-rest
Then string three of these together.
snap-snap-slam-rest-snap-snap-slam-rest-snap-snap-slam-rest
Of course, you can also create a couple of different measures, and string them together, perhaps in an alternating pattern.

The idea for such an assignment would be to require:

shortsounds.zip
Each filename indicates the length of the sound:

Result of the below example: mysoundpatterncollage.wav

Notice that the code is actually quite simple, though it looks long. It's just the same copy loop over, and over, and over – changing the source and target each time. It's basically practice on iteration and copying. Lots of such practice, but with a cool result.

def makeCollage():
  sound1 = makeEmptySound(2)
  sound2 = makeEmptySound(2)
  whole = makeEmptySound(12)
  ## Copy into sound1, twice
  ## Clap, clave, clink, snap, clave, clink, snap, clap
  ## .25 + .05 + .10 + .10 + .05 + .10 + .10 + .25
  targetIndex = 1
  for twice in range(1,3): #two times
    source = makeSound(getMediaPath("clap-q.wav"))
    for srcIndex in range(1,getLength(source)):
      v = getSampleValueAt(source,srcIndex)
      setSampleValueAt(sound1,targetIndex,v)
      targetIndex=targetIndex + 1
    source = makeSound(getMediaPath("clave-twentieth.wav"))
    for srcIndex in range(1,getLength(source)):
      v = getSampleValueAt(source,srcIndex)
      setSampleValueAt(sound1,targetIndex,v)
      targetIndex=targetIndex + 1
    source = makeSound(getMediaPath("clink-tenth.wav"))
    for srcIndex in range(1,getLength(source)):
      v = getSampleValueAt(source,srcIndex)
      setSampleValueAt(sound1,targetIndex,v)
      targetIndex=targetIndex + 1
    source = makeSound(getMediaPath("snap-tenth.wav"))
    for srcIndex in range(1,getLength(source)):
      v = getSampleValueAt(source,srcIndex)
      setSampleValueAt(sound1,targetIndex,v)
      targetIndex=targetIndex + 1
    source = makeSound(getMediaPath("clave-twentieth.wav"))
    for srcIndex in range(1,getLength(source)):
      v = getSampleValueAt(source,srcIndex)
      setSampleValueAt(sound1,targetIndex,v)
      targetIndex=targetIndex + 1
    source = makeSound(getMediaPath("clink-tenth.wav"))
    for srcIndex in range(1,getLength(source)):
      v = getSampleValueAt(source,srcIndex)
      setSampleValueAt(sound1,targetIndex,v)
      targetIndex=targetIndex + 1
    source = makeSound(getMediaPath("snap-tenth.wav"))
    for srcIndex in range(1,getLength(source)):
      v = getSampleValueAt(source,srcIndex)
      setSampleValueAt(sound1,targetIndex,v)
      targetIndex=targetIndex + 1
    source = makeSound(getMediaPath("clap-q.wav"))
    for srcIndex in range(1,getLength(source)):
      v = getSampleValueAt(source,srcIndex)
      setSampleValueAt(sound1,targetIndex,v)
      targetIndex=targetIndex + 1
  ## Sound2 will be 1/2 second of silence, one second splash,
  ## and 1/2 second of silence
  ## We can assume 22050 sampling rate
  targetIndex = 11025
  source=makeSound(getMediaPath("splasha-1.wav"))
  for srcIndex in range(1,getLength(source)):
    v = getSampleValueAt(source,srcIndex)
    setSampleValueAt(sound2,targetIndex,v)
    targetIndex=targetIndex + 1
  ## Make the Whole Sound
  ## We'll do sound1 twice, then sound2, and repeat that twice
  targetIndex = 1
  for twice in range(1,3): #two times
    source = sound1
    for srcIndex in range(1,getLength(source)):
      v = getSampleValueAt(source,srcIndex)
      setSampleValueAt(whole,targetIndex,v)
      targetIndex=targetIndex + 1
    source = sound1
    for srcIndex in range(1,getLength(source)):
      v = getSampleValueAt(source,srcIndex)
      setSampleValueAt(whole,targetIndex,v)
      targetIndex=targetIndex + 1
    source = sound2
    for srcIndex in range(1,getLength(source)):
      v = getSampleValueAt(source,srcIndex)
      setSampleValueAt(whole,targetIndex,v)
      targetIndex=targetIndex + 1
  play(whole)
  return whole


Links to this Page