changeset 1203:cfe2c755ee47

Updated to new Gervill CVS. - Fix: Throw IllegalArgumentException Exception on invalid soundbank to: SoftSynthesizer.unloadAllInstruments(Soundbank soundbank) SoftSynthesizer.unloadInstruments(Soundbank soundbank, Patch[] patchList) just like done in: SoftSynthesizer.unloadInstrument(Instrument instrument). - Change: SoftMainMixer, SoftVoice optimized for mono voices. - Change: SoftFilter optimized. - Fix: Turn SoftJitterCorrector, SoftAudioPusher threads into a daemon threads. These threads prevented the VM to exit when synthesizer was open. See: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=213 2008-11-10 Mark Wielaard <mark@klomp.org> * overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/ CHANGES.txt,SoftAudioPusher.java,SoftFilter.java, SoftJitterCorrector.java,SoftMainMixer.java,SoftVoice.java: Updated to new Gervill CVS.
author Mark Wielaard <mark@klomp.org>
date Mon, 10 Nov 2008 12:43:00 +0100
parents 688efd120766
children e7a4c496b2c0
files ChangeLog overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java
diffstat 7 files changed, 104 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Nov 09 22:31:21 2008 +0100
+++ b/ChangeLog	Mon Nov 10 12:43:00 2008 +0100
@@ -1,3 +1,10 @@
+2008-11-10  Mark Wielaard  <mark@klomp.org>
+
+	* overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/
+	CHANGES.txt,SoftAudioPusher.java,SoftFilter.java,
+	SoftJitterCorrector.java,SoftMainMixer.java,SoftVoice.java:
+	Updated to new Gervill CVS.
+
 2008-11-09  Mark Wielaard  <mark@klomp.org>
 
 	* Makefile.am (check-langtools): Run jtreg with -samevm.
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt	Sun Nov 09 22:31:21 2008 +0100
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt	Mon Nov 10 12:43:00 2008 +0100
@@ -1,3 +1,14 @@
+  - Fix: Throw IllegalArgumentException Exception on
+         invalid soundbank to:
+         SoftSynthesizer.unloadAllInstruments(Soundbank soundbank)
+         SoftSynthesizer.unloadInstruments(Soundbank soundbank, Patch[] patchList)
+         just like done in:
+         SoftSynthesizer.unloadInstrument(Instrument instrument).
+  - Change: SoftMainMixer, SoftVoice optimized for mono voices.
+  - Change: SoftFilter optimized. 
+  - Fix: Turn SoftJitterCorrector, SoftAudioPusher threads into a daemon threads.
+         These threads prevented the VM to exit when synthesizer was open.
+         See: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=213 
   - Add: More JTreg tests added:
            EmergencySoundbank
            SoftFilter
