def test_track_parsing_identifies_midi_events_correctly_4(self): input = BitArray("0x00923060003C6000FF2F00") track = process_track_chunk(input) self.assertEqual(track["type"], TRACK) self.assertEqual(len(track["events"]), 3) delta_time = track["events"][0][0] event = track["events"][0][1] self.assertEqual(delta_time, 0) self.assertEqual(event["type"], MIDI) self.assertEqual(event["sub_type"], "Note On") self.assertEqual(event["channel"], 3) self.assertEqual(event["note"], 48) self.assertEqual(event["velocity"], 96) delta_time = track["events"][1][0] event = track["events"][1][1] self.assertEqual(delta_time, 0) self.assertEqual(event["type"], MIDI) self.assertEqual(event["sub_type"], "Note On") self.assertEqual(event["channel"], 3) self.assertEqual(event["note"], 60) self.assertEqual(event["velocity"], 96)
def test_track_parsing_identifies_meta_events_correctly(self): input = BitArray("0x00FF58040402180800FF2F00") track = process_track_chunk(input) self.assertEqual(track["type"], TRACK) self.assertEqual(len(track["events"]), 2) delta_time = track["events"][0][0] event = track["events"][0][1] self.assertEqual(delta_time, 0) self.assertEqual(event["type"], META) self.assertEqual(event["sub_type"], "Time Signature")
def test_track_parsing_identifies_midi_events_correctly(self): input = BitArray("0x00C00500FF2F00") track = process_track_chunk(input) self.assertEqual(track["type"], TRACK) self.assertEqual(len(track["events"]), 2) delta_time = track["events"][0][0] event = track["events"][0][1] self.assertEqual(delta_time, 0) self.assertEqual(event["type"], MIDI) self.assertEqual(event["sub_type"], "Program Change") self.assertEqual(event["channel"], 1) self.assertEqual(event["new_value"], 5)
def test_track_parsing_raises_exception_if_end_of_track_event_missing(self): input = BitArray("0x00FF580404021808") self.assertRaises(Exception, process_track_chunk, input) input = BitArray("0x00FF2F00") track = process_track_chunk(input) self.assertEqual(track["type"], TRACK) self.assertEqual(len(track["events"]), 1) delta_time = track["events"][0][0] event = track["events"][0][1] self.assertEqual(delta_time, 0) self.assertEqual(event["type"], META) self.assertEqual(event["sub_type"], "End of Track")