1

I'm using Pygame.midi and you can select from 127 instruments.

I want to know how I can change/add midi instruments to this list.

Is there a list of pygame.midi instruments anywhere and if not what libraries is pygame using to actually do midi?

I've seen something called PortMidi and I'm wondering if this is what Pygame is using.

I just want to know how I can access pygame.midi and add instruments.

Greg James
  • 15
  • 4

1 Answers1

1

Pygame is not providing the instruments. It's just sending MIDI commands to your system's built-in synthesizer, usually part of your sound card. MIDI allows for 127 instruments at a time. There is a standard called "General MIDI" that tries to define a baseline of 127 instruments, and that's probably what your system is using.

You use "sysex" (system exclusive) messages to tell the synthesizer to change the instrument-to-channel assignments. pygame supports that with the write_sys_ex command, but you have to know the internals of your synthesizer to know which commands to send.

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30
  • interesting, does this mean that on different machines the instruments may not be the same? How would you suggest i use custom instruments while still using pygame.midi? – Greg James Apr 06 '21 at 20:14
  • It does mean that, yes. Most raw devices start out with the General MIDI set, so you'll get approximately what you're after, but the quality varies HUGELY. And if someone has a synth plugged in as their default MIDI device, which can happen, then all bets are off. – Tim Roberts Apr 06 '21 at 21:21
  • You can only select among the instruments that the synth offers. You can't load your own samples in MIDI. – Tim Roberts Apr 06 '21 at 21:24