|
23 | 23 | MidiFile, |
24 | 24 | ) |
25 | 25 | from music21.midi.translate import ( |
| 26 | + TimedNoteEvent, |
| 27 | + TranslateWarning, |
| 28 | + channelInstrumentData, |
| 29 | + conductorStream, |
| 30 | + getMetaEvents, |
26 | 31 | midiAsciiStringToBinaryString, |
27 | | - noteToMidiEvents, |
| 32 | + midiEventsToInstrument, |
28 | 33 | midiEventsToNote, |
29 | | - streamHierarchyToMidiTracks, midiFileToStream, conductorStream, |
30 | | - streamToMidiFile, prepareStreamForMidi, midiEventsToInstrument, getMetaEvents, |
31 | | - TranslateWarning, channelInstrumentData, packetStorageFromSubstreamList, |
| 34 | + midiFileToStream, |
| 35 | + noteToMidiEvents, |
| 36 | + packetStorageFromSubstreamList, |
| 37 | + prepareStreamForMidi, |
| 38 | + streamHierarchyToMidiTracks, |
| 39 | + streamToMidiFile, |
32 | 40 | updatePacketStorageWithChannelInfo, |
33 | 41 | ) |
34 | 42 | from music21.musicxml import testPrimitive |
@@ -323,7 +331,7 @@ def testImportWithRunningStatus(self): |
323 | 331 | # dealing with midi files that use running status compression |
324 | 332 | s = converter.parse(fp) |
325 | 333 | self.assertEqual(len(s.parts), 2) |
326 | | - self.assertEqual(len(s.parts[0].recurse().notes), 704) |
| 334 | + self.assertEqual(len(s.parts[0].recurse().notes), 702) |
327 | 335 | self.assertEqual(len(s.parts[1].recurse().notes), 856) |
328 | 336 |
|
329 | 337 | # for n in s.parts[0].notes: |
@@ -403,8 +411,7 @@ def testNote(self): |
403 | 411 | self.assertIsInstance(eventList[3], MidiEvent) |
404 | 412 |
|
405 | 413 | # translate eventList back to a note |
406 | | - n2 = midiEventsToNote(((eventList[0].time, eventList[1]), |
407 | | - (eventList[2].time, eventList[2]))) |
| 414 | + n2 = midiEventsToNote(TimedNoteEvent(eventList[0].time, eventList[2].time, eventList[1])) |
408 | 415 | self.assertEqual(n2.pitch.nameWithOctave, 'A4') |
409 | 416 | self.assertEqual(n2.quarterLength, 2.0) |
410 | 417 |
|
@@ -1538,23 +1545,24 @@ def testExportUnpitched(self): |
1538 | 1545 |
|
1539 | 1546 | def testMidiImportLyrics(self): |
1540 | 1547 | lyricFactZh = ['明', '山', '涌', '水', '郁', '郁', '葱', '', '葱', |
1541 | | - '钟', '灵', '毓', '秀', '海', '天', '', '东', |
1542 | | - '济', '济', '多', '士', '四', '方', '所', '', '崇', |
1543 | | - '早', '', '育', '', '文', '明', '', '种'] |
| 1548 | + '钟', '灵', '毓', '秀', '海', '天', '', '东', |
| 1549 | + '济', '济', '多', '士', '四', '方', '所', '', '崇', |
| 1550 | + '早', '', '育', '', '文', '明', '', '种'] |
1544 | 1551 | lyricFactKo = ['빛', '날', '세', '라', '영', '웅', '열', '', '사', |
1545 | | - '만', '세', '불', '망', '하', '실', '', '이', |
1546 | | - '옛', '적', '이', '나', '지', '금', '이', '', '나', |
1547 | | - '항', '상', '앙', '모', '합', '니', '', '다'] |
| 1552 | + '만', '세', '불', '망', '하', '실', '', '이', |
| 1553 | + '옛', '적', '이', '나', '지', '금', '이', '', '나', |
| 1554 | + '항', '상', '앙', '모', '합', '니', '', '다'] |
1548 | 1555 | testCases = [ |
1549 | 1556 | ('test18.mid', 'utf-8', lyricFactZh), |
1550 | 1557 | ('test19.mid', 'gbk', lyricFactZh), |
1551 | 1558 | ('test20.mid', 'utf-8', lyricFactKo), |
1552 | 1559 | ('test21.mid', 'euc-kr', lyricFactKo), |
1553 | 1560 | ] |
1554 | | - for (filename, encoding, lyricFact) in testCases: |
| 1561 | + |
| 1562 | + for filename, encoding, lyricFact in testCases: |
1555 | 1563 | fp = common.getSourceFilePath() / 'midi' / 'testPrimitive' / filename |
1556 | | - s = converter.parse(fp, encoding_type=encoding) |
1557 | | - for (n, l) in zip(s.flat.notes, lyricFact): |
| 1564 | + s = converter.parse(fp, encoding=encoding) |
| 1565 | + for (n, l) in zip(s.flatten().notes, lyricFact): |
1558 | 1566 | self.assertEqual(n.lyric, l) |
1559 | 1567 |
|
1560 | 1568 |
|
|
0 commit comments