在以下示例中,A和B具有setados工具,但是A和B都仅使用要设置的最后一个对象,就好像重写一样。

from mingus.midi import fluidsynth as a
from mingus.midi import fluidsynth as b
from mingus.containers import Note

a.init('/usr/share/sounds/sf2/FluidR3_GM.sf2',"alsa")
a.set_instrument(0, 34, 0)
b.set_instrument(0, 35, 0)

a.play_Note(26, 0, 127)
a.sleep(0.5)
b.play_Note(26, 0, 127)
b.sleep(0.5)

如何用相同的脚本或其他方式将A和B的工具设置到另一个乐器?

最佳答案

首先,如果您写:

from mingus.midi import fluidsynth as a
from mingus.midi import fluidsynth as b

然后将ab视为相同的对象。因此,编写b.set_instrument(0, 35, 0)a.set_instrument(0, 35, 0)相同。据我了解fluidsynth,您应该为每种乐器使用两个不同的 channel :
a.set_instrument(0, 34)
a.set_instrument(1, 35)

a.play_Note(26, 0, 127)
a.sleep(0.5)
a.play_Note(26, 1, 127)
a.sleep(0.5)

关于python - 如何使用Python和Mingus设置多个乐器?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21737288/

10-12 05:34