@@ -6,6 +17,8 @@
   - Fix: ModelByteBuffer.skip called super.skip
          instead to call to RandomAccessFile directly.
          JTreg tests added: ModelByteBuffer/RandomFileInputStream/*.java
+         
+Version 1.0.2 (released in OpenJDK 6 b12)   
   - Fix: ModelByteBuffer.len was being modified in inner
          class RandomFileInputStream. The variable was made final
          and RandomFileInputStream.read methods where fixed.
@@ -13,7 +26,7 @@
          Keys array was to small, it couldn't
          hold all possible midi notes (0..127).
 
-Version 1.0.1
+Version 1.0.1 (released as 1.0)
   - Fix: Created dummy SourceDataline so that following 
          jtreg test can be tested without using
          a real Audio Device SourceDataLine.  
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java	Sun Nov 09 22:31:21 2008 +0100
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java	Mon Nov 10 12:43:00 2008 +0100
@@ -54,6 +54,7 @@
             return;
         active = true;
         audiothread = new Thread(this);
+        audiothread.setDaemon(true);
         audiothread.setPriority(Thread.MAX_PRIORITY);
         audiothread.start();
     }
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java	Sun Nov 09 22:31:21 2008 +0100
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java	Mon Nov 10 12:43:00 2008 +0100
@@ -543,8 +543,6 @@
 
     public void filter1(SoftAudioBuffer sbuffer) {
 
-        float[] buffer = sbuffer.array();
-
         if (dirty) {
             filter1calc();
             dirty = false;
@@ -559,6 +557,7 @@
 
         if (wet > 0 || last_wet > 0) {
 
+            float[] buffer = sbuffer.array();
             int len = buffer.length;
             float a0 = this.last_a0;
             float q = this.last_q;
@@ -577,14 +576,16 @@
                     q += q_delta;
                     gain += gain_delta;
                     wet += wet_delta;
-                    y1 = (1 - q * a0) * y1 - (a0) * y2 + (a0) * buffer[i];
-                    y2 = (1 - q * a0) * y2 + (a0) * y1;
+                    float ga0 = (1 - q * a0);
+                    y1 = ga0 * y1 + (a0) * (buffer[i] - y2);
+                    y2 = ga0 * y2 + (a0) * y1;
                     buffer[i] = y2 * gain * wet + buffer[i] * (1 - wet);
                 }
             } else if (a0_delta == 0 && q_delta == 0) {
+                float ga0 = (1 - q * a0);
                 for (int i = 0; i < len; i++) {
-                    y1 = (1 - q * a0) * y1 - (a0) * y2 + (a0) * buffer[i];
-                    y2 = (1 - q * a0) * y2 + (a0) * y1;
+                    y1 = ga0 * y1 + (a0) * (buffer[i] - y2);
+                    y2 = ga0 * y2 + (a0) * y1;
                     buffer[i] = y2 * gain;
                 }
             } else {
@@ -592,8 +593,9 @@
                     a0 += a0_delta;
                     q += q_delta;
                     gain += gain_delta;
-                    y1 = (1 - q * a0) * y1 - (a0) * y2 + (a0) * buffer[i];
-                    y2 = (1 - q * a0) * y2 + (a0) * y1;
+                    float ga0 = (1 - q * a0);
+                    y1 = ga0 * y1 + (a0) * (buffer[i] - y2);
+                    y2 = ga0 * y2 + (a0) * y1;
                     buffer[i] = y2 * gain;
                 }
             }
@@ -611,4 +613,4 @@
         this.last_gain = this.gain;
         this.last_wet = this.wet;
     }
-}
+}
\ No newline at end of file
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java	Sun Nov 09 22:31:21 2008 +0100
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java	Mon Nov 10 12:43:00 2008 +0100
@@ -216,6 +216,7 @@
             };
 
             thread = new Thread(runnable);
+            thread.setDaemon(true);
             thread.setPriority(Thread.MAX_PRIORITY);
             thread.start();
         }
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java	Sun Nov 09 22:31:21 2008 +0100
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java	Mon Nov 10 12:43:00 2008 +0100
@@ -48,16 +48,18 @@
 
     public final static int CHANNEL_LEFT = 0;
     public final static int CHANNEL_RIGHT = 1;
-    public final static int CHANNEL_EFFECT1 = 2;
-    public final static int CHANNEL_EFFECT2 = 3;
-    public final static int CHANNEL_EFFECT3 = 4;
-    public final static int CHANNEL_EFFECT4 = 5;
+    public final static int CHANNEL_MONO = 2;
+    public final static int CHANNEL_EFFECT1 = 3;
+    public final static int CHANNEL_EFFECT2 = 4;
+    public final static int CHANNEL_EFFECT3 = 5;
+    public final static int CHANNEL_EFFECT4 = 6;
     public final static int CHANNEL_LEFT_DRY = 10;
     public final static int CHANNEL_RIGHT_DRY = 11;
     public final static int CHANNEL_SCRATCH1 = 12;
     public final static int CHANNEL_SCRATCH2 = 13;
     public final static int CHANNEL_CHANNELMIXER_LEFT = 14;
     public final static int CHANNEL_CHANNELMIXER_RIGHT = 15;
+    public final static int CHANNEL_CHANNELMIXER_MONO = 16;
     protected boolean active_sensing_on = false;
     private long msec_last_activity = -1;
     private boolean pusher_silent = false;
@@ -485,8 +487,10 @@
             // to channelmixer left,right input/output
             SoftAudioBuffer leftbak = buffers[CHANNEL_LEFT];
             SoftAudioBuffer rightbak = buffers[CHANNEL_RIGHT];
+            SoftAudioBuffer monobak = buffers[CHANNEL_MONO];
             buffers[CHANNEL_LEFT] = buffers[CHANNEL_CHANNELMIXER_LEFT];
-            buffers[CHANNEL_RIGHT] = buffers[CHANNEL_CHANNELMIXER_LEFT];
+            buffers[CHANNEL_RIGHT] = buffers[CHANNEL_CHANNELMIXER_RIGHT];
+            buffers[CHANNEL_MONO] = buffers[CHANNEL_CHANNELMIXER_MONO];
 
             int bufferlen = buffers[CHANNEL_LEFT].getSize();
 
@@ -503,6 +507,7 @@
             for (ModelChannelMixer cmixer : act_registeredMixers) {
                 for (int i = 0; i < cbuffer.length; i++)
                     Arrays.fill(cbuffer[i], 0);
+                buffers[CHANNEL_MONO].clear();
                 boolean hasactivevoices = false;
                 for (int i = 0; i < voicestatus.length; i++)
                     if (voicestatus[i].active)
@@ -516,6 +521,26 @@
                         cur_registeredMixers = null;
                     }
                 }
+                
+                if(!buffers[CHANNEL_MONO].isSilent())
+                {
+                    float[] mono = buffers[CHANNEL_MONO].array();
+                    float[] left = buffers[CHANNEL_LEFT].array();            
+                    if (nrofchannels != 1) {
+                        float[] right = buffers[CHANNEL_RIGHT].array();
+                        for (int i = 0; i < bufferlen; i++) {
+                            float v = mono[i];
+                            left[i] += v;
+                            right[i] += v;
+                        }                
+                    }
+                    else
+                    {
+                        for (int i = 0; i < bufferlen; i++) {
+                            left[i] += mono[i];
+                        }                                
+                    }                              
+                }                
 
                 for (int i = 0; i < cbuffer.length; i++) {
                     float[] cbuff = cbuffer[i];
@@ -539,6 +564,7 @@
 
             buffers[CHANNEL_LEFT] = leftbak;
             buffers[CHANNEL_RIGHT] = rightbak;
+            buffers[CHANNEL_MONO] = monobak;
 
         }
 
@@ -546,6 +572,27 @@
             if (voicestatus[i].active)
                 if (voicestatus[i].channelmixer == null)
                     voicestatus[i].processAudioLogic(buffers);
+        
+        if(!buffers[CHANNEL_MONO].isSilent())
+        {
+            float[] mono = buffers[CHANNEL_MONO].array();
+            float[] left = buffers[CHANNEL_LEFT].array();            
+            int bufferlen = buffers[CHANNEL_LEFT].getSize();
+            if (nrofchannels != 1) {
+                float[] right = buffers[CHANNEL_RIGHT].array();
+                for (int i = 0; i < bufferlen; i++) {
+                    float v = mono[i];
+                    left[i] += v;
+                    right[i] += v;
+                }                
+            }
+            else
+            {
+                for (int i = 0; i < bufferlen; i++) {
+                    left[i] += mono[i];
+                }                                
+            }            
+        }
 
         // Run effects
         if (synth.chorus_on)
@@ -665,7 +712,7 @@
                                 / synth.getControlRate());
 
         control_mutex = synth.control_mutex;
-        buffers = new SoftAudioBuffer[16];
+        buffers = new SoftAudioBuffer[17];
         for (int i = 0; i < buffers.length; i++) {
             buffers[i] = new SoftAudioBuffer(buffersize, synth.getFormat());
         }
--- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java	Sun Nov 09 22:31:21 2008 +0100
+++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java	Mon Nov 10 12:43:00 2008 +0100
@@ -782,6 +782,7 @@
 
         SoftAudioBuffer left = buffer[SoftMainMixer.CHANNEL_LEFT];
         SoftAudioBuffer right = buffer[SoftMainMixer.CHANNEL_RIGHT];
+        SoftAudioBuffer mono = buffer[SoftMainMixer.CHANNEL_MONO];
         SoftAudioBuffer eff1 = buffer[SoftMainMixer.CHANNEL_EFFECT1];
         SoftAudioBuffer eff2 = buffer[SoftMainMixer.CHANNEL_EFFECT2];
         SoftAudioBuffer leftdry = buffer[SoftMainMixer.CHANNEL_LEFT_DRY];
@@ -802,17 +803,26 @@
             if (rightdry != null)
                 mixAudioStream(rightdry, left, last_out_mixer_left,
                         out_mixer_left);
-        } else {
-            mixAudioStream(leftdry, left, last_out_mixer_left, out_mixer_left);
-            if (rightdry != null)
-                mixAudioStream(rightdry, right, last_out_mixer_right,
+        } else {            
+            if(rightdry == null && 
+                    last_out_mixer_left == last_out_mixer_right &&
+                    out_mixer_left == out_mixer_right)
+            {
+                mixAudioStream(leftdry, mono, last_out_mixer_left, out_mixer_left);
+            }
+            else
+            {
+                mixAudioStream(leftdry, left, last_out_mixer_left, out_mixer_left);
+                if (rightdry != null)
+                    mixAudioStream(rightdry, right, last_out_mixer_right,
                         out_mixer_right);
-            else
-                mixAudioStream(leftdry, right, last_out_mixer_right,
+                else
+                    mixAudioStream(leftdry, right, last_out_mixer_right,
                         out_mixer_right);
+            }
         }
 
-        if (rightdry == null) {
+        if (rightdry == null) {            
             mixAudioStream(leftdry, eff1, last_out_mixer_effect1,
                     out_mixer_effect1);
             mixAudioStream(leftdry, eff2, last_out_mixer_effect2,