Music21合并MIDI/合并乐器

发布于 2025-01-29 10:36:57 字数 713 浏览 4 评论 0原文

我目前正在从事一个有一些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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜爱纠缠 2025-02-05 10:36:57

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文