death_oclock 103 Posting Whiz

I just wrote a program that plays various drum sounds when certain keys are pressed. It works for the most part but, when two keys are pressed at the same time, only one sound plays. Both key presses are received, however. I am using the Clip class which allegedly supports simultaneous playing. Here's the relevant code:

Input.java

// input handling method
// keyMap is type HashMap<Integer, String>
// audio is instance of Audio
public void keyPressed(KeyEvent e)
{
	Integer code = new Integer(e.getKeyCode());
	
	String sound = keyMap.get(code);
	if(sound != null)
		audio.startSound(sound);
	
	e.consume();
}

Audio.java

// clip playing method
// soundMap is type HashMap<String, Clip>
public void startSound(String id)
{
	Clip sound = soundMap.get(id);
	if(sound != null)
	{
		sound.setFramePosition(0);
		sound.start();
	}
}

I can post any other methods/definitions if needed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.