无法在 MIDI 文件中写入 'rest' 个对象
Unable to write 'rest' objects in midi file
我有一个包含多个“notes
”、“chords
”和“rest
”对象的列表,并试图将它们写入 midi 文件。我正在尝试使用以下代码
midi_stream = stream.Stream(output_notes)
midi_stream.write('midi', fp='test_output.mid')
在读取创建的 midi 文件时,我发现 midi 文件中没有附加“rest
”对象。
output_notes变量的内容是:
<music21.note.Rest rest> <music21.chord.Chord A1 E2>
<music21.chord.Chord A1 E2> <music21.chord.Chord A1 E2>
<music21.note.Rest rest> <music21.chord.Chord A1 E2>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.chord.Chord A1 E2> <music21.chord.Chord A1 E2>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.note.Note A> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.note.Note A> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.note.Rest rest> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.chord.Chord A4 C#5 F5>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.chord.Chord A4 C#5 F5> <music21.note.Note B>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.chord.Chord A4 C#5 F5> <music21.note.Rest rest>
<music21.chord.Chord A4 C#5 F5> <music21.note.Rest rest>
<music21.chord.Chord A4 C#5 F5> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.chord.Chord G4 B4 D5>
<music21.chord.Chord F#4 B4 D5> <music21.chord.Chord F#4 B4 D5>
<music21.chord.Chord F#4 B4 D5> <music21.chord.Chord F#4 B4 D5>
<music21.note.Note C#> <music21.note.Rest rest> <music21.note.Rest rest>
<music21.chord.Chord F#4 B4 D5> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.chord.Chord E3 A3>
<music21.note.Rest rest> <music21.note.Note C> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.chord.Chord C3 G3> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Rest rest> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G>]
创建的 midi 文件中的内容是:
[<music21.chord.Chord A1 E2> <music21.chord.Chord A1 E2>
<music21.chord.Chord A1 E2> <music21.chord.Chord A1 E2>
<music21.chord.Chord A1 E2> <music21.note.Note A> <music21.note.Note G>
<music21.note.Note G> <music21.chord.Chord A4 C#5 F5>
<music21.note.Note B> <music21.chord.Chord A4 C#5 F5>
<music21.chord.Chord A4 C#5 F5> <music21.note.Note G>
<music21.chord.Chord B4 D5> <music21.note.Note F#>
<music21.chord.Chord B4 D5> <music21.note.Note F#>
<music21.chord.Chord B4 D5> <music21.note.Note C#>
<music21.chord.Chord F#4 B4 D5> <music21.chord.Chord E3 A3>
<music21.note.Note C> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.chord.Chord C3 G3> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.chord.Chord C3 G3> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G>]
你所做的是获取一个 music21
流,将其转换为 MIDI,然后再将其转换回 music21
流,令你惊讶的是 round-trip不会为您提供与原始输入相同的输出。
但是,如果您要将 Excel 电子表格转换为 .csv
并返回,我想您不会感到如此惊讶。
您所做的假设是 music21
和 MIDI 是两个等价的符号。他们不是。 music21
面向分数分析。它知道音符、休止符、小节、key-signatures 和谱号(以及更多)。
另一方面,MIDI 是一个synthesizer-oriented 回放指令集。想想你会在一些合成程序中看到的 piano-roll 符号,例如这个:
.
黑色水平条纹表示演奏的音符。但是其余的在哪里?没有任何音符,因为在整首曲子中都是无声的音符和小节中被静音打断 crotchet/quarter 音符长度的音符之间没有区别。这就是为什么我在评论中说 MIDI 实际上没有任何休止符。休止符仅用于向演奏者展示小节中哪些地方不能演奏音符。但是 MIDI 对小节一无所知(如果您在 MIDI 文件中看到小节,它们本质上是注释),因此它也不需要休止符。当 music21
从 MIDI 导入时,它会尽最大努力处理输入,但是从没有音符的情况下猜测休息应该去哪里是非常棘手的,如果 music21
没有这样做,你也不必感到惊讶一份如你所愿的好工作。
MIDI 是一种不太丰富的音乐表达媒介,因为它用对人类有意义的符号代替了对目标乐器的直接原始控制。如果您所要做的只是将 2(或 1,取决于上下文)添加到消息中的注释编号,则不需要 double-sharp 符号。这就是为什么从 music21
转换为 MIDI 并返回有点像将电子表格写成 .csv
然后再读回来。很多信息都丢失了。
实际上不存在 application-independent 音乐符号标准,当然也不是 MIDI。 MusicXML 试图做到这一点,但它并没有涵盖所有内容,因为如果您使用它在 musci21
、Sibelius 和 Dorico 之间进行转换,您会发现这一点。事实上,Dorico 会忽略 MusicXML 中的一些间距符号,因为它认为它自己可以做得更好。
你的 MIDI 文件中没有休止符的真正测试是播放 MIDI 文件,而不是将它转换为其他一些符号并将其视为MIDI 文件中的内容。你能听到锉刀中没有休止符吗?播放的输出声音是否与原始声音不同(忽略 non-note 属性,如乐器、音色、节奏等)?
我有一个包含多个“notes
”、“chords
”和“rest
”对象的列表,并试图将它们写入 midi 文件。我正在尝试使用以下代码
midi_stream = stream.Stream(output_notes)
midi_stream.write('midi', fp='test_output.mid')
在读取创建的 midi 文件时,我发现 midi 文件中没有附加“rest
”对象。
output_notes变量的内容是:
<music21.note.Rest rest> <music21.chord.Chord A1 E2>
<music21.chord.Chord A1 E2> <music21.chord.Chord A1 E2>
<music21.note.Rest rest> <music21.chord.Chord A1 E2>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.chord.Chord A1 E2> <music21.chord.Chord A1 E2>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.note.Note A> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.note.Note A> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.note.Rest rest> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.chord.Chord A4 C#5 F5>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.chord.Chord A4 C#5 F5> <music21.note.Note B>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.note.Rest rest>
<music21.chord.Chord A4 C#5 F5> <music21.note.Rest rest>
<music21.chord.Chord A4 C#5 F5> <music21.note.Rest rest>
<music21.chord.Chord A4 C#5 F5> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.chord.Chord G4 B4 D5>
<music21.chord.Chord F#4 B4 D5> <music21.chord.Chord F#4 B4 D5>
<music21.chord.Chord F#4 B4 D5> <music21.chord.Chord F#4 B4 D5>
<music21.note.Note C#> <music21.note.Rest rest> <music21.note.Rest rest>
<music21.chord.Chord F#4 B4 D5> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.chord.Chord E3 A3>
<music21.note.Rest rest> <music21.note.Note C> <music21.note.Rest rest>
<music21.note.Rest rest> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.chord.Chord C3 G3> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Rest rest> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G>]
创建的 midi 文件中的内容是:
[<music21.chord.Chord A1 E2> <music21.chord.Chord A1 E2>
<music21.chord.Chord A1 E2> <music21.chord.Chord A1 E2>
<music21.chord.Chord A1 E2> <music21.note.Note A> <music21.note.Note G>
<music21.note.Note G> <music21.chord.Chord A4 C#5 F5>
<music21.note.Note B> <music21.chord.Chord A4 C#5 F5>
<music21.chord.Chord A4 C#5 F5> <music21.note.Note G>
<music21.chord.Chord B4 D5> <music21.note.Note F#>
<music21.chord.Chord B4 D5> <music21.note.Note F#>
<music21.chord.Chord B4 D5> <music21.note.Note C#>
<music21.chord.Chord F#4 B4 D5> <music21.chord.Chord E3 A3>
<music21.note.Note C> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.chord.Chord C3 G3> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.chord.Chord C3 G3>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.chord.Chord C3 G3> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.chord.Chord C3 G3> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G> <music21.note.Note G> <music21.note.Note G>
<music21.note.Note G>]
你所做的是获取一个 music21
流,将其转换为 MIDI,然后再将其转换回 music21
流,令你惊讶的是 round-trip不会为您提供与原始输入相同的输出。
但是,如果您要将 Excel 电子表格转换为 .csv
并返回,我想您不会感到如此惊讶。
您所做的假设是 music21
和 MIDI 是两个等价的符号。他们不是。 music21
面向分数分析。它知道音符、休止符、小节、key-signatures 和谱号(以及更多)。
MIDI 是一个synthesizer-oriented 回放指令集。想想你会在一些合成程序中看到的 piano-roll 符号,例如这个:
黑色水平条纹表示演奏的音符。但是其余的在哪里?没有任何音符,因为在整首曲子中都是无声的音符和小节中被静音打断 crotchet/quarter 音符长度的音符之间没有区别。这就是为什么我在评论中说 MIDI 实际上没有任何休止符。休止符仅用于向演奏者展示小节中哪些地方不能演奏音符。但是 MIDI 对小节一无所知(如果您在 MIDI 文件中看到小节,它们本质上是注释),因此它也不需要休止符。当 music21
从 MIDI 导入时,它会尽最大努力处理输入,但是从没有音符的情况下猜测休息应该去哪里是非常棘手的,如果 music21
没有这样做,你也不必感到惊讶一份如你所愿的好工作。
MIDI 是一种不太丰富的音乐表达媒介,因为它用对人类有意义的符号代替了对目标乐器的直接原始控制。如果您所要做的只是将 2(或 1,取决于上下文)添加到消息中的注释编号,则不需要 double-sharp 符号。这就是为什么从 music21
转换为 MIDI 并返回有点像将电子表格写成 .csv
然后再读回来。很多信息都丢失了。
实际上不存在 application-independent 音乐符号标准,当然也不是 MIDI。 MusicXML 试图做到这一点,但它并没有涵盖所有内容,因为如果您使用它在 musci21
、Sibelius 和 Dorico 之间进行转换,您会发现这一点。事实上,Dorico 会忽略 MusicXML 中的一些间距符号,因为它认为它自己可以做得更好。
你的 MIDI 文件中没有休止符的真正测试是播放 MIDI 文件,而不是将它转换为其他一些符号并将其视为MIDI 文件中的内容。你能听到锉刀中没有休止符吗?播放的输出声音是否与原始声音不同(忽略 non-note 属性,如乐器、音色、节奏等)?