コード例 #1
0
 def retune_note(self, octave):
     """Retune the given note without playing it."""
     # Get the tuning event for this coordinate
     tuning, note_on, note_off = tonal_space_note_events(
                                     (self.coord[0], self.coord[1], octave),
                                     0, 0)
     self.sequencer.send_event(tuning)
コード例 #2
0
 def toggle_note(self, octave):
     """Start or stop a note playing"""
     # Get the events (note on and off) for this coordinate
     tuning, note_on, note_off = tonal_space_note_events(
                                     (self.coord[0], self.coord[1], octave),
                                     0, 0)
     if octave in self.playing:
         self.playing.remove(octave)
         del self.parent_window.playing_midi_notes[note_on.pitch]
         self.sequencer.send_event(note_off)
         # If no more notes playing, remove ourselves from the global playing record
         if len(self.playing) == 0:
             self.parent_window.playing_cells.remove(self)
     else:
         # If another instance of this ET note is playing, stop it, because 
         #  it will get retuned by this tuning event :-(
         if note_on.pitch in self.parent_window.playing_midi_notes:
             oldcell,oldoctave = self.parent_window.playing_midi_notes[note_on.pitch]
             oldcell.toggle_note(oldoctave)
         # Start the note playing
         self.playing.append(octave)
         if self.parent_window.equal_temperament:
             # Return the note to its default tuning (ET)
             tuning = single_note_tuning_event(
                                 [(note_on.pitch, note_on.pitch, 0)])
         self.sequencer.send_event(tuning)
         self.sequencer.send_event(note_on)
         # Note globally that we're playing
         self.parent_window.playing_cells.add(self)
         self.parent_window.playing_midi_notes[note_on.pitch] = (self, octave)
         
     self.refresh_playing()