United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6748247 Further update Gervill with still more post 1.0 fixes
JDK-6748247 : Further update Gervill with still more post 1.0 fixes

Details
Type:
Bug
Submit Date:
2008-09-15
Status:
Resolved
Updated Date:
2011-01-19
Project Name:
JDK
Resolved Date:
2008-09-22
Component:
client-libs
OS:
generic
Sub-Component:
javax.sound
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
OpenJDK6
Fixed Versions:
OpenJDK6 (b12)

Related Reports
Backport:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
The Gervill project continues to evolve and OpenJDK 6 should keep pace.

                                    

Comments
EVALUATION

Yes.
                                     
2008-09-15
SUGGESTED FIX

--- old/src/share/classes/com/sun/media/sound/ModelByteBuffer.java	Sun Sep 14 23:15:37 2008
+++ new/src/share/classes/com/sun/media/sound/ModelByteBuffer.java	Sun Sep 14 23:15:37 2008
@@ -85,11 +85,12 @@
         }
 
         public long skip(long n) throws IOException {
+            if( n < 0)
+                return 0;
             if (n > left)
                 n = left;
-            n = super.skip(n);
-            if (n == -1)
-                return -1;
+            long p = raf.getFilePointer();
+            raf.seek(p + n);
             left -= n;
             return n;
         }
--- old/src/share/classes/com/sun/media/sound/SoftMainMixer.java	Sun Sep 14 23:15:38 2008
+++ new/src/share/classes/com/sun/media/sound/SoftMainMixer.java	Sun Sep 14 23:15:38 2008
@@ -69,7 +69,7 @@
     private int nrofchannels = 2;
     private SoftVoice[] voicestatus = null;
     private SoftAudioBuffer[] buffers;
-    private SoftAudioProcessor reverb;
+    private SoftReverb reverb;
     private SoftAudioProcessor chorus;
     private SoftAudioProcessor agc;
     private long msec_buffer_len = 0;
@@ -681,6 +681,8 @@
         chorus.init(samplerate, controlrate);
         agc.init(samplerate, controlrate);
 
+        reverb.setLightMode(synth.reverb_light);
+        
         reverb.setMixMode(true);
         chorus.setMixMode(true);
         agc.setMixMode(false);
