• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

MIDI Volume Mystery

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic