changeset 63:1c7a97d80120

Some work on the sound code ...
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 25 Feb 2011 07:26:58 +0200
parents caf67c7e0814
children bca0112851d6
files game/SoundManager.java
diffstat 1 files changed, 11 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/game/SoundManager.java	Thu Feb 24 03:59:46 2011 +0200
+++ b/game/SoundManager.java	Fri Feb 25 07:26:58 2011 +0200
@@ -62,11 +62,11 @@
         DataLine.Info lineInfo = new DataLine.Info(SourceDataLine.class, playbackFormat);
 
         Mixer.Info[] info = AudioSystem.getMixerInfo();
-        System.out.print("getMaxSimultaneousSounds() mixer information:\n");
+        System.out.print("SMGR.getMaxSimultaneousSounds() mixer information:\n");
         Mixer.Info select = null;
         for (Mixer.Info i : info)
         {
-            System.out.print("#"+i.getName()+"\n");
+            System.out.print("  - '"+i.getName()+"'\n");
             if (i.getName().equals("Java Sound Audio Engine"))
                 select = i;
         }
@@ -74,13 +74,13 @@
         Mixer mixer = AudioSystem.getMixer(select);
 
         Mixer.Info i = mixer.getMixerInfo();
-        System.out.print("selected: "+i.getName()+"\n");
+        System.out.print("  * selected='"+i.getName()+"'\n");
 
         int maxLines = mixer.getMaxLines(lineInfo);
         if (maxLines == AudioSystem.NOT_SPECIFIED)
-            maxLines = 16;
+            maxLines = 8;
 
-        System.out.print("SMGR.getMaxSimultaneousSounds() maxLines="+maxLines+"\n");
+        System.out.print("  * maxLines="+maxLines+"\n");
 
         return maxLines;
     }
@@ -96,7 +96,6 @@
 
         // close the mixer (stops any running sounds)
         Mixer mixer = AudioSystem.getMixer(null);
-        System.out.print("SMGR.cleanUp(): foo\n");
         if (mixer.isOpen())
             mixer.close();
 
@@ -224,10 +223,11 @@
 
     public InputStream play(InputStream is)
     {
-        System.out.print("SMGR.play()\n");
+        System.out.print("SMGR.play("+is+")\n");
         if (is != null)
+        {
             runTask(new SoundPlayer(is));
-
+        }
         return is;
     }
 
@@ -246,8 +246,7 @@
 
         // use a short, 100ms (1/10th sec) buffer for filters that
         // change in real-time
-        int bufferSize = playbackFormat.getFrameSize() *
-            Math.round(playbackFormat.getSampleRate() / 10);
+        int bufferSize = playbackFormat.getFrameSize() * Math.round(playbackFormat.getSampleRate() / 10);
 
         // create, open, and start the line
         SourceDataLine line;
@@ -259,18 +258,13 @@
         }
         catch (LineUnavailableException ex)
         {
+            System.out.print("SMGR.threadStarted() line unavailable!\n");
             // the line is unavailable - signal to end this thread
             Thread.currentThread().interrupt();
             return;
         }
         
-/*
-        Control[] ctrls = line.getControls();
-        for (Control c : ctrls)
-        {
-            System.out.print("#" + c.toString() +"\n");
-        }
-*/
+        // Change volume
         Control.Type ct = FloatControl.Type.MASTER_GAIN;
         if (line.isControlSupported(ct))
         {