Music21合并MIDI/合并乐器
我目前正在从事一个有一些MIDI处理的项目。对于我的处理,我需要将打击乐器与俯仰仪器分开。在进行处理后(将倾斜仪器转换为另一个钥匙),我需要将两者重新合并在一起。
我的鼓和俯仰仪器被保存为MIDI文件。我的代码是:
pitch_midi = music21.converter.parse(pitch)
drums_midi = music21.converter.parse(drums)
transposed_pitch = pitch_midi.transpose(semitones) # Int Variable
transposed_pitch.append(drums_midi)
transposed_pitch.write('midi', 'Transposed.mid')
该代码运行良好,但保存的MIDI文件不包括鼓轨道。 drums_midi的类型为“< class'music21.stream.base.score'> “ transposed_pitch的类型是” “而且我怀疑这是一个问题。
如果
transposed_midi = transposed_pitch.append(drums_midi)
我会得到一个属性:'nontype'对象没有属性'写入'。这是有道理的,因为transposed_midi的类型是非类型的。
任何想法如何克服这一点?
I'm currently working on a project that has some midi processing. For my processing I needed to separate percussive instruments from pitched ones. After I did my processing (transposing the pitched instruments to another key) I need to merge the two back together.
My drums and pitched instruments are saved as midi files. My code is:
pitch_midi = music21.converter.parse(pitch)
drums_midi = music21.converter.parse(drums)
transposed_pitch = pitch_midi.transpose(semitones) # Int Variable
transposed_pitch.append(drums_midi)
transposed_pitch.write('midi', 'Transposed.mid')
The code runs just fine but the saved midi file doesn't include the drum tracks. The type of drums_midi is "<class 'music21.stream.base.Score'>
" and the type of the transposed_pitch is "<music21.stream.Score 0x155ad892af0>
" and I suspect that this is the problem.
If I do
transposed_midi = transposed_pitch.append(drums_midi)
I get an AttributeError: 'NoneType' object has no attribute 'write'. Which is makes sense since the type of transposed_midi is NoneType.
Any ideas how to overcome that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Music21
目前缺乏将打击乐轨迹导出到MIDI的支持,请参见 https:/https:/ /Github.com/cuthbertlab/music21/issues/238 。music21
currently lacks support for exporting percussion tracks to MIDI, see https://github.com/cuthbertLab/music21/issues/238.