0

I want to be able to control the 'master' or overall volume of a midi file that I play.

The setup:

  • I have a midi file in my java gui program that I want to play
  • I also have some interface which allows user input via keyboard/mouse/midi device to play sound
  • Finally I have sampled audio effects as well

What I want:

  • to be able to control the overall volume of the midi file on the fly as it plays in the background, without affecting the volume of any other audio element

Usual solution:

  • change the channel volume of each channel in the Synthesizer used to play the midi file
  • problem with this method is that if the midi file sends any volume messages to the Synthesizer, my volume settings are overridden

My solution (not finished yet)

  • implement a homespun Receiver/Transmitter to put in between the Sequencer and the Synthesizer
  • I plan on intercepting the channel volume related messages from the Sequencer, applying a gain set by my JSlider, and then relaying the edited messages to the Synthesizer.

Related question:

  • If my solution is the only way, other than the channel volume messages, are their any other volume related messages that I would have to intercept and edit as well?

Main question:

How can I just change the 'master' volume of the midi file?

Community
  • 1
  • 1
mallardz
  • 1,070
  • 11
  • 21
  • Have you considered just turning the knob on the amplifier? – keshlam Apr 19 '14 at 14:22
  • Yeah, that's not particularly helpful. – mallardz Apr 19 '14 at 14:24
  • Granted, but had to ask; sometimes it's the right answer. – keshlam Apr 19 '14 at 14:31
  • Is your question how to edit the MIDI score to change the channel or overall volume(s), or how to write/build something that will perform that edit on the fly? – keshlam Apr 19 '14 at 14:34
  • Sorry I thought you were being sarcastic. What I'm trying to do is edit on the fly as I have other user inputted sampled audio & midi sounds also playing. I just want to be able to have a background midi file playing, but let the user turn down its volume to hear their own input if necessary... I'm not very good at explaining simple things clearly! – mallardz Apr 19 '14 at 16:56
  • OK, so you basically want to alter the MIDI stream as it's being played back, to insert the channel volume control messages in response to the user's control, and to modify any channel volume controls in the stream to scale them up or down correspondingly. I suspect you can't easily do that as a software patch, unless it's already built into your MIDI playback tooling or those tools allow some form of plug-in filtering of the MIDI stream... Best other thought I've got is an Arduino or similar appropriately programmed. – keshlam Apr 20 '14 at 00:55

1 Answers1

1

In MIDI, all volume-related controllers (note velocity, expression, volume, master volume) are combined; each can be changed independently.

Every GM-compatible synthsizer should support the Master Volume message:

F0 7F 7F 04 01 LL MM F7

where LL and MM are lower and upper 7 bits of the 14-bit value. (Most devices have a 7-bit master volume and just ignore LL.)

Most MIDI files do not change the master volume; you should be able to just send this message blindly.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • Thank you, this sounds promising, I found something about Master Volume in a MIDI spec document, but didn't really understand it. Do you know how you would go about implementing this in Java? – mallardz Apr 20 '14 at 14:52
  • Like any other MIDI message. – CL. Apr 20 '14 at 14:53