Beispiel #1
0
class BeatSection(Section):
    polys = None
    fader = None

    def _setup(self):
        events.listen('facing_front', self.front_shift)
        events.listen('facing_back', self.back_shift)
        self.fader = Gain()
        self.fader.vel_multiplier = 0.5
        route(self.fader, midi)

    def _start(self):
        self.polys = []
        for _ in range(5):
            p = Polycrystalline(60)
            #p.front_chord = [-3+octave*12 for octave in 1,2,7,8]
            p.front_chord = [0 + octave * 12 for octave in 1, 2, 7, 8]
            p.back_chord = [0 + octave * 12 for octave in 1, 2, 7, 8]
            p.pitch_map = PitchMap(p.front_chord, variance=50)
            route(p, self.fader)
            self.polys.append(p)
            p.play()

    def _stop(self):
        sprout(self._fade_out)
        events.unlisten('facing_front', self.front_shift)
        events.unlisten('facing_back', self.back_shift)

    def _fade_out(self):
        self.fader.fade(1., 0., 10)
        time.sleep(10)
        for p in self.polys:
            p.stop()

    def front_shift(self):
        if type(self.polys) is list:
            front_chord = [
                random.choice((-3, -1, 2, 4, 7)) + octave * 12
                for octave in 1, 2, 7, 8
            ]
            for p in self.polys:
                p.front_chord = front_chord

    def back_shift(self):
        if type(self.polys) is list:
            back_chord = [
                random.choice((-4, -2, 0, 1, 3)) + octave * 12
                for octave in 1, 2, 7, 8
            ]
            for p in self.polys:
                p.back_chord = back_chord
Beispiel #2
0
class BeatSection(Section):
    polys = None
    fader = None
    def _setup(self):
        events.listen('facing_front', self.front_shift)
        events.listen('facing_back', self.back_shift)
        self.fader = Gain()
        self.fader.vel_multiplier = 0.5
        route(self.fader, midi)
    
    def _start(self):
        self.polys = []
        for _ in range(5):
            p = Polycrystalline(60)
            #p.front_chord = [-3+octave*12 for octave in 1,2,7,8]
            p.front_chord = [0+octave*12 for octave in 1,2,7,8]
            p.back_chord = [0+octave*12 for octave in 1,2,7,8]
            p.pitch_map = PitchMap(p.front_chord, variance=50)
            route(p,self.fader)
            self.polys.append(p)
            p.play()
    
    def _stop(self):
        sprout(self._fade_out)
        events.unlisten('facing_front', self.front_shift)
        events.unlisten('facing_back', self.back_shift)
    
    def _fade_out(self):
        self.fader.fade(1., 0., 10)
        time.sleep(10)
        for p in self.polys:
            p.stop()
    
    def front_shift(self):
        if type(self.polys) is list:
            front_chord = [random.choice((-3, -1, 2, 4, 7))+octave*12 for octave in 1,2,7,8]
            for p in self.polys:
                p.front_chord = front_chord

    def back_shift(self):
        if type(self.polys) is list:
            back_chord = [random.choice((-4, -2, 0, 1, 3))+octave*12 for octave in 1,2,7,8]
            for p in self.polys:
                p.back_chord = back_chord
Beispiel #3
0
class PolycrystallineSection(Section):
    prev_chord_index = -1

    def _setup(self):
        #events.listen('switch_top_lefthand', self.toggle)
        #events.listen('switch_left', self.left_hit)
        #events.listen('switch_right', self.right_hit)
        self.fader = Gain()
        self.polys = []

    def _start(self):
        self.fader.fade(0., 1., 15)
        self.octaves = Octaves(span=2)
        route(self.fader, self.octaves)
        route(self.octaves, midi)
        self.polys = []
        events.listen('facing_back', self.chord_change)
        events.listen('facing_front', self.chord_change)
        for _ in range(4):
            p = Polycrystalline(60)
            route(p, self.fader)
            self.polys.append(p)
            p.play()
        #sprout(self._chord_change)

    def _stop(self):
        sprout(self._fade_out)
        events.unlisten('facing_back', self.chord_change)
        events.unlisten('facing_front', self.chord_change)

    def _fade_out(self):
        self.fader.fade(1., 0., 10)
        time.sleep(10)
        for p in self.polys:
            p.stop()

    def chord_change(self):
        i = self.prev_chord_index
        while i == self.prev_chord_index:
            i = random.choice(range(len(self.polys[0].pitch_maps)))

        for p in self.polys:
            p.pitch_map = p.pitch_maps[i]
        self.prev_chord_index = i
