fix problèmes d'aligement du curseur avec le pointeur.
[minwii.git] / src / mxmMidi / example_transpose_octave.py
1 from MidiOutFile import MidiOutFile
2 from MidiInFile import MidiInFile
3
4 """
5 This is an example of the smallest possible type 0 midi file, where
6 all the midi events are in the same track.
7 """
8
9
10 class Transposer(MidiOutFile):
11
12 "Transposes all notes by 1 octave"
13
14 def _transp(self, ch, note):
15 if ch != 9: # not the drums!
16 note += 12
17 if note > 127:
18 note = 127
19 return note
20
21
22 def note_on(self, channel=0, note=0x40, velocity=0x40):
23 note = self._transp(channel, note)
24 MidiOutFile.note_on(self, channel, note, velocity)
25
26
27 def note_off(self, channel=0, note=0x40, velocity=0x40):
28 note = self._transp(channel, note)
29 MidiOutFile.note_off(self, channel, note, velocity)
30
31
32 out_file = 'midiout/transposed.mid'
33 midi_out = Transposer(out_file)
34
35 #in_file = 'midiout/minimal_type0.mid'
36 #in_file = 'test/midifiles/Lola.mid'
37 in_file = 'test/midifiles/tennessee_waltz.mid'
38 midi_in = MidiInFile(midi_out, in_file)
39 midi_in.read()
40