--- old/src/share/classes/com/sun/media/sound/SoftReverb.java	Sun Sep 14 23:15:39 2008
+++ new/src/share/classes/com/sun/media/sound/SoftReverb.java	Sun Sep 14 23:15:39 2008
@@ -35,7 +35,7 @@
  */
 public class SoftReverb implements SoftAudioProcessor {
 
-    private static class Delay {
+    private final static class Delay {
 
         private float[] delaybuffer;
         private int rovepos = 0;
@@ -52,31 +52,28 @@
             rovepos = 0;
         }
 
-        public void processReplace(float[] in, float[] out) {
-            float[] delaybuffer = this.delaybuffer;
+        public void processReplace(float[] inout) {
             if (delaybuffer == null)
                 return;
-            int len = in.length;
+            int len = inout.length;
             int rnlen = delaybuffer.length;
             int rovepos = this.rovepos;
 
             for (int i = 0; i < len; i++) {
-                float x = in[i];
-                out[i] = delaybuffer[rovepos];
+                float x = inout[i];
+                inout[i] = delaybuffer[rovepos];
                 delaybuffer[rovepos] = x;
-                rovepos = rovepos + 1;
-                if (rovepos == rnlen)
+                if (++rovepos == rnlen)
                     rovepos = 0;
-                //rovepos = (rovepos + 1) % rnlen;
             }
             this.rovepos = rovepos;
         }
     }
 
-    private static class AllPass {
+    private final static class AllPass {
 
-        private float[] delaybuffer;
-        private int delaybuffersize;
+        private final float[] delaybuffer;
+        private final int delaybuffersize;
         private int rovepos = 0;
         private float feedback;
 
@@ -88,47 +85,42 @@
         public void setFeedBack(float feedback) {
             this.feedback = feedback;
         }
-        int ucount = 0;
 
+        public void processReplace(float inout[]) {
+            int len = inout.length;
+            int delaybuffersize = this.delaybuffersize;
+            int rovepos = this.rovepos;            
+            for (int i = 0; i < len; i++) {
+                float delayout = delaybuffer[rovepos];
+                float input = inout[i];
+                inout[i] = delayout - input;
+                delaybuffer[rovepos] = input + delayout * feedback;
+                if (++rovepos == delaybuffersize)
+                    rovepos = 0;
+            }
+            this.rovepos = rovepos;                        
+        }
+        
         public void processReplace(float in[], float out[]) {
             int len = in.length;
+            int delaybuffersize = this.delaybuffersize;
+            int rovepos = this.rovepos;            
             for (int i = 0; i < len; i++) {
-
                 float delayout = delaybuffer[rovepos];
-
-                // undenormalise(delayout)
-                /*
-                if (((delayout > 0.0) && (delayout < 1.0E-10))
-                        || ((delayout < 0.0) && (delayout > -1.0E-10)))
-                    delayout = 0;
-                */
-
                 float input = in[i];
-                out[i] = -input + delayout;
+                out[i] = delayout - input;
                 delaybuffer[rovepos] = input + delayout * feedback;
                 if (++rovepos == delaybuffersize)
                     rovepos = 0;
             }
-
-            ucount++;
-            if (ucount == 10) {
-                ucount = 0;
-                for (int i = 0; i < delaybuffer.length; i++) {
-                    double v = delaybuffer[i];
-                    if (((v > 0.0) && (v < 1.0E-10))
-                            || ((v < 0.0) && (v > -1.0E-10))) {
-                        delaybuffer[i] = 0;
-                    }
-                }
-            }
-
-        }
+            this.rovepos = rovepos;                        
+        }        
     }
 
-    private static class Comb {
+    private final static class Comb {
 
-        private float[] delaybuffer;
-        private int delaybuffersize;
+        private final float[] delaybuffer;
+        private final int delaybuffersize;
         private int rovepos = 0;
         private float feedback;
         private float filtertemp = 0;
@@ -142,56 +134,54 @@
 
         public void setFeedBack(float feedback) {
             this.feedback = feedback;
+            filtercoeff2 = (1 - filtercoeff1)* feedback;
         }
-        int ucount = 0;
 
         public void processMix(float in[], float out[]) {
-            int len = in.length;
-
-            float filtercoeff2 = this.filtercoeff2 * feedback;
-
+            int len = in.length;            
+            int delaybuffersize = this.delaybuffersize;
+            int rovepos = this.rovepos;
+            float filtertemp = this.filtertemp;
+            float filtercoeff1 = this.filtercoeff1;
+            float filtercoeff2 = this.filtercoeff2;
             for (int i = 0; i < len; i++) {
                 float delayout = delaybuffer[rovepos];
-
                 // One Pole Lowpass Filter
                 filtertemp = (delayout * filtercoeff2)
                         + (filtertemp * filtercoeff1);
-
-                // undenormalise(filtertemp)
-                /*
-                if (((filtertemp > 0.0) && (filtertemp < 1.0E-10))
-                        || ((filtertemp < 0.0) && (filtertemp > -1.0E-10)))
-                    filtertemp = 0;
-                */
                 out[i] += delayout;
-                delaybuffer[rovepos] = in[i] + (filtertemp);// * feedback);
-
+                delaybuffer[rovepos] = in[i] + filtertemp;
                 if (++rovepos == delaybuffersize)
                     rovepos = 0;
+            }            
+            this.filtertemp  = filtertemp;
+            this.rovepos = rovepos;
+        }
 
-            }
-            ucount++;
-            if (ucount == 10) {
-                ucount = 0;
-                if (((filtertemp > 0.0) && (filtertemp < 1.0E-10))
-                        || ((filtertemp < 0.0) && (filtertemp > -1.0E-10))) {
-                    filtertemp = 0;
-                }
-                for (int i = 0; i < delaybuffer.length; i++) {
-                    double v = delaybuffer[i];
-                    if (((v > 0.0) && (v < 1.0E-10))
-                            || ((v < 0.0) && (v > -1.0E-10))) {
-                        delaybuffer[i] = 0;
-                    }
-                }
-            }
-
-
+        public void processReplace(float in[], float out[]) {
+            int len = in.length;            
+            int delaybuffersize = this.delaybuffersize;
+            int rovepos = this.rovepos;
+            float filtertemp = this.filtertemp;
+            float filtercoeff1 = this.filtercoeff1;
+            float filtercoeff2 = this.filtercoeff2;
+            for (int i = 0; i < len; i++) {
+                float delayout = delaybuffer[rovepos];
+                // One Pole Lowpass Filter
+                filtertemp = (delayout * filtercoeff2)
+                        + (filtertemp * filtercoeff1);
+                out[i] = delayout;
+                delaybuffer[rovepos] = in[i] + filtertemp;
+                if (++rovepos == delaybuffersize)
+                    rovepos = 0;
+            }            
+            this.filtertemp  = filtertemp;
+            this.rovepos = rovepos;
         }
 
         public void setDamp(float val) {
             filtercoeff1 = val;
-            filtercoeff2 = 1 - filtercoeff1;
+            filtercoeff2 = (1 - filtercoeff1)* feedback;
         }
     }
     private float roomsize;
@@ -203,8 +193,11 @@
     private AllPass[] allpassL;
     private AllPass[] allpassR;
     private float[] input;
-    private float[] outR;
-    private float[] outL;
+    private float[] out;
+    private float[] pre1;
+    private float[] pre2;
+    private float[] pre3;
+    private boolean denormal_flip = false;
     private boolean mix = true;
     private SoftAudioBuffer inputA;
     private SoftAudioBuffer left;
@@ -214,7 +207,8 @@
     private float dirty_damp;
     private float dirty_predelay;
     private float dirty_gain;
-    private float samplerate;
+    private float samplerate;    
+    private boolean light = true;
 
     public void init(float samplerate, float controlrate) {
         this.samplerate = samplerate;
@@ -237,7 +231,7 @@
         combL[3] = new Comb((int) (freqscale * (1356)));
         combR[3] = new Comb((int) (freqscale * (1356 + stereospread)));
         combL[4] = new Comb((int) (freqscale * (1422)));
-        combR[4] = new Comb((int) (freqscale * (1422 + stereospread)));
+        combR[4] = new Comb((int) (freqscale * (1422 + stereospread)));        
         combL[5] = new Comb((int) (freqscale * (1491)));
         combR[5] = new Comb((int) (freqscale * (1491 + stereospread)));
         combL[6] = new Comb((int) (freqscale * (1557)));
@@ -306,58 +300,100 @@
             input = new float[numsamples];
 
         float again = gain * 0.018f / 2;
+        
+        denormal_flip = !denormal_flip;
+        if(denormal_flip)
+            for (int i = 0; i < numsamples; i++) 
+                input[i] = inputA[i] * again + 1E-20f;
+        else
+            for (int i = 0; i < numsamples; i++) 
+                input[i] = inputA[i] * again - 1E-20f;
 
-        for (int i = 0; i < numsamples; i++)
-            input[i] = inputA[i] * again;
-
-        delay.processReplace(input, input);
-
-
-        if (right != null) {
-            if (outR == null || outR.length < numsamples)
-                outR = new float[numsamples];
-            Arrays.fill(outR, 0);
-            for (int i = 0; i < combR.length; i++)
-                combR[i].processMix(input, outR);
+        delay.processReplace(input);
+                      
+        if(light && (right != null))
+        {
+            if (pre1 == null || pre1.length < numsamples)
+            {
+                pre1 = new float[numsamples];
+                pre2 = new float[numsamples];
+                pre3 = new float[numsamples];
+            }
+            
             for (int i = 0; i < allpassL.length; i++)
-                allpassR[i].processReplace(outR, outR);
+                allpassL[i].processReplace(input);
 
-            if (mix) {
-                for (int i = 0; i < numsamples; i++)
-                    right[i] += outR[i];
-            } else {
-                for (int i = 0; i < numsamples; i++)
-                    right[i] = outR[i];
+            combL[0].processReplace(input, pre3);
+            combL[1].processReplace(input, pre3);
+
+            combL[2].processReplace(input, pre1);
+            for (int i = 4; i < combL.length-2; i+=2)
+                combL[i].processMix(input, pre1); 
+            
+            combL[3].processReplace(input, pre2);;
+            for (int i = 5; i < combL.length-2; i+=2)            
+                combL[i].processMix(input, pre2);
+                                        
+            if (!mix)
+            {
+                Arrays.fill(right, 0);            
+                Arrays.fill(left, 0);
             }
+            for (int i = combR.length-2; i < combR.length; i++)
+                combR[i].processMix(input, right);            
+            for (int i = combL.length-2; i < combL.length; i++)
+                combL[i].processMix(input, left);
+            
+            for (int i = 0; i < numsamples; i++) 
+            {
+                float p = pre1[i] - pre2[i];
+                float m = pre3[i];
+                left[i] += m + p;
+                right[i] += m - p;
+            }
         }
+        else
+        {
+            if (out == null || out.length < numsamples)
+                out = new float[numsamples];
+            
+            if (right != null) {
+                if (!mix)            
+                    Arrays.fill(right, 0);                        
+                allpassR[0].processReplace(input, out);
+                for (int i = 1; i < allpassR.length; i++)
+                    allpassR[i].processReplace(out);
+                for (int i = 0; i < combR.length; i++)
+                    combR[i].processMix(out, right);
+            }
 
-
-        if (outL == null || outL.length < numsamples)
-            outL = new float[numsamples];
-        Arrays.fill(outL, 0);
-        for (int i = 0; i < combL.length; i++)
-            combL[i].processMix(input, outL);
-        for (int i = 0; i < allpassL.length; i++)
-            allpassL[i].processReplace(outL, outL);
-        
-        if (mix) {
-            for (int i = 0; i < numsamples; i++)
-                left[i] += outL[i];
-        } else {
-            for (int i = 0; i < numsamples; i++)
-                left[i] = outL[i];
+            if (!mix)            
+                Arrays.fill(left, 0);                    
+            allpassL[0].processReplace(input, out);
+            for (int i = 1; i < allpassL.length; i++)
+                allpassL[i].processReplace(out);
+            for (int i = 0; i < combL.length; i++)
+                combL[i].processMix(out, left);            
         }
+        
+        
+        
+        
+        
 
         if (silent_input) {
-            float avgpower = 0; 
+            silent = true;
             for (int i = 0; i < numsamples; i++)
-                avgpower += outL[i]*outL[i];
-            avgpower /= numsamples;
-            avgpower = (float)Math.sqrt(avgpower);
-            if(avgpower < 0.00001)
-                silent = true;
-        } 
-
+            {
+                float v = left[i];
+                if(v > 1E-10 || v < -1E-10)
+                {
+                    silent = false;
+                    break;
+                }
+            }
+        }
+        
     }
 
     public void globalParameterControlChange(int[] slothpath, long param,
@@ -440,7 +476,7 @@
     public void setRoomSize(float value) {
         roomsize = 1 - (0.17f / value);
 
-        for (int i = 0; i < 8; i++) {
+        for (int i = 0; i < combL.length; i++) {
             combL[i].feedback = roomsize;
             combR[i].feedback = roomsize;
         }
@@ -464,10 +500,16 @@
             damp = 0;
 
         // damp = value * 0.4f;
-        for (int i = 0; i < 8; i++) {
+        for (int i = 0; i < combL.length; i++) {
             combL[i].setDamp(damp);
             combR[i].setDamp(damp);
         }
 
     }
+    
+    public void setLightMode(boolean light)
+    {
+        this.light = light;
+    }
 }
+
--- old/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java	Sun Sep 14 23:15:40 2008
+++ new/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java	Sun Sep 14 23:15:40 2008
@@ -47,6 +47,8 @@
             return new DLSSoundbank(url);
         } catch (RIFFInvalidFormatException e) {
             return null;
+        } catch(IOException ioe) {
+            return null;
         }
     }
 
--- old/src
                                     
2008-09-22



Hardware and Software, Engineered to Work Together