Mercurial > hg > ristipolku
changeset 93:e1d657e6c25b
Work on audio code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 03 Mar 2011 18:21:45 +0200 |
parents | d5f51370617b |
children | 18316f0638ff |
files | game/Engine.java game/SoundManager.java |
diffstat | 2 files changed, 13 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/game/Engine.java Thu Mar 03 18:12:04 2011 +0200 +++ b/game/Engine.java Thu Mar 03 18:21:45 2011 +0200 @@ -215,7 +215,7 @@ super(pos); pscale = ps; -// sndPlaced = smgr.getSound("sounds/placed.wav"); + sndPlaced = G.smgr.getSound("sounds/placed.wav"); startNewGame(); } @@ -471,7 +471,7 @@ System.out.print("Engine() constructor\n"); // Sound system - G.smgr = new SoundManager(new AudioFormat(22050, 16, 1, true, false), 4); + G.smgr = new SoundManager(new AudioFormat(22050, 16, 1, true, false), 2); // Load resources try @@ -528,14 +528,16 @@ addMouseListener(this); addMouseWheelListener(this); + // Start playing background music + G.smgr.play(musa); + // Get initial focus if (!hasFocus()) { System.out.print("Engine(): requesting focus\n"); requestFocus(); } - -// G.smgr.play(musa); + } public void startNewGame()
--- a/game/SoundManager.java Thu Mar 03 18:12:04 2011 +0200 +++ b/game/SoundManager.java Thu Mar 03 18:21:45 2011 +0200 @@ -41,15 +41,15 @@ setDaemon(true); alive = true; - queue = new LinkedList(); - for (int i = 0; i < numThreads; i++) - new PooledThread().start(); - playbackFormat = format; localLine = new ThreadLocal(); localBuffer = new ThreadLocal(); pausedLock = new Object(); + queue = new LinkedList(); + for (int i = 0; i < numThreads; i++) + new PooledThread().start(); + synchronized (this) { notifyAll(); @@ -223,7 +223,7 @@ public InputStream play(InputStream is) { - System.out.print("SMGR.play("+is+")\n"); + System.out.print("SMGR.play(is="+is+")\n"); if (is != null) { runTask(new SoundPlayer(is)); @@ -242,7 +242,6 @@ catch (InterruptedException ex) { } } - System.out.print("SMGR.threadStarted()\n"); // use a short, 100ms (1/10th sec) buffer for filters that // change in real-time @@ -251,6 +250,8 @@ // create, open, and start the line SourceDataLine line; DataLine.Info lineInfo = new DataLine.Info(SourceDataLine.class, playbackFormat); + + System.out.print("SMGR.threadStarted(): "+lineInfo.toString()+"\n"); try { line = (SourceDataLine) AudioSystem.getLine(lineInfo);