changeset 1450:1c9ba5e52e34

Add missing Gervill test files. 2008-11-24 Mark Wielaard <mark@klomp.org> * overlays/openjdk/jdk/test/com/sun/media/sound/ EmergencySoundbank/TestCreateSoundbank.java ModelByteBuffer/RandomFileInputStream/Available.java ModelByteBuffer/RandomFileInputStream/Close.java ModelByteBuffer/RandomFileInputStream/MarkReset.java ModelByteBuffer/RandomFileInputStream/MarkSupported.java ModelByteBuffer/RandomFileInputStream/Read.java ModelByteBuffer/RandomFileInputStream/ReadByte.java ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java ModelByteBuffer/RandomFileInputStream/Skip.java SoftAudioSynthesizer/DummySourceDataLine.java SoftFilter/TestProcessAudio.java SoftSynthesizer/DummySourceDataLine.java: Add missing Gervill test files.
author Mark Wielaard <mark@klomp.org>
date Mon, 24 Nov 2008 13:30:00 +0100
parents b7ce0d293432
children 0d528f5c93eb
files ChangeLog overlays/openjdk/jdk/test/com/sun/media/sound/EmergencySoundbank/TestCreateSoundbank.java overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/Available.java overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/Close.java overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/MarkReset.java overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/MarkSupported.java overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/Read.java overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/ReadByte.java overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/Skip.java overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioSynthesizer/DummySourceDataLine.java overlays/openjdk/jdk/test/com/sun/media/sound/SoftFilter/TestProcessAudio.java overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/DummySourceDataLine.java
diffstat 13 files changed, 1519 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Nov 23 17:46:11 2008 +0100
+++ b/ChangeLog	Mon Nov 24 13:30:00 2008 +0100
@@ -1,3 +1,20 @@
+2008-11-24  Mark Wielaard  <mark@klomp.org>
+
+	* overlays/openjdk/jdk/test/com/sun/media/sound/
+	EmergencySoundbank/TestCreateSoundbank.java
+	ModelByteBuffer/RandomFileInputStream/Available.java
+	ModelByteBuffer/RandomFileInputStream/Close.java
+	ModelByteBuffer/RandomFileInputStream/MarkReset.java
+	ModelByteBuffer/RandomFileInputStream/MarkSupported.java
+	ModelByteBuffer/RandomFileInputStream/Read.java
+	ModelByteBuffer/RandomFileInputStream/ReadByte.java
+	ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java
+	ModelByteBuffer/RandomFileInputStream/Skip.java
+	SoftAudioSynthesizer/DummySourceDataLine.java
+	SoftFilter/TestProcessAudio.java
+	SoftSynthesizer/DummySourceDataLine.java: Add missing Gervill
+	test files.
+
 2008-11-23  Mark Wielaard  <mark@klomp.org>
 
 	* patches/icedtea-samejvm-safe.patch: New patch.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/EmergencySoundbank/TestCreateSoundbank.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,59 @@