Beispiel #4
0
class PolycrystallineSection(Section):
    prev_chord_index = -1
    def _setup(self):
        #events.listen('switch_top_lefthand', self.toggle)
        #events.listen('switch_left', self.left_hit)
        #events.listen('switch_right', self.right_hit)
        self.fader = Gain()
        self.polys = []
    
    def _start(self):
        self.fader.fade(0., 1., 15)
        self.octaves = Octaves(span=2)
        route(self.fader, self.octaves)
        route(self.octaves, midi)
        self.polys = []
        events.listen('facing_back', self.chord_change)
        events.listen('facing_front', self.chord_change)
        for _ in range(4):
            p = Polycrystalline(60)
            route(p, self.fader)
            self.polys.append(p)
            p.play()
        #sprout(self._chord_change)
    
    def _stop(self):
        sprout(self._fade_out)
        events.unlisten('facing_back', self.chord_change)
        events.unlisten('facing_front', self.chord_change)
    
    def _fade_out(self):
        self.fader.fade(1., 0., 10)
        time.sleep(10)
        for p in self.polys:
            p.stop()
    
    def chord_change(self):
        i = self.prev_chord_index
        while i ==self.prev_chord_index:
            i = random.choice(range(len(self.polys[0].pitch_maps)))
        
        for p in self.polys:
            p.pitch_map = p.pitch_maps[i]
        self.prev_chord_index = i
Beispiel #5
0
    def __init__(self, humanize=None, echo=None, gain=None):
        if humanize is not None:
            self.humanize = humanize
        else:
            self.humanize = Humanize(delay_max=0.01, velocity_max=50)

        if echo is not None:
            self.echo = echo
        else:
            self.echo = Echo(decay=0.85, delay=0.2, decay_variability=0.1)

        if gain is not None:
            self.gain = gain
        else:
            self.gain = Gain()
            self.gain.fade(0, 1, 10)

        self.notes = (4, 5, 7, 11, 12)
        self.octaves = (2, 3, 4, 6, 7, 8)
Beispiel #6
0
class HumanizedRepetition(Autonomous):
    humanize = None
    echo = None
    gain = None

    def __init__(self, humanize=None, echo=None, gain=None):
        if humanize is not None:
            self.humanize = humanize
        else:
            self.humanize = Humanize(delay_max=0.01, velocity_max=50)

        if echo is not None:
            self.echo = echo
        else:
            self.echo = Echo(decay=0.85, delay=0.2, decay_variability=0.1)

        if gain is not None:
            self.gain = gain
        else:
            self.gain = Gain()
            self.gain.fade(0, 1, 10)

        self.notes = (4, 5, 7, 11, 12)
        self.octaves = (2, 3, 4, 6, 7, 8)

    def _play(self):
        midi.setSustain(True)

        route(self.echo, self.humanize)
        route(self.humanize, self.gain)
        route(self.gain, midi)

        note_choices = [
            x + octave * 12 for x in (4, 5, 7, 11, 12)
            for octave in (1, 2, 3, 4, 5, 6, 7, 8)
        ]

        while self.playing:
            t = time.time()
            self.echo.note(random.choice(note_choices), 0.15, 40)
            time.sleep(random.choice((0.2, 0.4)) - time.time() + t)
