• 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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

MIDI Volume Mystery

 
Greenhorn
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!
 
I'm so happy! And I wish to make this tiny ad happy too:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic