X-Git-Url: https://scm.cri.minesparis.psl.eu/git/minwii.git/blobdiff_plain/346a9b8e1fcfe30629f0d1ee4675e9e8f89890cf..4c4732c6ed8cb0aaa70fb2d4c6e5a958868c5349:/src/mxmMidi/example_transpose_octave.py?ds=sidebyside diff --git a/src/mxmMidi/example_transpose_octave.py b/src/mxmMidi/example_transpose_octave.py deleted file mode 100644 index 57dbbff..0000000 --- a/src/mxmMidi/example_transpose_octave.py +++ /dev/null @@ -1,40 +0,0 @@ -from MidiOutFile import MidiOutFile -from MidiInFile import MidiInFile - -""" -This is an example of the smallest possible type 0 midi file, where -all the midi events are in the same track. -""" - - -class Transposer(MidiOutFile): - - "Transposes all notes by 1 octave" - - def _transp(self, ch, note): - if ch != 9: # not the drums! - note += 12 - if note > 127: - note = 127 - return note - - - def note_on(self, channel=0, note=0x40, velocity=0x40): - note = self._transp(channel, note) - MidiOutFile.note_on(self, channel, note, velocity) - - - def note_off(self, channel=0, note=0x40, velocity=0x40): - note = self._transp(channel, note) - MidiOutFile.note_off(self, channel, note, velocity) - - -out_file = 'midiout/transposed.mid' -midi_out = Transposer(out_file) - -#in_file = 'midiout/minimal_type0.mid' -#in_file = 'test/midifiles/Lola.mid' -in_file = 'test/midifiles/tennessee_waltz.mid' -midi_in = MidiInFile(midi_out, in_file) -midi_in.read() -