Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
361 views
in Technique[技术] by (71.8m points)

java - How to change the 'master' volume of a synthesizer/sequencer?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...