Beispiel #7
0
class HumanizedRepetition(Autonomous):
    humanize = None
    echo = None
    gain = None
    
    def __init__(self, humanize=None, echo=None, gain=None):
        if humanize is not None:
            self.humanize = humanize
        else:
            self.humanize = Humanize(delay_max = 0.01, velocity_max = 50)
        
        if echo is not None:
            self.echo = echo
        else:
            self.echo = Echo(decay=0.85, delay=0.2, decay_variability=0.1)
        
        if gain is not None:
            self.gain = gain
        else:
            self.gain = Gain()
            self.gain.fade(0,1,10)
        
        self.notes = (4,5,7,11,12)
        self.octaves = (2,3,4,6,7,8)
        
    
    def _play(self):
        midi.setSustain(True)
        
        route(self.echo, self.humanize)
        route(self.humanize, self.gain)
        route(self.gain, midi)
        
        note_choices = [x + octave*12 for x in (4,5,7,11,12) for octave in (1,2,3,4,5,6,7,8)]
        
        while self.playing:
            t = time.time()
            self.echo.note(random.choice(note_choices), 0.15,40)
            time.sleep(random.choice((0.2,0.4)) - time.time() + t)
Beispiel #8
0
class RhythmSection(Section):
    rhythms = None
    def _setup(self):
        self.fader = Gain()
        route(self.fader, midi)
        self.rhythms = []
    
    def _start(self):
        for pitch in 24,48,84,96:
            midi.lockPitch(pitch, 'rhythm')
            r = Rhythm(pitch=pitch, beat=0.125)
            r.loud = 50
            r.quiet = 20
            route(r, self.fader)
            self.rhythms.append(r)
    
        self.fader.fade(1.5, 1., 10)
        for r in self.rhythms:
            r.start()
    
    def _stop(self):
        for r in self.rhythms:
            r.stop()
Beispiel #9
0
class RhythmSection(Section):
    rhythms = None

    def _setup(self):
        self.fader = Gain()
        route(self.fader, midi)
        self.rhythms = []

    def _start(self):
        for pitch in 24, 48, 84, 96:
            midi.lockPitch(pitch, 'rhythm')
            r = Rhythm(pitch=pitch, beat=0.125)
            r.loud = 50
            r.quiet = 20
            route(r, self.fader)
            self.rhythms.append(r)

        self.fader.fade(1.5, 1., 10)
        for r in self.rhythms:
            r.start()

    def _stop(self):
        for r in self.rhythms:
            r.stop()
Beispiel #10
0
 def __init__(self, humanize=None, echo=None, gain=None):
     if humanize is not None:
         self.humanize = humanize
     else:
         self.humanize = Humanize(delay_max = 0.01, velocity_max = 50)
     
     if echo is not None:
         self.echo = echo
     else:
         self.echo = Echo(decay=0.85, delay=0.2, decay_variability=0.1)
     
     if gain is not None:
         self.gain = gain
     else:
         self.gain = Gain()
         self.gain.fade(0,1,10)
     
     self.notes = (4,5,7,11,12)
     self.octaves = (2,3,4,6,7,8)
Beispiel #11
0
 def _setup(self):
     events.listen('facing_front', self.front_shift)
     events.listen('facing_back', self.back_shift)
     self.fader = Gain()
     self.fader.vel_multiplier = 0.5
     route(self.fader, midi)
Beispiel #12
0
 def _setup(self):
     self.fader = Gain()
     route(self.fader, midi)
     self.rhythms = []
Beispiel #13
0
 def _setup(self):
     #events.listen('switch_top_lefthand', self.toggle)
     #events.listen('switch_left', self.left_hit)
     #events.listen('switch_right', self.right_hit)
     self.fader = Gain()
     self.polys = []
Beispiel #14
0
 def _setup(self):
     events.listen('facing_front', self.front_shift)
     events.listen('facing_back', self.back_shift)
     self.fader = Gain()
     self.fader.vel_multiplier = 0.5
     route(self.fader, midi)
Beispiel #15
0
 def _setup(self):
     self.fader = Gain()
     route(self.fader, midi)
     self.rhythms = []
Beispiel #16
0
 def _setup(self):
     #events.listen('switch_top_lefthand', self.toggle)
     #events.listen('switch_left', self.left_hit)
     #events.listen('switch_right', self.right_hit)
     self.fader = Gain()
     self.polys = []