+import java.io.File;
+
+import javax.sound.midi.Instrument;
+import javax.sound.midi.Patch;
+import javax.sound.midi.Soundbank;
+
+import com.sun.media.sound.EmergencySoundbank;
+import com.sun.media.sound.ModelInstrument;
+import com.sun.media.sound.ModelPatch;
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ @summary Test EmergencySoundbank createSoundbank() method */
+
+public class TestCreateSoundbank {
+
+    public static void main(String[] args) throws Exception {
+        
+        Soundbank soundbank = EmergencySoundbank.createSoundbank();
+        for (int i = 0; i < 128; i++) {
+            Patch patch = new ModelPatch(0, i, false);
+            ModelInstrument ins = (ModelInstrument)soundbank.getInstrument(patch);
+            if(ins == null)
+                throw new Exception("Instrument " + i + " is missing!");
+            if(ins.getPerformers().length == 0)
+                throw new Exception("Instrument " + i + " doesn't have any performers!");
+        }
+        Patch patch = new ModelPatch(0, 0, true);
+        ModelInstrument ins = (ModelInstrument)soundbank.getInstrument(patch);
+        if(ins == null)
+            throw new Exception("Drumkit instrument is missing!");
+        if(ins.getPerformers().length == 0)
+            throw new Exception("Drumkit instrument doesn't have any performers!");
+    }   
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/Available.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @summary Test ModelByteBuffer.RandomFileInputStream available() method */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.sampled.*;
+
+import com.sun.media.sound.*;
+
+public class Available {
+
+    static float[] testarray;
+    static byte[] test_byte_array;  
+    static File test_file;
+    static AudioFormat format = new AudioFormat(44100, 16, 1, true, false);
+    
+    static void setUp() throws Exception {
+        testarray = new float[1024];
+        for (int i = 0; i < 1024; i++) {
+            double ii = i / 1024.0;
+            ii = ii * ii;
+            testarray[i] = (float)Math.sin(10*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI);
+            testarray[i] *= 0.3;
+        }       
+        test_byte_array = new byte[testarray.length*2];
+        AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array);
+        test_file = File.createTempFile("test", ".raw");
+        FileOutputStream fos = new FileOutputStream(test_file);
+        fos.write(test_byte_array);
+    }   
+    
+    static void tearDown() throws Exception {
+        if(!test_file.delete())
+            test_file.deleteOnExit();
+    }           
+    
+    public static void main(String[] args) throws Exception {
+        try
+        {
+            setUp();
+            
+            for (int i = 0; i < 8; i++) {
+                ModelByteBuffer buff;
+                if(i % 2 == 0)
+                    buff = new ModelByteBuffer(test_file);
+                else
+                    buff = new ModelByteBuffer(test_byte_array);
+                if((i / 2) == 1)
+                    buff.subbuffer(5);
+                if((i / 2) == 2)
+                    buff.subbuffer(5,500);
+                if((i / 2) == 3)
+                    buff.subbuffer(5,600,true);
+                
+                long capacity = buff.capacity();
+                InputStream is = buff.getInputStream();
+                try
+                {                                     
+                    int ret = is.available();
+                    if(ret != capacity)
+                        throw new RuntimeException("is.available() return unexpected value!");
+                }
+                finally
+                {
+                    is.close();
+                }
+                if(buff.capacity() != capacity)
+                    throw new RuntimeException("Capacity variable should not change!");                
+            }           
+        }
+        finally
+        {
+            tearDown();
+        }       
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/Close.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @summary Test ModelByteBuffer.RandomFileInputStream close method */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.sampled.*;
+
+import com.sun.media.sound.*;
+
+public class Close {
+
+    static float[] testarray;
+    static byte[] test_byte_array;  
+    static File test_file;
+    static AudioFormat format = new AudioFormat(44100, 16, 1, true, false);
+    
+    static void setUp() throws Exception {
+        testarray = new float[1024];
+        for (int i = 0; i < 1024; i++) {
+            double ii = i / 1024.0;
+            ii = ii * ii;
+            testarray[i] = (float)Math.sin(10*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI);
+            testarray[i] *= 0.3;
+        }       
+        test_byte_array = new byte[testarray.length*2];
+        AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array);
+        test_file = File.createTempFile("test", ".raw");
+        FileOutputStream fos = new FileOutputStream(test_file);
+        fos.write(test_byte_array);
+    }   
+    
+    static void tearDown() throws Exception {
+        if(!test_file.delete())
+            test_file.deleteOnExit();
+    }           
+    
+    public static void main(String[] args) throws Exception {
+        try
+        {
+            setUp();
+            
+            for (int i = 0; i < 8; i++) {
+                ModelByteBuffer buff;
+                if(i % 2 == 0)
+                    buff = new ModelByteBuffer(test_file);
+                else
+                    buff = new ModelByteBuffer(test_byte_array);
+                if((i / 2) == 1)
+                    buff.subbuffer(5);
+                if((i / 2) == 2)
+                    buff.subbuffer(5,500);
+                if((i / 2) == 3)
+                    buff.subbuffer(5,600,true);
+                
+                long capacity = buff.capacity();
+                InputStream is = buff.getInputStream();
+                try
+                {                    
+                }
+                finally
+                {
+                    is.close();
+                }
+                if(buff.capacity() != capacity)
+                    throw new RuntimeException("Capacity variable should not change!");
+            }           
+        }
+        finally
+        {
+            tearDown();
+        }       
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/MarkReset.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @summary Test ModelByteBuffer.RandomFileInputStream mark and reset methods */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.sampled.*;
+
+import com.sun.media.sound.*;
+
+public class MarkReset {
+
+    static float[] testarray;
+    static byte[] test_byte_array;  
+    static File test_file;
+    static AudioFormat format = new AudioFormat(44100, 16, 1, true, false);
+    
+    static void setUp() throws Exception {
+        testarray = new float[1024];
+        for (int i = 0; i < 1024; i++) {
+            double ii = i / 1024.0;
+            ii = ii * ii;
+            testarray[i] = (float)Math.sin(10*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI);
+            testarray[i] *= 0.3;
+        }       
+        test_byte_array = new byte[testarray.length*2];
+        AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array);
+        test_file = File.createTempFile("test", ".raw");
+        FileOutputStream fos = new FileOutputStream(test_file);
+        fos.write(test_byte_array);
+    }   
+    
+    static void tearDown() throws Exception {
+        if(!test_file.delete())
+            test_file.deleteOnExit();
+    }           
+    
+    public static void main(String[] args) throws Exception {
+        try
+        {
+            setUp();
+            
+            for (int i = 0; i < 8; i++) {
+                ModelByteBuffer buff;
+                if(i % 2 == 0)
+                    buff = new ModelByteBuffer(test_file);
+                else
+                    buff = new ModelByteBuffer(test_byte_array);
+                if((i / 2) == 1)
+                    buff.subbuffer(5);
+                if((i / 2) == 2)
+                    buff.subbuffer(5,500);
+                if((i / 2) == 3)
+                    buff.subbuffer(5,600,true);
+                
+                long capacity = buff.capacity();
+                InputStream is = buff.getInputStream();
+                try
+                {                
+                    is.mark(1000);
+                    int ret = is.available();
+                    int a = is.read();
+                    is.skip(75);                          
+                    is.reset();
+                    if(is.available() != ret)
+                        throw new RuntimeException(
+                                "is.available() returns incorrect value ("
+                                + is.available() + "!="+(ret)+") !");
+                    int b = is.read();
+                    if(a != b)
+                        throw new RuntimeException(
+                                "is doesn't return same value after reset ("
+                                + a + "!="+b+") !");
+                    
+                    is.skip(15);        
+                    ret = is.available();
+                    is.mark(1000);
+                    is.reset();
+                    if(is.available() != ret)
+                        throw new RuntimeException(
+                                "is.available() returns incorrect value ("
+                                + is.available() + "!="+(ret)+") !");
+                   
+                    
+                }
+                finally
+                {
+                    is.close();
+                }
+                if(buff.capacity() != capacity)
+                    throw new RuntimeException("Capacity variable should not change!");                
+            }           
+        }
+        finally
+        {
+            tearDown();
+        }       
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/MarkSupported.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @summary Test ModelByteBuffer.RandomFileInputStream markSupported() method */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.sampled.*;
+
+import com.sun.media.sound.*;
+
+public class MarkSupported {
+
+    static float[] testarray;
+    static byte[] test_byte_array;  
+    static File test_file;
+    static AudioFormat format = new AudioFormat(44100, 16, 1, true, false);
+    
+    static void setUp() throws Exception {
+        testarray = new float[1024];
+        for (int i = 0; i < 1024; i++) {
+            double ii = i / 1024.0;
+            ii = ii * ii;
+            testarray[i] = (float)Math.sin(10*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI);
+            testarray[i] *= 0.3;
+        }       
+        test_byte_array = new byte[testarray.length*2];
+        AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array);
+        test_file = File.createTempFile("test", ".raw");
+        FileOutputStream fos = new FileOutputStream(test_file);
+        fos.write(test_byte_array);
+    }   
+    
+    static void tearDown() throws Exception {
+        if(!test_file.delete())
+            test_file.deleteOnExit();
+    }           
+    
+    public static void main(String[] args) throws Exception {
+        try
+        {
+            setUp();
+            
+            for (int i = 0; i < 8; i++) {
+                ModelByteBuffer buff;
+                if(i % 2 == 0)
+                    buff = new ModelByteBuffer(test_file);
+                else
+                    buff = new ModelByteBuffer(test_byte_array);
+                if((i / 2) == 1)
+                    buff.subbuffer(5);
+                if((i / 2) == 2)
+                    buff.subbuffer(5,500);
+                if((i / 2) == 3)
+                    buff.subbuffer(5,600,true);
+                
+                long capacity = buff.capacity();
+                InputStream is = buff.getInputStream();
+                try
+                {               
+                    if(!is.markSupported())
+                        throw new RuntimeException("InputStream doesn't support mark/reset!");
+                }
+                finally
+                {
+                    is.close();
+                }
+                if(buff.capacity() != capacity)
+                    throw new RuntimeException("Capacity variable should not change!");                
+            }           
+        }
+        finally
+        {
+            tearDown();
+        }       
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/Read.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @summary Test ModelByteBuffer.RandomFileInputStream read() method */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.sampled.*;
+
+import com.sun.media.sound.*;
+
+public class Read {
+
+    static float[] testarray;
+    static byte[] test_byte_array;  
+    static File test_file;
+    static AudioFormat format = new AudioFormat(44100, 16, 1, true, false);
+    
+    static void setUp() throws Exception {
+        testarray = new float[1024];
+        for (int i = 0; i < 1024; i++) {
+            double ii = i / 1024.0;
+            ii = ii * ii;
+            testarray[i] = (float)Math.sin(10*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI);
+            testarray[i] *= 0.3;
+        }       
+        test_byte_array = new byte[testarray.length*2];
+        AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array);
+        test_file = File.createTempFile("test", ".raw");
+        FileOutputStream fos = new FileOutputStream(test_file);
+        fos.write(test_byte_array);
+    }   
+    
+    static void tearDown() throws Exception {
+        if(!test_file.delete())
+            test_file.deleteOnExit();
+    }           
+    
+    public static void main(String[] args) throws Exception {
+        try
+        {
+            setUp();
+            
+            for (int i = 0; i < 8; i++) {
+                ModelByteBuffer buff;
+                if(i % 2 == 0)
+                    buff = new ModelByteBuffer(test_file);
+                else
+                    buff = new ModelByteBuffer(test_byte_array);
+                if((i / 2) == 1)
+                    buff.subbuffer(5);
+                if((i / 2) == 2)
+                    buff.subbuffer(5,500);
+                if((i / 2) == 3)
+                    buff.subbuffer(5,600,true);
+                
+                long capacity = buff.capacity();
+                InputStream is = buff.getInputStream();
+                try
+                {                 
+                    byte[] b = new byte[100];
+                    int ret = is.available();
+                    int n = is.read();
+                    if(n == -1)                    
+                        throw new RuntimeException("is.read shouldn't return -1!");
+                    if(is.available() != ret - 1)
+                        throw new RuntimeException(
+                                "is.available() returns incorrect value ("
+                                + is.available() + "!="+(ret - 1)+") !");
+                    is.skip(5000);
+                    if(is.read() != -1)
+                        throw new RuntimeException(
+                                "is.read() doesn't return -1!");
+                }
+                finally
+                {
+                    is.close();
+                }
+                if(buff.capacity() != capacity)
+                    throw new RuntimeException("Capacity variable should not change!");                
+            }           
+        }
+        finally
+        {
+            tearDown();
+        }       
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/ReadByte.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @summary Test ModelByteBuffer.RandomFileInputStream read(byte[]) method */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.sampled.*;
+
+import com.sun.media.sound.*;
+
+public class ReadByte {
+
+    static float[] testarray;
+    static byte[] test_byte_array;  
+    static File test_file;
+    static AudioFormat format = new AudioFormat(44100, 16, 1, true, false);
+    
+    static void setUp() throws Exception {
+        testarray = new float[1024];
+        for (int i = 0; i < 1024; i++) {
+            double ii = i / 1024.0;
+            ii = ii * ii;
+            testarray[i] = (float)Math.sin(10*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI);
+            testarray[i] *= 0.3;
+        }       
+        test_byte_array = new byte[testarray.length*2];
+        AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array);
+        test_file = File.createTempFile("test", ".raw");
+        FileOutputStream fos = new FileOutputStream(test_file);
+        fos.write(test_byte_array);
+    }   
+    
+    static void tearDown() throws Exception {
+        if(!test_file.delete())
+            test_file.deleteOnExit();
+    }           
+    
+    public static void main(String[] args) throws Exception {
+        try
+        {
+            setUp();
+            
+            for (int i = 0; i < 8; i++) {
+                ModelByteBuffer buff;
+                if(i % 2 == 0)
+                    buff = new ModelByteBuffer(test_file);
+                else
+                    buff = new ModelByteBuffer(test_byte_array);
+                if((i / 2) == 1)
+                    buff.subbuffer(5);
+                if((i / 2) == 2)
+                    buff.subbuffer(5,500);
+                if((i / 2) == 3)
+                    buff.subbuffer(5,600,true);
+                
+                long capacity = buff.capacity();
+                InputStream is = buff.getInputStream();
+                try
+                {                 
+                    byte[] b = new byte[100];
+                    int ret = is.available();
+                    int n = is.read(b);
+                    if(n == -1)                    
+                        throw new RuntimeException("is.read shouldn't return -1!");
+                    if(is.available() != ret - n)
+                        throw new RuntimeException(
+                                "is.available() returns incorrect value ("
+                                + is.available() + "!="+(ret - n)+") !");
+                    is.skip(5000);
+                    if(is.read(b) != -1)
+                        throw new RuntimeException(
+                                "is.read() doesn't return -1!");
+                    
+                }
+                finally
+                {
+                    is.close();
+                }
+                if(buff.capacity() != capacity)
+                    throw new RuntimeException("Capacity variable should not change!");                
+            }           
+        }
+        finally
+        {
+            tearDown();
+        }       
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @summary Test ModelByteBuffer.RandomFileInputStream read(byte[], int, int) method */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.sampled.*;
+
+import com.sun.media.sound.*;
+
+public class ReadByteIntInt {
+
+    static float[] testarray;
+    static byte[] test_byte_array;  
+    static File test_file;
+    static AudioFormat format = new AudioFormat(44100, 16, 1, true, false);
+    
+    static void setUp() throws Exception {
+        testarray = new float[1024];
+        for (int i = 0; i < 1024; i++) {
+            double ii = i / 1024.0;
+            ii = ii * ii;
+            testarray[i] = (float)Math.sin(10*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI);
+            testarray[i] *= 0.3;
+        }       
+        test_byte_array = new byte[testarray.length*2];
+        AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array);
+        test_file = File.createTempFile("test", ".raw");
+        FileOutputStream fos = new FileOutputStream(test_file);
+        fos.write(test_byte_array);
+    }   
+    
+    static void tearDown() throws Exception {
+        if(!test_file.delete())
+            test_file.deleteOnExit();
+    }           
+    
+    public static void main(String[] args) throws Exception {
+        try
+        {
+            setUp();
+            
+            for (int i = 0; i < 8; i++) {
+                ModelByteBuffer buff;
+                if(i % 2 == 0)
+                    buff = new ModelByteBuffer(test_file);
+                else
+                    buff = new ModelByteBuffer(test_byte_array);
+                if((i / 2) == 1)
+                    buff.subbuffer(5);
+                if((i / 2) == 2)
+                    buff.subbuffer(5,500);
+                if((i / 2) == 3)
+                    buff.subbuffer(5,600,true);
+                
+                long capacity = buff.capacity();
+                InputStream is = buff.getInputStream();
+                try
+                {                 
+                    byte[] b = new byte[100];
+                    int ret = is.available();
+                    int n = is.read(b, 7, 50);
+                    if(n == -1)                    
+                        throw new RuntimeException("is.read shouldn't return -1!");
+                    if(is.available() != ret - n)
+                        throw new RuntimeException(
+                                "is.available() returns incorrect value ("
+                                + is.available() + "!="+(ret - n)+") !");
+                    is.skip(5000);
+                    if(is.read(b, 7, 50) != -1)
+                        throw new RuntimeException(
+                                "is.read() doesn't return -1!");
+                    
+                }
+                finally
+                {
+                    is.close();
+                }
+                if(buff.capacity() != capacity)
+                    throw new RuntimeException("Capacity variable should not change!");                
+            }           
+        }
+        finally
+        {
+            tearDown();
+        }       
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/RandomFileInputStream/Skip.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @summary Test ModelByteBuffer.RandomFileInputStream skip(long) method */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.sampled.*;
+
+import com.sun.media.sound.*;
+
+public class Skip {
+
+    static float[] testarray;
+    static byte[] test_byte_array;  
+    static File test_file;
+    static AudioFormat format = new AudioFormat(44100, 16, 1, true, false);
+    
+    static void setUp() throws Exception {
+        testarray = new float[1024];
+        for (int i = 0; i < 1024; i++) {
+            double ii = i / 1024.0;
+            ii = ii * ii;
+            testarray[i] = (float)Math.sin(10*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI);
+            testarray[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI);
+            testarray[i] *= 0.3;
+        }       
+        test_byte_array = new byte[testarray.length*2];
+        AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array);
+        test_file = File.createTempFile("test", ".raw");
+        FileOutputStream fos = new FileOutputStream(test_file);
+        fos.write(test_byte_array);
+    }   
+    
+    static void tearDown() throws Exception {
+        if(!test_file.delete())
+            test_file.deleteOnExit();
+    }           
+    
+    public static void main(String[] args) throws Exception {
+        try
+        {
+            setUp();
+            
+            for (int i = 0; i < 8; i++) {
+                ModelByteBuffer buff;
+                if(i % 2 == 0)
+                    buff = new ModelByteBuffer(test_file);
+                else
+                    buff = new ModelByteBuffer(test_byte_array);
+                if((i / 2) == 1)
+                    buff.subbuffer(5);
+                if((i / 2) == 2)
+                    buff.subbuffer(5,500);
+                if((i / 2) == 3)
+                    buff.subbuffer(5,600,true);
+                
+                long capacity = buff.capacity();
+                InputStream is = buff.getInputStream();
+                try
+                {                 
+                    int ret = is.available();
+                    long n = is.skip(75);
+                    if(n == -1)                    
+                        throw new RuntimeException("is.read shouldn't return -1!");
+                    if(is.available() != ret - n)
+                        throw new RuntimeException(
+                                "is.available() returns incorrect value ("
+                                + is.available() + "!="+(ret - n)+") !");
+                    
+                    ret = is.available();
+                    n = is.skip(-100);
+                    if(n != 0)                    
+                        throw new RuntimeException("is.skip(-100) shouldn't skip values!");
+                    if(is.available() != ret - n)
+                        throw new RuntimeException(
+                                "is.available() returns incorrect value ("
+                                + is.available() + "!="+(ret - n)+") !");
+
+                    ret = is.available();
+                    n = is.skip(5000);
+                    if(is.available() != ret - n)
+                        throw new RuntimeException(
+                                "is.available() returns incorrect value ("
+                                + is.available() + "!="+(ret - n)+") !");
+                    if(is.available() != 0)
+                        throw new RuntimeException(
+                                "is.available() returns incorrect value ("
+                                + is.available() + "!="+(0)+") !");                }
+                finally
+                {
+                    is.close();
+                }
+                if(buff.capacity() != capacity)
+                    throw new RuntimeException("Capacity variable should not change!");                
+            }           
+        }
+        finally
+        {
+            tearDown();
+        }       
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioSynthesizer/DummySourceDataLine.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,207 @@
+import java.util.ArrayList;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.Control;
+import javax.sound.sampled.DataLine;
+import javax.sound.sampled.LineListener;
+import javax.sound.sampled.LineUnavailableException;
+import javax.sound.sampled.SourceDataLine;
+import javax.sound.sampled.AudioFormat.Encoding;
+import javax.sound.sampled.Control.Type;
+
+import com.sun.media.sound.AudioFloatConverter;
+
+/**
+ * This is a SourceDataLine simulator used for testing SoftSynthesizer
+ * without using real SourceDataLine / Audio Device. 
+ * 
+ * @author Karl Helgason
+ */
+
+public class DummySourceDataLine implements SourceDataLine {
+
+    private int bufferSize = -1;
+
+    private AudioFormat format = new AudioFormat(44100.0f, 16, 2, true, false);
+    
+    private DataLine.Info sourceLineInfo;
+    
+    private boolean active = false;
+    
+    private long framepos = 0;
+    
+    private boolean opened = false;
+    
+    private int framesize = 0;
+    
+    public DummySourceDataLine()
+    {
+        ArrayList<AudioFormat> formats = new ArrayList<AudioFormat>();
+        for (int channels = 1; channels <= 2; channels++) {
+            formats.add(new AudioFormat(Encoding.PCM_SIGNED,
+                    AudioSystem.NOT_SPECIFIED, 8, channels, channels,
+                    AudioSystem.NOT_SPECIFIED, false));
+            formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
+                    AudioSystem.NOT_SPECIFIED, 8, channels, channels,
+                    AudioSystem.NOT_SPECIFIED, false));
+            for (int bits = 16; bits < 32; bits += 8) {
+                formats.add(new AudioFormat(Encoding.PCM_SIGNED,
+                        AudioSystem.NOT_SPECIFIED, bits, channels, channels
+                                * bits / 8, AudioSystem.NOT_SPECIFIED, false));
+                formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
+                        AudioSystem.NOT_SPECIFIED, bits, channels, channels
+                                * bits / 8, AudioSystem.NOT_SPECIFIED, false));
+                formats.add(new AudioFormat(Encoding.PCM_SIGNED,
+                        AudioSystem.NOT_SPECIFIED, bits, channels, channels
+                                * bits / 8, AudioSystem.NOT_SPECIFIED, true));
+                formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
+                        AudioSystem.NOT_SPECIFIED, bits, channels, channels
+                                * bits / 8, AudioSystem.NOT_SPECIFIED, true));
+            }
+            formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
+                    AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
+                    AudioSystem.NOT_SPECIFIED, false));
+            formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
+                    AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
+                    AudioSystem.NOT_SPECIFIED, true));
+            formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
+                    AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
+                    AudioSystem.NOT_SPECIFIED, false));
+            formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
+                    AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
+                    AudioSystem.NOT_SPECIFIED, true));
+        }
+        AudioFormat[] formats_array = formats.toArray(new AudioFormat[formats
+                .size()]);
+        sourceLineInfo = new DataLine.Info(SourceDataLine.class,
+                formats_array, AudioSystem.NOT_SPECIFIED,
+                AudioSystem.NOT_SPECIFIED);
+        
+    }
+
+    public void open() throws LineUnavailableException {
+        open(format);
+    }
+
+    public void open(AudioFormat format) throws LineUnavailableException {
+        if (bufferSize == -1)
+            bufferSize = ((int) (format.getFrameRate() / 2))
+                    * format.getFrameSize();
+        open(format, bufferSize);
+    }
+
+    public void open(AudioFormat format, int bufferSize)
+            throws LineUnavailableException {
+        this.format = format;
+        this.bufferSize = bufferSize;
+        this.framesize = format.getFrameSize();        
+        opened = true;
+    }
+    
+    public boolean isOpen() {
+        return opened;
+    }
+
+    public int write(byte[] b, int off, int len) {
+        if (!isOpen())
+            return 0;
+        if (len % framesize != 0)
+            throw new IllegalArgumentException(
+                    "Number of bytes does not represent an integral number of sample frames.");
+
+
+        int flen = len / framesize;
+        framepos += flen;
+        
+        long time =  (long) (flen * (1000.0 / (double) getFormat()
+                .getSampleRate()));
+        try {
+            Thread.sleep(time);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+            return 0;
+        }
+        
+        return len;
+    }
+
+    public int available() {
+        return 0;
+    }
+
+    public void drain() {
+    }
+
+    public void flush() {
+    }
+
+    public int getBufferSize() {
+        return bufferSize;
+    }
+
+    public AudioFormat getFormat() {
+        return format;
+    }
+
+    public int getFramePosition() {
+        return (int) getLongFramePosition();
+    }
+
+    public float getLevel() {
+        return AudioSystem.NOT_SPECIFIED;
+    }
+
+    public long getLongFramePosition() {
+        return framepos;
+    }
+
+    public long getMicrosecondPosition() {
+        return (long) (getLongFramePosition() * (1000000.0 / (double) getFormat()
+                .getSampleRate()));
+    }
+
+    public boolean isActive() {
+        return active;
+    }
+
+    public boolean isRunning() {
+        return active;
+    }
+
+    public void start() {
+        active = true;
+    }
+
+    public void stop() {
+        active = false;
+    }
+
+    public void close() {
+        stop(); 
+    }
+
+    public Control getControl(Type control) {
+        throw new IllegalArgumentException("Unsupported control type : "
+                + control);
+    }
+
+    public Control[] getControls() {
+        return new Control[0];
+    }
+
+    public javax.sound.sampled.Line.Info getLineInfo() {
+        return sourceLineInfo;
+    }
+
+    public boolean isControlSupported(Type control) {
+        return false;
+    }
+    
+    public void addLineListener(LineListener listener) {
+    }
+
+    public void removeLineListener(LineListener listener) {
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftFilter/TestProcessAudio.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+   @summary Test SoftFilter processAudio method */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Random;
+
+import javax.sound.sampled.*;
+
+import com.sun.media.sound.*;
+
+public class TestProcessAudio {
+
+    public static void main(String[] args) throws Exception {
+        AudioFormat format = new AudioFormat(44100, 16, 2, true, false);
+        SoftAudioBuffer sbuffer = new SoftAudioBuffer(3600, format);
+        SoftFilter filter = new SoftFilter(format.getSampleRate());
+        Random random = new Random(42);
+
+        
+        for (int t = 0; t <= 6; t++)
+        {
+            if(t == 0) filter.setFilterType(SoftFilter.FILTERTYPE_BP12);
+            if(t == 1) filter.setFilterType(SoftFilter.FILTERTYPE_HP12);
+            if(t == 2) filter.setFilterType(SoftFilter.FILTERTYPE_HP24);
+            if(t == 3) filter.setFilterType(SoftFilter.FILTERTYPE_LP12);
+            if(t == 4) filter.setFilterType(SoftFilter.FILTERTYPE_LP24);
+            if(t == 5) filter.setFilterType(SoftFilter.FILTERTYPE_LP6);
+            if(t == 6) filter.setFilterType(SoftFilter.FILTERTYPE_NP12);
+            
+            
+            // Try first by reseting always
+            for (int f = 1200; f < 3600; f+=100) 
+                for (int r = 0; r <= 30; r+=5) {
+                    filter.reset();
+                    filter.setResonance(r);
+                    filter.setFrequency(f);
+                    float[] data = sbuffer.array();
+                    int len = sbuffer.getSize();
+                    for (int i = 0; i < len; i++) 
+                        data[i] = random.nextFloat() - 0.5f;            
+                    filter.processAudio(sbuffer);                    
+                }
+            
+            // Now we skip reseting
+            // to test how changing frequency and resonance
+            // affect active filter
+            for (int f = 100; f < 12800; f+=1200) 
+            for (int r = 0; r <= 30; r+=5) {                       
+                filter.setResonance(r);
+                filter.setFrequency(f);
+                float[] data = sbuffer.array();
+                int len = sbuffer.getSize();
+                for (int i = 0; i < len; i++) 
+                    data[i] = random.nextFloat() - 0.5f;            
+                filter.processAudio(sbuffer);
+            }
+            for (int f = 12800; f >= 100; f-=1200) 
+                for (int r = 30; r >= 0; r-=5) {                       
+                    filter.setResonance(r);
+                    filter.setFrequency(f);
+                    float[] data = sbuffer.array();
+                    int len = sbuffer.getSize();
+                    for (int i = 0; i < len; i++) 
+                        data[i] = random.nextFloat() - 0.5f;            
+                    filter.processAudio(sbuffer);
+                }
+            filter.reset();
+        }
+        
+    }
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/DummySourceDataLine.java	Mon Nov 24 13:30:00 2008 +0100
@@ -0,0 +1,207 @@
+import java.util.ArrayList;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.Control;
+import javax.sound.sampled.DataLine;
+import javax.sound.sampled.LineListener;
+import javax.sound.sampled.LineUnavailableException;
+import javax.sound.sampled.SourceDataLine;
+import javax.sound.sampled.AudioFormat.Encoding;
+import javax.sound.sampled.Control.Type;
+
+import com.sun.media.sound.AudioFloatConverter;
+
+/**
+ * This is a SourceDataLine simulator used for testing SoftSynthesizer
+ * without using real SourceDataLine / Audio Device. 
+ * 
+ * @author Karl Helgason
+ */
+
+public class DummySourceDataLine implements SourceDataLine {
+
+    private int bufferSize = -1;
+
+    private AudioFormat format = new AudioFormat(44100.0f, 16, 2, true, false);
+    
+    private DataLine.Info sourceLineInfo;
+    
+    private boolean active = false;
+    
+    private long framepos = 0;
+    
+    private boolean opened = false;
+    
+    private int framesize = 0;
+    
+    public DummySourceDataLine()
+    {
+        ArrayList<AudioFormat> formats = new ArrayList<AudioFormat>();
+        for (int channels = 1; channels <= 2; channels++) {
+            formats.add(new AudioFormat(Encoding.PCM_SIGNED,
+                    AudioSystem.NOT_SPECIFIED, 8, channels, channels,
+                    AudioSystem.NOT_SPECIFIED, false));
+            formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
+                    AudioSystem.NOT_SPECIFIED, 8, channels, channels,
+                    AudioSystem.NOT_SPECIFIED, false));
+            for (int bits = 16; bits < 32; bits += 8) {
+                formats.add(new AudioFormat(Encoding.PCM_SIGNED,
+                        AudioSystem.NOT_SPECIFIED, bits, channels, channels
+                                * bits / 8, AudioSystem.NOT_SPECIFIED, false));
+                formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
+                        AudioSystem.NOT_SPECIFIED, bits, channels, channels
+                                * bits / 8, AudioSystem.NOT_SPECIFIED, false));
+                formats.add(new AudioFormat(Encoding.PCM_SIGNED,
+                        AudioSystem.NOT_SPECIFIED, bits, channels, channels
+                                * bits / 8, AudioSystem.NOT_SPECIFIED, true));
+                formats.add(new AudioFormat(Encoding.PCM_UNSIGNED,
+                        AudioSystem.NOT_SPECIFIED, bits, channels, channels
+                                * bits / 8, AudioSystem.NOT_SPECIFIED, true));
+            }
+            formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
+                    AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
+                    AudioSystem.NOT_SPECIFIED, false));
+            formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
+                    AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
+                    AudioSystem.NOT_SPECIFIED, true));
+            formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
+                    AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
+                    AudioSystem.NOT_SPECIFIED, false));
+            formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT,
+                    AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
+                    AudioSystem.NOT_SPECIFIED, true));
+        }
+        AudioFormat[] formats_array = formats.toArray(new AudioFormat[formats
+                .size()]);
+        sourceLineInfo = new DataLine.Info(SourceDataLine.class,
+                formats_array, AudioSystem.NOT_SPECIFIED,
+                AudioSystem.NOT_SPECIFIED);
+        
+    }
+
+    public void open() throws LineUnavailableException {
+        open(format);
+    }
+
+    public void open(AudioFormat format) throws LineUnavailableException {
+        if (bufferSize == -1)
+            bufferSize = ((int) (format.getFrameRate() / 2))
+                    * format.getFrameSize();
+        open(format, bufferSize);
+    }
+
+    public void open(AudioFormat format, int bufferSize)
+            throws LineUnavailableException {
+        this.format = format;
+        this.bufferSize = bufferSize;
+        this.framesize = format.getFrameSize();        
+        opened = true;
+    }
+    
+    public boolean isOpen() {
+        return opened;
+    }
+
+    public int write(byte[] b, int off, int len) {
+        if (!isOpen())
+            return 0;
+        if (len % framesize != 0)
+            throw new IllegalArgumentException(
+                    "Number of bytes does not represent an integral number of sample frames.");
+
+
+        int flen = len / framesize;
+        framepos += flen;
+        
+        long time =  (long) (flen * (1000.0 / (double) getFormat()
+                .getSampleRate()));
+        try {
+            Thread.sleep(time);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+            return 0;
+        }
+        
+        return len;
+    }
+
+    public int available() {
+        return 0;
+    }
+
+    public void drain() {
+    }
+
+    public void flush() {
+    }
+
+    public int getBufferSize() {
+        return bufferSize;
+    }
+
+    public AudioFormat getFormat() {
+        return format;
+    }
+
+    public int getFramePosition() {
+        return (int) getLongFramePosition();
+    }
+
+    public float getLevel() {
+        return AudioSystem.NOT_SPECIFIED;
+    }
+
+    public long getLongFramePosition() {
+        return framepos;
+    }
+
+    public long getMicrosecondPosition() {
+        return (long) (getLongFramePosition() * (1000000.0 / (double) getFormat()
+                .getSampleRate()));
+    }
+
+    public boolean isActive() {
+        return active;
+    }
+
+    public boolean isRunning() {
+        return active;
+    }
+
+    public void start() {
+        active = true;
+    }
+
+    public void stop() {
+        active = false;
+    }
+
+    public void close() {
+        stop(); 
+    }
+
+    public Control getControl(Type control) {
+        throw new IllegalArgumentException("Unsupported control type : "
+                + control);
+    }
+
+    public Control[] getControls() {
+        return new Control[0];
+    }
+
+    public javax.sound.sampled.Line.Info getLineInfo() {
+        return sourceLineInfo;
+    }
+
+    public boolean isControlSupported(Type control) {
+        return false;
+    }
+    
+    public void addLineListener(LineListener listener) {
+    }
+
+    public void removeLineListener(LineListener listener) {
+    }
+
+}