def play(): # this really isn't endless, because we've engaged a global stop timer. # but if you change 10 to 100, it will play for 100 seconds. Make note # of the use of Endlessly here to see that data sources are not exhausted. output = Performance(bpm=120, stop_seconds=10) # play the two scales for 7 beats each, and then keep using those scales scale1 = scale("c6 major") scale2 = scale("c6 minor") scale_choices = [dict(scale=scale1, beats=7), dict(scale=scale2, beats=7)] source = ScaleSource(scales=Endlessly(scale_choices)) # note: the syntax is simpler to just play ONE scale repeatedly, and you'll see this # done more in future examples. Because we don't need to stay in one scale for N beats # before moving on to another, we don't need all the extra info. # source = ScaleSource(scales=scale1) # the scale follower will play the first 7 notes in each scale, whatever the current # scale is. follower = ScaleFollower(lengths=7, channel=1) source.chain([follower, output]) conductor = Conductor(signal=[source], performance=output) conductor.start()
def play(): output = Performance(bpm=120, stop_seconds=10) # specify that we are going to be playing the c6 major scale for a very long # time scale1 = scale("c6 major") source = ScaleSource(scales=[ dict(scale=scale1, beats=9999) ]) # but just play the first 7 notes in the scale follower = ScaleFollower(lengths=[ 7 ], channel=1) source.chain([follower, output]) # begin performance conductor = Conductor(signal=[source], performance=output) conductor.start()
def play(): # playing all the power chords in a chromatic scale. output = Performance(bpm=120, stop_seconds=10) # play the two scales for 7 beats each, and then keep using those scales scale1 = scale("c4 chromatic") scale_choices = dict(scale=scale1, beats=12) source = ScaleSource(scales=scale_choices) follower = ScaleFollower(lengths=12) chordify = Chordify(types="power", channel=1) source.chain([follower, chordify, output]) conductor = Conductor(signal=[source], performance=output) conductor.start()
def play(): output = Performance(bpm=120, stop_seconds=10) scale1 = scale("c6 major") scale2 = scale("c6 minor") # the performance will use the c6 major scale for 7 beats, then the c6 minor scale for 7 beats source = ScaleSource( scales=[dict(scale=scale1, beats=7), dict(scale=scale2, beats=7)]) # the scale follower will play the first 7 notes in each scale follower = ScaleFollower(lengths=[7, 7], channel=1) source.chain([follower, output]) conductor = Conductor(signal=[source], performance=output) conductor.start()
def play(): # example 05 was "playing all the power chords in a chromatic scale". # let's modify the example very slightly using Subdivide. # normally the conductor sends down quarter notes. Let's alternate # playing quarter notes and sixteenth notes. output = Performance(bpm=120, stop_seconds=10) # play the two scales for 7 beats each, and then keep using those scales source = ScaleSource(scales=scale("c4 chromatic")) follower = ScaleFollower(lengths=12) # pay attention to this part - nothing else has changed subdivide = Subdivide(splits=Endlessly([1, 4])) chordify = Chordify(types="power", channel=1) source.chain([follower, subdivide, chordify, output]) conductor = Conductor(signal=[source], performance=output) conductor.start()
def test_simple_band(self): output = Performance(bpm=120, stop_seconds=10) scale1 = scale("c6 major") scale2 = scale("c6 minor") source = ScaleSource( scales=[dict(scale=scale1, beats=7), dict(scale=scale2, beats=7)]) subdivide = Subdivide(splits=[4]) roman = Roman(symbols="1 2 3 4 I IV V iii".split(), channel=1) follower = ScaleFollower(lengths=[7]) chordify = Chordify(types=['power']) shift = Transpose(octaves=[-3], channel=2) source.chain([subdivide, roman, output]) source.chain([follower, chordify, shift, output]) conductor = Conductor(signal=[source], performance=output) conductor.start()
def play(): # example 05 was "playing all the power chords in a chromatic scale". # example 06 used subdivide to chop up alternating measures with faster notes # now lets alternately transpose every 2nd measure up an octave # and every 3rd measure down an octave output = Performance(bpm=120, stop_seconds=10) source = ScaleSource(scales=scale("c4 chromatic")) follower = ScaleFollower(lengths=Endlessly([12])) subdivide = Subdivide(splits=Endlessly([1,4])) # pay attention to this part - nothing else has changed transpose = Transpose(octaves=Endlessly([0,1,-1])) chordify = Chordify(types="power", channel=1) source.chain([follower, subdivide, transpose, chordify, output]) conductor = Conductor(signal=[source], performance=output) conductor.start()
def play(): # previous examples showed a couple of instruments, lets go back to one # instrument to showcase just the arpeggiator. # WARNING - may not make sense if you haven't used any hardware or # software arpeggiators. output = Performance(bpm=120, stop_seconds=10) scale1 = scale("c4 major") scale_choices = [dict(scale=scale1, beats=7)] # refresher - CAMP is generator based, and performances stop when there is # nothing left to do OR stop_seconds is reached. # by not wrapping the scale choices in "Endlessly", we're allowing this example # to terminate when the scale is done. This example will play 24 quarter note # beats and STOP. But the way the arpeggiator is coded, there will really be # 24*4 = 96 sixteenth notes, of which 3/4s of them will be played with audible notes # and the rests will be, ahem, rests. # refresher - the MIDI channel number can be set anywhere in the graph, as well as overrided # anywhere in the graph. Leaving it off here on ScaleSource and setting it on the # Arp would do exactly the same thing. Leaving off the channel will cause an exception. source = ScaleSource(scales=(scale_choices), channel=1) # refresher - the scale follower will take note of the current scale and # play the scale for a given number of notes in order. We could be more # creative by using Roman() instead to select particular notes (or chords) # in the scale. follower = ScaleFollower(lengths=Endlessly([7])) # refresher, the roman usage looks very similar: # roman = Roman(symbols="1 2 3 4 5 6 7".split()) # really, there's little use for ScaleFollower in the real world, but it was # getting lonely and wanted to be featured here. It's a bit more efficient # but I doubt that matters. # NOW FOR THE FUN PART. # ok, here's the arpeggiator. # in this example, we take the currently selected note from the scale # play that note, then the notes 4 and 9 semitones up - a major chord. # every single beat will be divided into 4 parts by the arp due to 'splits' # however every 4th note is also a REST. # # see this table: # # TRIGGER: | C4 ~~~~~~~~~~~~ | D4 ~~~~~~~~~ | ... # ---------+-----------------+--------------+ # RESTS: | N N N Y | N N N Y | # SEMI: | +0 +3 +8 - | +0 +3 +8 | # OCTAVES: | +2 -2 0 0 | +2 -2 0 0 | # ---------+-----------------+--------------+ # PLAY: | C6 E2 G4 - | D6 Gb2 A4 - | # # more creative things can be done by having the semitones # and rest patterns be different lengths, and so on, as well as using # the 'free' mode with those uneven lengths. arp = Arp(semitones=Endlessly([0, 3, 8, 0]), octaves=Endlessly([2, -2, 0, 0]), splits=Endlessly([4]), rests=Endlessly([0, 0, 0, 1])) # HOMEWORK: add "mode=free" to the Arp constructor above and experiment # with octaves, splits, rests, and semitones of different values and array # lengths. # POP QUIZ: what happens if we remove Endlessly from some of the expressions above? # WHY? # the chain here is simple - scale source feeds note source, which in turn # feeds the arp. source.chain([follower, arp, output]) # kick out the jams conductor = Conductor(signal=[source], performance=output) conductor.start()