使用Python Mido库选择GM MIDI Level 2乐器

2024-04-25 13:23:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Python Mido 库来创建MIDI文件。我已经弄明白了要改变现状 您可以将program_change消息添加到 给定频道:

from mido import Message, MidiFile, MidiTrack
track = MidiTrack()
...
track.append(Message('program_change', program = 36,
                     time = 1234, channel = 0)

这是可行的,但我只能使用GM MIDI 1级乐器。我 想要访问 GM MIDI Level 2仪器也是

请告诉我如何使用代码来做这件事。所有MIDI文档 我发现谷歌搜索的结果令人难以置信地困惑


Tags: 文件fromimport消息messagetrackprogramchange
1条回答
网友
1楼 · 发布于 2024-04-25 13:23:43

报告说:

3.2 Program Change Message

[…]
Sets the timbre for the specified Channel.

When the Channel is a Melody Channel, the timbre is selected from the Bank specified by Bank Select (using Bank Select 79H/xxH, with Bank 79H/00H corresponding to the GM1 sound set). […]

3.3.1 Bank Select (cc#0/32)

Bank Select selects the desired Bank for the specified Channel. The first byte listed is the MSB, transmitted on cc#0. The second byte listed is the LSB, transmitted on cc#32. Banks are listed in the GM2 Sound Set table (Appendix A). Bank Select 79H/00H corresponds to the GM1 Sound Set.[…]

The Bank Select message shall not affect any change in sound until a subsequent Program Change message is received.

因此,要访问其他工具,您必须在发送程序更改消息之前选择其他银行。 例如,要选择“气泡”:

track.append(Message('control_change', control =  0, value = 0x79, channel = 0, time = 1233))
track.append(Message('control_change', control = 32, value = 0x05, channel = 0, time = 1233))
track.append(Message('program_change', program = 0x7a,             channel = 0, time = 1234))

相关问题 更多 >