Example #1
0
 def _calc_velocity(self, hand, slide=False):
     if slide:
         velocity = int(
             scale_constrain(kinect.speed_piano[hand][global_vars.X], 0,
                             150, 10, 100))
     else:
         velocity = int(
             scale_constrain(kinect.speed_piano[hand][global_vars.Y], 0,
                             150, 10, 127))
     return velocity
Example #2
0
 def _play(self):
     global beat
     
     smallest_area = 10
     for dur, wait in random.choice([
                                     [(4,5), (1,4)], 
                                     [(2,2),(1,4),(2,3)],
                                     [(3,3),(1,1),(1,2),(1,2),(1,2)]
                                     ]):
         
         area = kinect.area
         
         if area > 0.5:
             velocity = int(scale_constrain(area, 0, 1, 10, 127))
             
             beat = max(min((30 - kinect.speed_ramp) / 120., 0.25), 0.03)
             if beat == 0.03:
                 self.shortcount += 1
                 if self.shortcount > 20:
                     events.send('stop_all_sections')
             else:
                 self.shortcount = 0
             for pitch in crazychord:
                 #self._out(pitch, dur*beat, velocity, 2)
                 self._out(pitch, dur*beat, velocity, 2, 'crazychord')
             time.sleep(wait * beat*1.)
         else:
             time.sleep(beat)
Example #3
0
    def _play(self):
        global beat

        smallest_area = 10
        for dur, wait in random.choice([[(4, 5), (1, 4)],
                                        [(2, 2), (1, 4), (2, 3)],
                                        [(3, 3), (1, 1), (1, 2), (1, 2),
                                         (1, 2)]]):

            area = kinect.area

            if area > 0.5:
                velocity = int(scale_constrain(area, 0, 1, 10, 127))

                beat = max(min((30 - kinect.speed_ramp) / 120., 0.25), 0.03)
                if beat == 0.03:
                    self.shortcount += 1
                    if self.shortcount > 20:
                        events.send('stop_all_sections')
                else:
                    self.shortcount = 0
                for pitch in crazychord:
                    #self._out(pitch, dur*beat, velocity, 2)
                    self._out(pitch, dur * beat, velocity, 2, 'crazychord')
                time.sleep(wait * beat * 1.)
            else:
                time.sleep(beat)
Example #4
0
    def _calculate(self):
        smoothness = Smoothness.retrieve()
        while self.calculate:
            lh = smoothness.value('lefthand')
            rh = smoothness.value('righthand')

            self.swing = round(
                scale_constrain(lh, 0, 150, 0.5, 0.7) * 100) * 0.01
            self.jaggedness = scale_constrain(rh, 0, 150, 0., 1.)
            self.snapshots.append((lh + rh) * .5)
            self.snapshots = self.snapshots[-5:]

            if self.snapshots[0] <= .5 and self.snapshots[-1] > .5:
                midi.setSustain(False)
            elif self.snapshots[0] >= .5 and self.snapshots[-1] < .5:
                midi.setSustain(True)
            time.sleep(0.1)
Example #5
0
 def _play(self):
     events.wait_for('ictus')
     height = kinect.get_coord('righthand')[1]
     index = int(height / 70)
     self.index = index
     self.velocity = (scale_constrain(self.ictus.avg_magnitude, 15, 130, 10, 100) * .5
                      + self.velocity * .5)
     
     pitches = self.get_chord()
     self.set_pitches(pitches, self.velocity)
     
     self.glissando.amt = 6/max(6,self.ictus.magnitude) * 0.1 # faster gliss with faster ictus
     self.glissando.chord([p-12 for p in pitches], 3, min(self.velocity+15,127))
Example #6
0
    def _play(self):
        events.wait_for('ictus')
        height = kinect.get_coord('righthand')[1]
        index = int(height / 70)
        self.index = index
        self.velocity = (
            scale_constrain(self.ictus.avg_magnitude, 15, 130, 10, 100) * .5 +
            self.velocity * .5)

        pitches = self.get_chord()
        self.set_pitches(pitches, self.velocity)

        self.glissando.amt = 6 / max(
            6, self.ictus.magnitude) * 0.1  # faster gliss with faster ictus
        self.glissando.chord([p - 12 for p in pitches], 3,
                             min(self.velocity + 15, 127))
Example #7
0
 def _get_pitch_indices(self, hand, x1, x2):
     note_spacing = self.octave_spacing / len(self.pitches[hand])
     index1 = int(scale_constrain(x1, -700, 700, 0, 1400 / note_spacing))
     index2 = int(scale_constrain(x2, -700, 700, 0, 1400 / note_spacing))
     return range(index1, index2 + 1)
Example #8
0
 def _calc_velocity(self, hand, slide=False):
     if slide:
         velocity = int(scale_constrain(kinect.speed_piano[hand][global_vars.X], 0, 150, 10, 100))
     else:
         velocity = int(scale_constrain(kinect.speed_piano[hand][global_vars.Y], 0, 150, 10, 127))
     return velocity
Example #9
0
 def _get_pitch_indices(self, hand, x1, x2):
     note_spacing = self.octave_spacing / len(self.pitches[hand])
     index1 = int(scale_constrain(x1, -700, 700, 0, 1400 / note_spacing))
     index2 = int(scale_constrain(x2, -700, 700, 0, 1400 / note_spacing))
     return range(index1, index2 + 1)