• 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
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Worst Metronome in the world. Delay in playing Audio.

 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. I've just started learning about how to use sound in java. I thought I would start with the simplest way of doing things first by using the Applet.newAudioClip() method.

I've been making a beat calculator, which the user can tap in a tempo and it tells the user what tempo that is. I am now adding a metronome (click track) to it as well. The metronome was working fine before I added sound. But there seems to be a delay in playing the sounds sometimes, which makes it sound like the click is speeding up and slowing down. The proglem is with the sound because the visual part of the metronome - a JButton which counts the beats in a bar - is still working fine and is in time. I'm using the Swing Timer to keep time.

Does anyone know why the sound sometimes plays straight away, yet sometimes there is a delay? Is there anything I can do to make it run more smoothly? I know there are more complex ways of using sound in Java but I want to sort this way out before I move on.

Here is part of my Click class below. I've only kept in methods I thought were relevant.

 
Fire me boy! Cool, soothing, shameless self promotion:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic