def testSysEx(self): MyMIDI = MIDIFile(1) MyMIDI.addSysEx(0,0, 0, struct.pack('>B', 0x01)) MyMIDI.close() self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type, 'SysEx') self.assertEquals(get_byte(MyMIDI, 0, 0), 0x00) self.assertEquals(get_byte(MyMIDI, 0, 1), 0xf0) self.assertEquals(get_byte(MyMIDI, 0, 2), 3) self.assertEquals(get_byte(MyMIDI, 0, 3), 0x00) self.assertEquals(get_byte(MyMIDI, 0, 4), 0x01) self.assertEquals(get_byte(MyMIDI, 0, 5), 0xf7)
def testSysEx(self): MyMIDI = MIDIFile(1) MyMIDI.addSysEx(0, 0, 0, struct.pack('>B', 0x01)) MyMIDI.close() self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type, 'SysEx') self.assertEquals(get_byte(MyMIDI, 0, 0), 0x00) self.assertEquals(get_byte(MyMIDI, 0, 1), 0xf0) self.assertEquals(get_byte(MyMIDI, 0, 2), 3) self.assertEquals(get_byte(MyMIDI, 0, 3), 0x00) self.assertEquals(get_byte(MyMIDI, 0, 4), 0x01) self.assertEquals(get_byte(MyMIDI, 0, 5), 0xf7)
def testDeinterleaveNotes(self): MyMIDI = MIDIFile(1) MyMIDI.addNote(0, 0, 100, 0, 2, 100) MyMIDI.addNote(0, 0, 100, 1, 2, 100) MyMIDI.close() self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type, 'NoteOn') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].time, 0) self.assertEquals(MyMIDI.tracks[0].MIDIEventList[1].type, 'NoteOff') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[1].time, 128) self.assertEquals(MyMIDI.tracks[0].MIDIEventList[2].type, 'NoteOn') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[2].time, 0) self.assertEquals(MyMIDI.tracks[0].MIDIEventList[3].type, 'NoteOff') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[3].time, 256)
def testUniversalSysEx(self): MyMIDI = MIDIFile(1) MyMIDI.addUniversalSysEx(0,0, 1, 2, struct.pack('>B', 0x01)) MyMIDI.close() self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type, 'UniversalSysEx') self.assertEquals(get_byte(MyMIDI, 0, 0), 0x00) self.assertEquals(get_byte(MyMIDI, 0, 1), 0xf0) self.assertEquals(get_byte(MyMIDI, 0, 2), 6) self.assertEquals(get_byte(MyMIDI, 0, 3), 0x7E) self.assertEquals(get_byte(MyMIDI, 0, 4), 0x7F) self.assertEquals(get_byte(MyMIDI, 0, 5), 0x01) self.assertEquals(get_byte(MyMIDI, 0, 6), 0x02) self.assertEquals(get_byte(MyMIDI, 0, 7), 0x01) self.assertEquals(get_byte(MyMIDI, 0, 8), 0xf7)
def testUniversalSysEx(self): MyMIDI = MIDIFile(1) MyMIDI.addUniversalSysEx(0, 0, 1, 2, struct.pack('>B', 0x01)) MyMIDI.close() self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type, 'UniversalSysEx') self.assertEquals(get_byte(MyMIDI, 0, 0), 0x00) self.assertEquals(get_byte(MyMIDI, 0, 1), 0xf0) self.assertEquals(get_byte(MyMIDI, 0, 2), 6) self.assertEquals(get_byte(MyMIDI, 0, 3), 0x7E) self.assertEquals(get_byte(MyMIDI, 0, 4), 0x7F) self.assertEquals(get_byte(MyMIDI, 0, 5), 0x01) self.assertEquals(get_byte(MyMIDI, 0, 6), 0x02) self.assertEquals(get_byte(MyMIDI, 0, 7), 0x01) self.assertEquals(get_byte(MyMIDI, 0, 8), 0xf7)
def testTimeShift(self): # With one track MyMIDI = MIDIFile(1) MyMIDI.addNote(0, 0, 100, 5, 1, 100) MyMIDI.close() self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type, 'NoteOn') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].time, 0) self.assertEquals(MyMIDI.tracks[0].MIDIEventList[1].type, 'NoteOff') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[1].time, 128) # With two tracks MyMIDI = MIDIFile(2) MyMIDI.addNote(0, 0, 100, 5, 1, 100) MyMIDI.addNote(1, 0, 100, 6, 1, 100) MyMIDI.close() self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type, 'NoteOn') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].time, 0) self.assertEquals(MyMIDI.tracks[0].MIDIEventList[1].type, 'NoteOff') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[1].time, 128) self.assertEquals(MyMIDI.tracks[1].MIDIEventList[0].type, 'NoteOn') self.assertEquals(MyMIDI.tracks[1].MIDIEventList[0].time, 128) self.assertEquals(MyMIDI.tracks[1].MIDIEventList[1].type, 'NoteOff') self.assertEquals(MyMIDI.tracks[1].MIDIEventList[1].time, 128) # Negative Time MyMIDI = MIDIFile(1) MyMIDI.addNote(0, 0, 100, -5, 1, 100) MyMIDI.close() self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type, 'NoteOn') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].time, 0) self.assertEquals(MyMIDI.tracks[0].MIDIEventList[1].type, 'NoteOff') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[1].time, 128) # Negative time, two tracks MyMIDI = MIDIFile(2) MyMIDI.addNote(0, 0, 100, -1, 1, 100) MyMIDI.addNote(1, 0, 100, 0, 1, 100) MyMIDI.close() self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type, 'NoteOn') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].time, 0) self.assertEquals(MyMIDI.tracks[0].MIDIEventList[1].type, 'NoteOff') self.assertEquals(MyMIDI.tracks[0].MIDIEventList[1].time, 128) self.assertEquals(MyMIDI.tracks[1].MIDIEventList[0].type, 'NoteOn') self.assertEquals(MyMIDI.tracks[1].MIDIEventList[0].time, 128) self.assertEquals(MyMIDI.tracks[1].MIDIEventList[1].type, 'NoteOff') self.assertEquals(MyMIDI.tracks[1].MIDIEventList[1].time, 128)
def testTuning(self): MyMIDI = MIDIFile(1) MyMIDI.changeNoteTuning(0, [(1, 440), (2, 880)]) MyMIDI.close() self.assertEquals(MyMIDI.tracks[0].MIDIEventList[0].type, 'UniversalSysEx') self.assertEquals(get_byte(MyMIDI, 0, 0), 0x00) self.assertEquals(get_byte(MyMIDI, 0, 1), 0xf0) self.assertEquals(get_byte(MyMIDI, 0, 2), 15) self.assertEquals(get_byte(MyMIDI, 0, 3), 0x7E) self.assertEquals(get_byte(MyMIDI, 0, 4), 0x7F) self.assertEquals(get_byte(MyMIDI, 0, 5), 0x08) self.assertEquals(get_byte(MyMIDI, 0, 6), 0x02) self.assertEquals(get_byte(MyMIDI, 0, 7), 0x00) self.assertEquals(get_byte(MyMIDI, 0, 8), 0x2) self.assertEquals(get_byte(MyMIDI, 0, 9), 0x1) self.assertEquals(get_byte(MyMIDI, 0, 10), 69) self.assertEquals(get_byte(MyMIDI, 0, 11), 0) self.assertEquals(get_byte(MyMIDI, 0, 12), 0) self.assertEquals(get_byte(MyMIDI, 0, 13), 0x2) self.assertEquals(get_byte(MyMIDI, 0, 14), 81) self.assertEquals(get_byte(MyMIDI, 0, 15), 0) self.assertEquals(get_byte(MyMIDI, 0, 16), 0) self.assertEquals(get_byte(MyMIDI, 0, 17), 0xf7)