-->

Sending pitch bend to MIDI sequencer in Java

2019-06-27 02:03发布

问题:

I understand the basics of getting a MIDI sequencer up and running and I would like to be able to increase/decrease the pitch of the sequence during playback, but pitch bend is a message that gets sent to the synthesizer, not the sequencer.

I tried setting the sequencer's receiver to be the synthesizer's transmitter, and when I sent pitch-bend short messages, the sequencer stayed the same pitch but then the synthesizer played a second track at the new pitch bend value, creating some pretty awful-sounding music.

Is there a good way of bending pitch during playback like there is for changing tempo?

Another option (which seems like a big kluge) is to have a few versions of the MIDI files in different keys ready to load when called.

回答1:

You could try to send the messages directly to the synthesizer's receiver by calling its send method, but the synthesizer might not allow its receivers to influence each other.

Ultimately, the messages sent to the synthesizer are stored in the sequencer's track, so to have pitch-bend messages, edit the sequence to add those messages.



回答2:

The MIDI protocol doesn't define any standards for pitch, except for pitch bend which is generally intended to be used as a temporary effect rather than a way of setting the arrangement's tuning. It sounds like you are implementing a sequencer in Java, in which case I would rather suggest having a global detune preference. Then you would simply render the audio with the default tuning (440Hz) and then apply pitchbend to the bounced arrangement. There are several libraries which can do pitchbend for you, including the excellent DIRAC.