aspose file tools
The moose likes Other JSE/JEE APIs and the fly likes MIDI Volume Mystery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "MIDI Volume Mystery" Watch "MIDI Volume Mystery" New topic

MIDI Volume Mystery

Jeremy Sanderson

Joined: Sep 03, 2009
Posts: 1
Hello. I'm attempting to write a class that will load and play MIDIs as either sound effects or background music for a game. Since the music was overpowering the sound effects, I needed to find a way to adjust the volume. I thought it would be a simple thing to do so, but after searching the Internet for hours I'm still at a loss. I've attempted to isolate the problem with the following bare-bones code, which is drawn partly from Killer Game Programming in Java:

Everything compiles fine, and the background music midi file plays when I run the program. My attempts to change the volume, however, do nothing. Immediately before and after the call to controlChange, all channels display as being set to 127. I did discover that if I put in a Thread.sleep(1000) right after sequence.start(), the volume change is successful, but the channel values still do not read what I attempted to set them to. Half of them still read 127, and the other half read arbitrary values (which stay the same on subsequent runs of the program). Moreover, it will not be very helpful for my sound effects to have to wait a second into their playtime for their volume to be changed.

I just started teaching myself Java a couple months ago, and I am completely stumped as to how I can change a value, immediately print that value, and not see the change reflected. Any insight at all would be greatly appreciated!
Have you tried LearnNowOnline?
subject: MIDI Volume Mystery