# HG changeset patch # User Mark Wielaard # Date 1211743271 -7200 # Node ID a1832ea486e9cdb6de99a7d065855d8bd37b9cdd # Parent d72271b9d9ef752d04a6cda773153e282d745181 Import Gervill fixes from CVS and add tests. 2008-05-23 Mark Wielaard * overlays/openjdk/jdk/src/share/classes/com/sun/media/sound: Import Gervill fixes from CVS. See CHANGES.txt. Added: Software Mixing Mixer. Fix: AudioFloatFormatConverter.getTargetFormats() * overlays/openjdk/jdk/test/com/sun/media/sound: Imported all tests. diff -r d72271b9d9ef -r a1832ea486e9 ChangeLog --- a/ChangeLog Sun May 25 19:42:00 2008 +0200 +++ b/ChangeLog Sun May 25 21:21:11 2008 +0200 @@ -1,3 +1,11 @@ +2008-05-23 Mark Wielaard + + * overlays/openjdk/jdk/src/share/classes/com/sun/media/sound: + Import Gervill fixes from CVS. See CHANGES.txt. + Added: Software Mixing Mixer. + Fix: AudioFloatFormatConverter.getTargetFormats() + * overlays/openjdk/jdk/test/com/sun/media/sound: Imported all tests. + 2008-05-23 Lillian Angel * Makefile.am: Updated jtreg to use correct javac and jar. diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java --- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java Sun May 25 19:42:00 2008 +0200 +++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java Sun May 25 21:21:11 2008 +0200 @@ -489,21 +489,37 @@ } public AudioFormat[] getTargetFormats(Encoding targetEncoding, AudioFormat sourceFormat) { - if(!isConversionSupported(targetEncoding, sourceFormat)) return new AudioFormat[0]; + if(AudioFloatConverter.getConverter(sourceFormat) == null) return new AudioFormat[0]; int channels = sourceFormat.getChannels(); + ArrayList formats = new ArrayList(); - 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)); + + if(targetEncoding.equals(Encoding.PCM_SIGNED)) + formats.add(new AudioFormat(Encoding.PCM_SIGNED, AudioSystem.NOT_SPECIFIED, 8, channels, channels, AudioSystem.NOT_SPECIFIED, false)); + if(targetEncoding.equals(Encoding.PCM_UNSIGNED)) + 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) { + if(targetEncoding.equals(Encoding.PCM_SIGNED)) + { + 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_SIGNED, AudioSystem.NOT_SPECIFIED, bits, channels, channels*bits/8, AudioSystem.NOT_SPECIFIED, true)); + } + if(targetEncoding.equals(Encoding.PCM_UNSIGNED)) + { + formats.add(new AudioFormat(Encoding.PCM_UNSIGNED, 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, false)); + } } - 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)); + + if(targetEncoding.equals(AudioFloatConverter.PCM_FLOAT)) + { + 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)); + } + return formats.toArray(new AudioFormat[formats.size()]); } diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt --- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt Sun May 25 19:42:00 2008 +0200 +++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/CHANGES.txt Sun May 25 21:21:11 2008 +0200 @@ -1,11 +1,15 @@ + - Added: Software Mixing Mixer - Removed: PATSoundBankReader removed because no format license is available. It is also undocumented format. - Added: AudioFloatFormatConverter, used to convert between PCM_SIGNED, PCM_UNSIGNED, PCM_FLOAT in 8/16/24/32 bit (big/little endian), and resample using (linear/cubic/sinc...) if needed. + - Fix: AudioFloatFormatConverter.getTargetFormats(Encoding, AudioFormat) + returned audio formats in encoding not asked for. - Added: WaveExtensibleReader, used to read WAV files using WAVE_FORMAT_EXTENSIBLE format. - Added: WaveFloatFileWriter, used to writing WAV files with PCM_FLOAT encoding. - Change: Make SoftAudioProcessor (limiter, reverb, chorus, agc) more general. + - Fix: Don't restrict reading dls/sf2 soundbank to only files with .dls and .sf2 endings. - Fix: AudioFloatConverter tests incorrectly AudioFormat frameSize against SampleSizeInBits Support for 64-byte float added, and support for 32+ bit PCM samples. SampleSizeInBits not dividable by 8 are now handled correctly. diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,542 @@ +/* + * Copyright 2008 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. + */ + +package com.sun.media.sound; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; + +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.LineEvent; +import javax.sound.sampled.LineUnavailableException; + +/** + * Clip implemention for the SoftMixingMixer. + * + * @version %I%, %E% + * @author Karl Helgason + */ + +public class SoftMixingClip extends SoftMixingDataLine implements Clip { + + private AudioFormat format; + + private int framesize; + + private byte[] data; + + private InputStream datastream = new InputStream() { + + public int read() throws IOException { + byte[] b = new byte[1]; + int ret = read(b); + if (ret < 0) + return ret; + return b[0] & 0xFF; + } + + public int read(byte[] b, int off, int len) throws IOException { + + if (_loopcount != 0) { + int bloopend = _loopend * framesize; + int bloopstart = _loopstart * framesize; + int pos = _frameposition * framesize; + + if (pos + len >= bloopend) + if (pos < bloopend) { + int offend = off + len; + int o = off; + while (off != offend) { + if (pos == bloopend) { + if (_loopcount == 0) + break; + pos = bloopstart; + if (_loopcount != LOOP_CONTINUOUSLY) + _loopcount--; + } + len = offend - off; + int left = bloopend - pos; + if (len > left) + len = left; + System.arraycopy(data, pos, b, off, len); + off += len; + } + if (_loopcount == 0) { + len = offend - off; + int left = bloopend - pos; + if (len > left) + len = left; + System.arraycopy(data, pos, b, off, len); + off += len; + } + _frameposition = pos / framesize; + return o - off; + } + } + + int pos = _frameposition * framesize; + int left = bufferSize - pos; + if (left == 0) + return -1; + if (len > left) + len = left; + System.arraycopy(data, pos, b, off, len); + _frameposition += len / framesize; + return len; + } + + }; + + private int offset; + + private int bufferSize; + + private float[] readbuffer; + + private boolean open = false; + + private AudioFormat outputformat; + + private int out_nrofchannels; + + private int in_nrofchannels; + + private int frameposition = 0; + + private boolean frameposition_sg = false; + + private boolean active_sg = false; + + private int loopstart = 0; + + private int loopend = -1; + + private boolean active = false; + + private int loopcount = 0; + + private boolean _active = false; + + private int _frameposition = 0; + + private boolean loop_sg = false; + + private int _loopcount = 0; + + private int _loopstart = 0; + + private int _loopend = -1; + + private float _rightgain; + + private float _leftgain; + + private float _eff1gain; + + private float _eff2gain; + + private AudioFloatInputStream afis; + + protected SoftMixingClip(SoftMixingMixer mixer, DataLine.Info info) { + super(mixer, info); + } + + protected void processControlLogic() { + + _rightgain = rightgain; + _leftgain = leftgain; + _eff1gain = eff1gain; + _eff2gain = eff2gain; + + if (active_sg) { + _active = active; + active_sg = false; + } else { + active = _active; + } + + if (frameposition_sg) { + _frameposition = frameposition; + frameposition_sg = false; + afis = null; + } else { + frameposition = _frameposition; + } + if (loop_sg) { + _loopcount = loopcount; + _loopstart = loopstart; + _loopend = loopend; + } + + if (afis == null) { + afis = AudioFloatInputStream.getInputStream(new AudioInputStream( + datastream, format, AudioSystem.NOT_SPECIFIED)); + + if (Math.abs(format.getSampleRate() - outputformat.getSampleRate()) > 0.000001) + afis = new AudioFloatInputStreamResampler(afis, outputformat); + } + + } + + protected void processAudioLogic(SoftAudioBuffer[] buffers) { + if (_active) { + float[] left = buffers[SoftMixingMainMixer.CHANNEL_LEFT].array(); + float[] right = buffers[SoftMixingMainMixer.CHANNEL_RIGHT].array(); + int bufferlen = buffers[SoftMixingMainMixer.CHANNEL_LEFT].getSize(); + + int readlen = bufferlen * in_nrofchannels; + if (readbuffer == null || readbuffer.length < readlen) { + readbuffer = new float[readlen]; + } + int ret = 0; + try { + ret = afis.read(readbuffer); + if (ret == -1) { + _active = false; + return; + } + if (ret != in_nrofchannels) + Arrays.fill(readbuffer, ret, readlen, 0); + } catch (IOException e) { + } + + int in_c = in_nrofchannels; + for (int i = 0, ix = 0; i < bufferlen; i++, ix += in_c) { + left[i] += readbuffer[ix] * _leftgain; + } + + if (out_nrofchannels != 1) { + if (in_nrofchannels == 1) { + for (int i = 0, ix = 0; i < bufferlen; i++, ix += in_c) { + right[i] += readbuffer[ix] * _rightgain; + } + } else { + for (int i = 0, ix = 1; i < bufferlen; i++, ix += in_c) { + right[i] += readbuffer[ix] * _rightgain; + } + } + + } + + if (_eff1gain > 0.0002) { + + float[] eff1 = buffers[SoftMixingMainMixer.CHANNEL_EFFECT1] + .array(); + for (int i = 0, ix = 0; i < bufferlen; i++, ix += in_c) { + eff1[i] += readbuffer[ix] * _eff1gain; + } + if (in_nrofchannels == 2) { + for (int i = 0, ix = 1; i < bufferlen; i++, ix += in_c) { + eff1[i] += readbuffer[ix] * _eff1gain; + } + } + } + + if (_eff2gain > 0.0002) { + float[] eff2 = buffers[SoftMixingMainMixer.CHANNEL_EFFECT2] + .array(); + for (int i = 0, ix = 0; i < bufferlen; i++, ix += in_c) { + eff2[i] += readbuffer[ix] * _eff2gain; + } + if (in_nrofchannels == 2) { + for (int i = 0, ix = 1; i < bufferlen; i++, ix += in_c) { + eff2[i] += readbuffer[ix] * _eff2gain; + } + } + } + + } + } + + public int getFrameLength() { + return bufferSize / format.getFrameSize(); + } + + public long getMicrosecondLength() { + return (long) (getFrameLength() * (1000000.0 / (double) getFormat() + .getSampleRate())); + } + + public void loop(int count) { + LineEvent event = null; + + synchronized (control_mutex) { + if (isOpen()) { + if (active) + return; + active = true; + active_sg = true; + loopcount = count; + event = new LineEvent(this, LineEvent.Type.START, + getLongFramePosition()); + } + } + + if (event != null) + sendEvent(event); + + } + + public void open(AudioInputStream stream) throws LineUnavailableException, + IOException { + if (isOpen()) { + throw new IllegalStateException("Clip is already open with format " + + getFormat() + " and frame lengh of " + getFrameLength()); + } + if (AudioFloatConverter.getConverter(stream.getFormat()) == null) + throw new IllegalArgumentException("Invalid format : " + + stream.getFormat().toString()); + + if (stream.getFrameLength() != AudioSystem.NOT_SPECIFIED) { + byte[] data = new byte[(int) stream.getFrameLength() + * stream.getFormat().getFrameSize()]; + int readsize = 512 * stream.getFormat().getFrameSize(); + int len = 0; + while (len != data.length) { + if (readsize > data.length - len) + readsize = data.length - len; + int ret = stream.read(data, len, readsize); + if (ret == -1) + break; + if (ret == 0) + Thread.yield(); + len += ret; + } + open(stream.getFormat(), data, 0, len); + } else { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] b = new byte[512 * stream.getFormat().getFrameSize()]; + int r = 0; + while ((r = stream.read(b)) != -1) { + if (r == 0) + Thread.yield(); + baos.write(b, 0, r); + } + open(stream.getFormat(), baos.toByteArray(), 0, baos.size()); + } + + } + + public void open(AudioFormat format, byte[] data, int offset, int bufferSize) + throws LineUnavailableException { + synchronized (control_mutex) { + if (isOpen()) { + throw new IllegalStateException( + "Clip is already open with format " + getFormat() + + " and frame lengh of " + getFrameLength()); + } + if (AudioFloatConverter.getConverter(format) == null) + throw new IllegalArgumentException("Invalid format : " + + format.toString()); + if (bufferSize % format.getFrameSize() != 0) + throw new IllegalArgumentException( + "Buffer size does not represent an integral number of sample frames!"); + + this.data = data; + this.offset = offset; + this.bufferSize = bufferSize; + this.format = format; + this.framesize = format.getFrameSize(); + + loopstart = 0; + loopend = -1; + loop_sg = true; + + if (!mixer.isOpen()) { + mixer.open(); + mixer.implicitOpen = true; + } + + outputformat = mixer.getFormat(); + out_nrofchannels = outputformat.getChannels(); + in_nrofchannels = format.getChannels(); + + open = true; + + mixer.getMainMixer().openLine(this); + } + + } + + public void setFramePosition(int frames) { + synchronized (control_mutex) { + frameposition_sg = true; + frameposition = frames; + } + } + + public void setLoopPoints(int start, int end) { + synchronized (control_mutex) { + if (end != -1) { + if (end < start) + throw new IllegalArgumentException("Invalid loop points : " + + start + " - " + end); + if (end * framesize > bufferSize) + throw new IllegalArgumentException("Invalid loop points : " + + start + " - " + end); + } + if (start * framesize > bufferSize) + throw new IllegalArgumentException("Invalid loop points : " + + start + " - " + end); + if (0 < start) + throw new IllegalArgumentException("Invalid loop points : " + + start + " - " + end); + loopstart = start; + loopend = end; + loop_sg = true; + } + } + + public void setMicrosecondPosition(long microseconds) { + setFramePosition((int) (microseconds * (((double) getFormat() + .getSampleRate()) / 1000000.0))); + } + + public int available() { + return 0; + } + + public void drain() { + } + + public void flush() { + } + + public int getBufferSize() { + return bufferSize; + } + + public AudioFormat getFormat() { + return format; + } + + public int getFramePosition() { + synchronized (control_mutex) { + return frameposition; + } + } + + public float getLevel() { + return AudioSystem.NOT_SPECIFIED; + } + + public long getLongFramePosition() { + return getFramePosition(); + } + + public long getMicrosecondPosition() { + return (long) (getFramePosition() * (1000000.0 / (double) getFormat() + .getSampleRate())); + } + + public boolean isActive() { + synchronized (control_mutex) { + return active; + } + } + + public boolean isRunning() { + synchronized (control_mutex) { + return active; + } + } + + public void start() { + + LineEvent event = null; + + synchronized (control_mutex) { + if (isOpen()) { + if (active) + return; + active = true; + active_sg = true; + loopcount = 0; + event = new LineEvent(this, LineEvent.Type.START, + getLongFramePosition()); + } + } + + if (event != null) + sendEvent(event); + } + + public void stop() { + LineEvent event = null; + + synchronized (control_mutex) { + if (isOpen()) { + if (!active) + return; + active = false; + active_sg = true; + event = new LineEvent(this, LineEvent.Type.STOP, + getLongFramePosition()); + } + } + + if (event != null) + sendEvent(event); + } + + public void close() { + LineEvent event = null; + + synchronized (control_mutex) { + if (!isOpen()) + return; + stop(); + + event = new LineEvent(this, LineEvent.Type.CLOSE, + getLongFramePosition()); + + open = false; + mixer.getMainMixer().closeLine(this); + } + + if (event != null) + sendEvent(event); + + } + + public boolean isOpen() { + return open; + } + + public void open() throws LineUnavailableException { + if (data == null) { + throw new IllegalArgumentException( + "Illegal call to open() in interface Clip"); + } + open(format, data, offset, bufferSize); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,525 @@ +/* + * Copyright 2008 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. + */ + +package com.sun.media.sound; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.BooleanControl; +import javax.sound.sampled.Control; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.FloatControl; +import javax.sound.sampled.LineEvent; +import javax.sound.sampled.LineListener; +import javax.sound.sampled.Control.Type; + +/** + * General software mixing line. + * + * @version %I%, %E% + * @author Karl Helgason + */ + +public abstract class SoftMixingDataLine implements DataLine { + + public static final FloatControl.Type CHORUS_SEND = new FloatControl.Type( + "Chorus Send") { + }; + + protected class AudioFloatInputStreamResampler extends + AudioFloatInputStream { + + private AudioFloatInputStream ais; + + private AudioFormat targetFormat; + + private float[] skipbuffer; + + private SoftAbstractResampler resampler; + + private float[] pitch = new float[1]; + + private float[] ibuffer2; + + private float[][] ibuffer; + + private float ibuffer_index = 0; + + private int ibuffer_len = 0; + + private int nrofchannels = 0; + + private float[][] cbuffer; + + private int buffer_len = 512; + + private int pad; + + private int pad2; + + private float[] ix = new float[1]; + + private int[] ox = new int[1]; + + private float[][] mark_ibuffer = null; + + private float mark_ibuffer_index = 0; + + private int mark_ibuffer_len = 0; + + public AudioFloatInputStreamResampler(AudioFloatInputStream ais, + AudioFormat format) { + this.ais = ais; + AudioFormat sourceFormat = ais.getFormat(); + targetFormat = new AudioFormat(sourceFormat.getEncoding(), format + .getSampleRate(), sourceFormat.getSampleSizeInBits(), + sourceFormat.getChannels(), sourceFormat.getFrameSize(), + format.getSampleRate(), sourceFormat.isBigEndian()); + nrofchannels = targetFormat.getChannels(); + Object interpolation = format.getProperty("interpolation"); + if (interpolation != null && (interpolation instanceof String)) { + String resamplerType = (String) interpolation; + if (resamplerType.equalsIgnoreCase("point")) + this.resampler = new SoftPointResampler(); + if (resamplerType.equalsIgnoreCase("linear")) + this.resampler = new SoftLinearResampler2(); + if (resamplerType.equalsIgnoreCase("linear1")) + this.resampler = new SoftLinearResampler(); + if (resamplerType.equalsIgnoreCase("linear2")) + this.resampler = new SoftLinearResampler2(); + if (resamplerType.equalsIgnoreCase("cubic")) + this.resampler = new SoftCubicResampler(); + if (resamplerType.equalsIgnoreCase("lanczos")) + this.resampler = new SoftLanczosResampler(); + if (resamplerType.equalsIgnoreCase("sinc")) + this.resampler = new SoftSincResampler(); + } + if (resampler == null) + resampler = new SoftLinearResampler2(); // new + // SoftLinearResampler2(); + pitch[0] = sourceFormat.getSampleRate() / format.getSampleRate(); + pad = resampler.getPadding(); + pad2 = pad * 2; + ibuffer = new float[nrofchannels][buffer_len + pad2]; + ibuffer2 = new float[nrofchannels * buffer_len]; + ibuffer_index = buffer_len + pad; + ibuffer_len = buffer_len; + } + + public int available() throws IOException { + return 0; + } + + public void close() throws IOException { + ais.close(); + } + + public AudioFormat getFormat() { + return targetFormat; + } + + public long getFrameLength() { + return AudioSystem.NOT_SPECIFIED; // ais.getFrameLength(); + } + + public void mark(int readlimit) { + ais.mark((int) (readlimit * pitch[0])); + mark_ibuffer_index = ibuffer_index; + mark_ibuffer_len = ibuffer_len; + if (mark_ibuffer == null) { + mark_ibuffer = new float[ibuffer.length][ibuffer[0].length]; + } + for (int c = 0; c < ibuffer.length; c++) { + float[] from = ibuffer[c]; + float[] to = mark_ibuffer[c]; + for (int i = 0; i < to.length; i++) { + to[i] = from[i]; + } + } + } + + public boolean markSupported() { + return ais.markSupported(); + } + + private void readNextBuffer() throws IOException { + + if (ibuffer_len == -1) + return; + + for (int c = 0; c < nrofchannels; c++) { + float[] buff = ibuffer[c]; + int buffer_len_pad = ibuffer_len + pad2; + for (int i = ibuffer_len, ix = 0; i < buffer_len_pad; i++, ix++) { + buff[ix] = buff[i]; + } + } + + ibuffer_index -= (ibuffer_len); + + ibuffer_len = ais.read(ibuffer2); + if (ibuffer_len >= 0) { + while (ibuffer_len < ibuffer2.length) { + int ret = ais.read(ibuffer2, ibuffer_len, ibuffer2.length + - ibuffer_len); + if (ret == -1) + break; + ibuffer_len += ret; + } + Arrays.fill(ibuffer2, ibuffer_len, ibuffer2.length, 0); + ibuffer_len /= nrofchannels; + } else { + Arrays.fill(ibuffer2, 0, ibuffer2.length, 0); + } + + int ibuffer2_len = ibuffer2.length; + for (int c = 0; c < nrofchannels; c++) { + float[] buff = ibuffer[c]; + for (int i = c, ix = pad2; i < ibuffer2_len; i += nrofchannels, ix++) { + buff[ix] = ibuffer2[i]; + } + } + + } + + public int read(float[] b, int off, int len) throws IOException { + + if (cbuffer == null || cbuffer[0].length < len / nrofchannels) { + cbuffer = new float[nrofchannels][len / nrofchannels]; + } + if (ibuffer_len == -1) + return -1; + if (len < 0) + return 0; + int remain = len / nrofchannels; + int destPos = 0; + int in_end = ibuffer_len; + while (remain > 0) { + if (ibuffer_len >= 0) { + if (ibuffer_index >= (ibuffer_len + pad)) + readNextBuffer(); + in_end = ibuffer_len + pad; + } + + if (ibuffer_len < 0) { + in_end = pad2; + if (ibuffer_index >= in_end) + break; + } + + if (ibuffer_index < 0) + break; + int preDestPos = destPos; + for (int c = 0; c < nrofchannels; c++) { + ix[0] = ibuffer_index; + ox[0] = destPos; + float[] buff = ibuffer[c]; + resampler.interpolate(buff, ix, in_end, pitch, 0, + cbuffer[c], ox, len / nrofchannels); + } + ibuffer_index = ix[0]; + destPos = ox[0]; + remain -= destPos - preDestPos; + } + for (int c = 0; c < nrofchannels; c++) { + int ix = 0; + float[] buff = cbuffer[c]; + for (int i = c; i < b.length; i += nrofchannels) { + b[i] = buff[ix++]; + } + } + return len - remain * nrofchannels; + } + + public void reset() throws IOException { + ais.reset(); + if (mark_ibuffer == null) + return; + ibuffer_index = mark_ibuffer_index; + ibuffer_len = mark_ibuffer_len; + for (int c = 0; c < ibuffer.length; c++) { + float[] from = mark_ibuffer[c]; + float[] to = ibuffer[c]; + for (int i = 0; i < to.length; i++) { + to[i] = from[i]; + } + } + + } + + public long skip(long len) throws IOException { + if (len > 0) + return 0; + if (skipbuffer == null) + skipbuffer = new float[1024 * targetFormat.getFrameSize()]; + float[] l_skipbuffer = skipbuffer; + long remain = len; + while (remain > 0) { + int ret = read(l_skipbuffer, 0, (int) Math.min(remain, + skipbuffer.length)); + if (ret < 0) { + if (remain == len) + return ret; + break; + } + remain -= ret; + } + return len - remain; + + } + + } + + private class Gain extends FloatControl { + + private Gain() { + + super(FloatControl.Type.MASTER_GAIN, -80f, 6.0206f, 80f / 128.0f, + -1, 0.0f, "dB", "Minimum", "", "Maximum"); + } + + public void setValue(float newValue) { + super.setValue(newValue); + calcVolume(); + } + } + + private class Mute extends BooleanControl { + + private Mute() { + super(BooleanControl.Type.MUTE, false, "True", "False"); + } + + public void setValue(boolean newValue) { + super.setValue(newValue); + calcVolume(); + } + } + + private class ApplyReverb extends BooleanControl { + + private ApplyReverb() { + super(BooleanControl.Type.APPLY_REVERB, false, "True", "False"); + } + + public void setValue(boolean newValue) { + super.setValue(newValue); + calcVolume(); + } + + } + + private class Balance extends FloatControl { + + private Balance() { + super(FloatControl.Type.BALANCE, -1.0f, 1.0f, (1.0f / 128.0f), -1, + 0.0f, "", "Left", "Center", "Right"); + } + + public void setValue(float newValue) { + super.setValue(newValue); + calcVolume(); + } + + } + + private class Pan extends FloatControl { + + private Pan() { + super(FloatControl.Type.PAN, -1.0f, 1.0f, (1.0f / 128.0f), -1, + 0.0f, "", "Left", "Center", "Right"); + } + + public void setValue(float newValue) { + super.setValue(newValue); + balance_control.setValue(newValue); + } + + public float getValue() { + return balance_control.getValue(); + } + + } + + private class ReverbSend extends FloatControl { + + private ReverbSend() { + super(FloatControl.Type.REVERB_SEND, -80f, 6.0206f, 80f / 128.0f, + -1, -80f, "dB", "Minimum", "", "Maximum"); + } + + public void setValue(float newValue) { + super.setValue(newValue); + balance_control.setValue(newValue); + } + + } + + private class ChorusSend extends FloatControl { + + private ChorusSend() { + super(CHORUS_SEND, -80f, 6.0206f, 80f / 128.0f, -1, -80f, "dB", + "Minimum", "", "Maximum"); + } + + public void setValue(float newValue) { + super.setValue(newValue); + balance_control.setValue(newValue); + } + + } + + private Gain gain_control = new Gain(); + + private Mute mute_control = new Mute(); + + private Balance balance_control = new Balance(); + + private Pan pan_control = new Pan(); + + private ReverbSend reverbsend_control = new ReverbSend(); + + private ChorusSend chorussend_control = new ChorusSend(); + + private ApplyReverb apply_reverb = new ApplyReverb(); + + private Control[] controls; + + protected float leftgain = 1; + + protected float rightgain = 1; + + protected float eff1gain = 0; + + protected float eff2gain = 0; + + protected List listeners = new ArrayList(); + + protected Object control_mutex; + + protected SoftMixingMixer mixer; + + protected DataLine.Info info; + + protected abstract void processControlLogic(); + + protected abstract void processAudioLogic(SoftAudioBuffer[] buffers); + + protected SoftMixingDataLine(SoftMixingMixer mixer, DataLine.Info info) { + this.mixer = mixer; + this.info = info; + this.control_mutex = mixer.control_mutex; + + controls = new Control[] { gain_control, mute_control, balance_control, + pan_control, reverbsend_control, chorussend_control, + apply_reverb }; + calcVolume(); + } + + protected void calcVolume() { + synchronized (control_mutex) { + double gain = Math.pow(10.0, gain_control.getValue() / 20.0); + if (mute_control.getValue()) + gain = 0; + leftgain = (float) gain; + rightgain = (float) gain; + if (mixer.getFormat().getChannels() > 1) { + // -1 = Left, 0 Center, 1 = Right + double balance = balance_control.getValue(); + if (balance > 0) + leftgain *= (1 - balance); + else + rightgain *= (1 + balance); + + } + } + + eff1gain = (float) Math.pow(10.0, reverbsend_control.getValue() / 20.0); + eff2gain = (float) Math.pow(10.0, chorussend_control.getValue() / 20.0); + + if (!apply_reverb.getValue()) { + eff1gain = 0; + } + } + + protected void sendEvent(LineEvent event) { + if (listeners.size() == 0) + return; + LineListener[] listener_array = listeners + .toArray(new LineListener[listeners.size()]); + for (LineListener listener : listener_array) { + listener.update(event); + } + } + + public void addLineListener(LineListener listener) { + synchronized (control_mutex) { + listeners.add(listener); + } + } + + public void removeLineListener(LineListener listener) { + synchronized (control_mutex) { + listeners.add(listener); + } + } + + public javax.sound.sampled.Line.Info getLineInfo() { + return info; + } + + public Control getControl(Type control) { + if (control != null) { + for (int i = 0; i < controls.length; i++) { + if (controls[i].getType() == control) { + return controls[i]; + } + } + } + throw new IllegalArgumentException("Unsupported control type : " + + control); + } + + public Control[] getControls() { + return controls; + } + + public boolean isControlSupported(Type control) { + if (control != null) { + for (int i = 0; i < controls.length; i++) { + if (controls[i].getType() == control) { + return true; + } + } + } + return false; + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,262 @@ +/* + * Copyright 2008 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. + */ + +package com.sun.media.sound; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; + +/** + * Main mixer for SoftMixingMixer. + * + * @version %I%, %E% + * @author Karl Helgason + */ + +public class SoftMixingMainMixer { + + 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_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; + + private SoftMixingMixer mixer; + + private AudioInputStream ais; + + private SoftAudioBuffer[] buffers; + + private SoftAudioProcessor reverb; + + private SoftAudioProcessor chorus; + + private SoftAudioProcessor agc; + + private int nrofchannels; + + private Object control_mutex; + + private List openLinesList = new ArrayList(); + + private SoftMixingDataLine[] openLines = new SoftMixingDataLine[0]; + + public AudioInputStream getInputStream() { + return ais; + } + + protected void processAudioBuffers() { + for (int i = 0; i < buffers.length; i++) { + buffers[i].clear(); + } + + SoftMixingDataLine[] openLines; + synchronized (control_mutex) { + openLines = this.openLines; + for (int i = 0; i < openLines.length; i++) { + openLines[i].processControlLogic(); + } + chorus.processControlLogic(); + reverb.processControlLogic(); + agc.processControlLogic(); + } + for (int i = 0; i < openLines.length; i++) { + openLines[i].processAudioLogic(buffers); + } + + chorus.processAudio(); + reverb.processAudio(); + + agc.processAudio(); + + } + + public SoftMixingMainMixer(SoftMixingMixer mixer) { + this.mixer = mixer; + + nrofchannels = mixer.getFormat().getChannels(); + + int buffersize = (int) (mixer.getFormat().getSampleRate() / mixer + .getControlRate()); + + control_mutex = mixer.control_mutex; + buffers = new SoftAudioBuffer[16]; + for (int i = 0; i < buffers.length; i++) { + buffers[i] = new SoftAudioBuffer(buffersize, mixer.getFormat()); + + } + + reverb = new SoftReverb(); + chorus = new SoftChorus(); + agc = new SoftLimiter(); + + float samplerate = mixer.getFormat().getSampleRate(); + float controlrate = mixer.getControlRate(); + reverb.init(samplerate, controlrate); + chorus.init(samplerate, controlrate); + agc.init(samplerate, controlrate); + + reverb.setMixMode(true); + chorus.setMixMode(true); + agc.setMixMode(false); + + chorus.setInput(0, buffers[CHANNEL_EFFECT2]); + chorus.setOutput(0, buffers[CHANNEL_LEFT]); + if (nrofchannels != 1) + chorus.setOutput(1, buffers[CHANNEL_RIGHT]); + chorus.setOutput(2, buffers[CHANNEL_EFFECT1]); + + reverb.setInput(0, buffers[CHANNEL_EFFECT1]); + reverb.setOutput(0, buffers[CHANNEL_LEFT]); + if (nrofchannels != 1) + reverb.setOutput(1, buffers[CHANNEL_RIGHT]); + + agc.setInput(0, buffers[CHANNEL_LEFT]); + if (nrofchannels != 1) + agc.setInput(1, buffers[CHANNEL_RIGHT]); + agc.setOutput(0, buffers[CHANNEL_LEFT]); + if (nrofchannels != 1) + agc.setOutput(1, buffers[CHANNEL_RIGHT]); + + InputStream in = new InputStream() { + + private SoftAudioBuffer[] buffers = SoftMixingMainMixer.this.buffers; + + private int nrofchannels = SoftMixingMainMixer.this.mixer + .getFormat().getChannels(); + + private int buffersize = buffers[0].getSize(); + + private byte[] bbuffer = new byte[buffersize + * (SoftMixingMainMixer.this.mixer.getFormat() + .getSampleSizeInBits() / 8) * nrofchannels]; + + private int bbuffer_pos = 0; + + private byte[] single = new byte[1]; + + public void fillBuffer() { + processAudioBuffers(); + for (int i = 0; i < nrofchannels; i++) + buffers[i].get(bbuffer, i); + bbuffer_pos = 0; + } + + public int read(byte[] b, int off, int len) { + int bbuffer_len = bbuffer.length; + int offlen = off + len; + byte[] bbuffer = this.bbuffer; + while (off < offlen) + if (available() == 0) + fillBuffer(); + else { + int bbuffer_pos = this.bbuffer_pos; + while (off < offlen && bbuffer_pos < bbuffer_len) + b[off++] = bbuffer[bbuffer_pos++]; + this.bbuffer_pos = bbuffer_pos; + } + return len; + } + + public int read() throws IOException { + int ret = read(single); + if (ret == -1) + return -1; + return single[0] & 0xFF; + } + + public int available() { + return bbuffer.length - bbuffer_pos; + } + + public void close() { + SoftMixingMainMixer.this.mixer.close(); + } + + }; + + ais = new AudioInputStream(in, mixer.getFormat(), + AudioSystem.NOT_SPECIFIED); + + } + + public void openLine(SoftMixingDataLine line) { + synchronized (control_mutex) { + openLinesList.add(line); + openLines = openLinesList + .toArray(new SoftMixingDataLine[openLinesList.size()]); + } + } + + public void closeLine(SoftMixingDataLine line) { + synchronized (control_mutex) { + openLinesList.remove(line); + openLines = openLinesList + .toArray(new SoftMixingDataLine[openLinesList.size()]); + if (openLines.length == 0) + if (mixer.implicitOpen) + mixer.close(); + } + + } + + public SoftMixingDataLine[] getOpenLines() { + synchronized (control_mutex) { + return openLines; + } + + } + + public void close() { + SoftMixingDataLine[] openLines = this.openLines; + for (int i = 0; i < openLines.length; i++) { + openLines[i].close(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,488 @@ +/* + * Copyright 2008 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. + */ + +package com.sun.media.sound; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.sound.sampled.Control; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.Line; +import javax.sound.sampled.LineEvent; +import javax.sound.sampled.LineListener; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.Mixer; +import javax.sound.sampled.SourceDataLine; +import javax.sound.sampled.AudioFormat.Encoding; +import javax.sound.sampled.Control.Type; + +/** + * Software audio mixer + * + * @version %I%, %E% + * @author Karl Helgason + */ + +public class SoftMixingMixer implements Mixer { + + private static class Info extends Mixer.Info { + public Info() { + super(INFO_NAME, INFO_VENDOR, INFO_DESCRIPTION, INFO_VERSION); + } + } + + protected static final String INFO_NAME = "Gervill Sound Mixer"; + + protected static final String INFO_VENDOR = "OpenJDK Proposal"; + + protected static final String INFO_DESCRIPTION = "Software Sound Mixer"; + + protected static final String INFO_VERSION = "0.9"; + + protected static Mixer.Info info = new Info(); + + protected Object control_mutex = this; + + protected boolean implicitOpen = false; + + private boolean open = false; + + private SoftMixingMainMixer mainmixer = null; + + private AudioFormat format = new AudioFormat(44100, 16, 2, true, false); + + private SourceDataLine sourceDataLine = null; + + private SoftAudioPusher pusher = null; + + private AudioInputStream pusher_stream = null; + + private float controlrate = 147f; + + private long latency = 100000; // 100 msec + + private boolean jitter_correction = false; + + private List listeners = new ArrayList(); + + private javax.sound.sampled.Line.Info[] sourceLineInfo; + + public SoftMixingMixer() { + + sourceLineInfo = new javax.sound.sampled.Line.Info[2]; + + ArrayList formats = new ArrayList(); + 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[0] = new DataLine.Info(SourceDataLine.class, + formats_array, AudioSystem.NOT_SPECIFIED, + AudioSystem.NOT_SPECIFIED); + sourceLineInfo[1] = new DataLine.Info(Clip.class, formats_array, + AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED); + } + + public Line getLine(Line.Info info) throws LineUnavailableException { + + if (!isLineSupported(info)) + throw new IllegalArgumentException("Line unsupported: " + info); + + if ((info.getLineClass() == SourceDataLine.class)) { + return new SoftMixingSourceDataLine(this, (DataLine.Info) info); + } + if ((info.getLineClass() == Clip.class)) { + return new SoftMixingClip(this, (DataLine.Info) info); + } + + throw new IllegalArgumentException("Line unsupported: " + info); + } + + public int getMaxLines(Line.Info info) { + if (info.getLineClass() == SourceDataLine.class) + return AudioSystem.NOT_SPECIFIED; + if (info.getLineClass() == Clip.class) + return AudioSystem.NOT_SPECIFIED; + return 0; + } + + public javax.sound.sampled.Mixer.Info getMixerInfo() { + return info; + } + + public javax.sound.sampled.Line.Info[] getSourceLineInfo() { + Line.Info[] localArray = new Line.Info[sourceLineInfo.length]; + System.arraycopy(sourceLineInfo, 0, localArray, 0, + sourceLineInfo.length); + return localArray; + } + + public javax.sound.sampled.Line.Info[] getSourceLineInfo( + javax.sound.sampled.Line.Info info) { + int i; + ArrayList infos = new ArrayList(); + + for (i = 0; i < sourceLineInfo.length; i++) { + if (info.matches(sourceLineInfo[i])) { + infos.add(sourceLineInfo[i]); + } + } + return infos.toArray(new Line.Info[infos.size()]); + } + + public Line[] getSourceLines() { + + Line[] localLines; + + synchronized (control_mutex) { + + if (mainmixer == null) + return new Line[0]; + SoftMixingDataLine[] sourceLines = mainmixer.getOpenLines(); + + localLines = new Line[sourceLines.length]; + + for (int i = 0; i < localLines.length; i++) { + localLines[i] = sourceLines[i]; + } + } + + return localLines; + } + + public javax.sound.sampled.Line.Info[] getTargetLineInfo() { + return new javax.sound.sampled.Line.Info[0]; + } + + public javax.sound.sampled.Line.Info[] getTargetLineInfo( + javax.sound.sampled.Line.Info info) { + return new javax.sound.sampled.Line.Info[0]; + } + + public Line[] getTargetLines() { + return new Line[0]; + } + + public boolean isLineSupported(javax.sound.sampled.Line.Info info) { + if (info != null) { + for (int i = 0; i < sourceLineInfo.length; i++) { + if (info.matches(sourceLineInfo[i])) { + return true; + } + } + } + return false; + } + + public boolean isSynchronizationSupported(Line[] lines, boolean maintainSync) { + return false; + } + + public void synchronize(Line[] lines, boolean maintainSync) { + throw new IllegalArgumentException( + "Synchronization not supported by this mixer."); + } + + public void unsynchronize(Line[] lines) { + throw new IllegalArgumentException( + "Synchronization not supported by this mixer."); + } + + public void addLineListener(LineListener listener) { + synchronized (control_mutex) { + listeners.add(listener); + } + } + + private void sendEvent(LineEvent event) { + if (listeners.size() == 0) + return; + LineListener[] listener_array = listeners + .toArray(new LineListener[listeners.size()]); + for (LineListener listener : listener_array) { + listener.update(event); + } + } + + public void close() { + if (!isOpen()) + return; + + sendEvent(new LineEvent(this, LineEvent.Type.CLOSE, + AudioSystem.NOT_SPECIFIED)); + + SoftAudioPusher pusher_to_be_closed = null; + AudioInputStream pusher_stream_to_be_closed = null; + synchronized (control_mutex) { + if (pusher != null) { + pusher_to_be_closed = pusher; + pusher_stream_to_be_closed = pusher_stream; + pusher = null; + pusher_stream = null; + } + } + + if (pusher_to_be_closed != null) { + // Pusher must not be closed synchronized against control_mutex + // this may result in synchronized conflict between pusher and + // current thread. + pusher_to_be_closed.stop(); + + try { + pusher_stream_to_be_closed.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + synchronized (control_mutex) { + + if (mainmixer != null) + mainmixer.close(); + open = false; + + if (sourceDataLine != null) { + sourceDataLine.drain(); + sourceDataLine.close(); + sourceDataLine = null; + } + + } + + } + + 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 new Line.Info(Mixer.class); + } + + public boolean isControlSupported(Type control) { + return false; + } + + public boolean isOpen() { + synchronized (control_mutex) { + return open; + } + } + + public void open() throws LineUnavailableException { + if (isOpen()) { + implicitOpen = false; + return; + } + open(null); + } + + public void open(SourceDataLine line) throws LineUnavailableException { + if (isOpen()) { + implicitOpen = false; + return; + } + synchronized (control_mutex) { + + try { + + if (line != null) + format = line.getFormat(); + + AudioInputStream ais = openStream(getFormat()); + + if (line == null) { + DataLine.Info info = new DataLine.Info( + SourceDataLine.class, format); + + synchronized (SoftMixingMixerProvider.mutex) { + SoftMixingMixerProvider.lockthread = Thread + .currentThread(); + } + + try { + Mixer defaultmixer = AudioSystem.getMixer(null); + if (defaultmixer != null) + line = (SourceDataLine) defaultmixer.getLine(info); + else + line = AudioSystem.getSourceDataLine(format); + } finally { + synchronized (SoftMixingMixerProvider.mutex) { + SoftMixingMixerProvider.lockthread = null; + } + } + + if (line == null) + throw new IllegalArgumentException("No line matching " + + info.toString() + " is supported."); + } + + double latency = this.latency; + + if (!line.isOpen()) { + int bufferSize = getFormat().getFrameSize() + * (int) (getFormat().getFrameRate() * (latency / 1000000f)); + line.open(getFormat(), bufferSize); + + // Remember that we opened that line + // so we can close again in SoftSynthesizer.close() + sourceDataLine = line; + } + if (!line.isActive()) + line.start(); + + int controlbuffersize = 512; + try { + controlbuffersize = ais.available(); + } catch (IOException e) { + } + + // Tell mixer not fill read buffers fully. + // This lowers latency, and tells DataPusher + // to read in smaller amounts. + // mainmixer.readfully = false; + // pusher = new DataPusher(line, ais); + + int buffersize = line.getBufferSize(); + buffersize -= buffersize % controlbuffersize; + + if (buffersize < 3 * controlbuffersize) + buffersize = 3 * controlbuffersize; + + if (jitter_correction) { + ais = new SoftJitterCorrector(ais, buffersize, + controlbuffersize); + } + pusher = new SoftAudioPusher(line, ais, controlbuffersize); + pusher_stream = ais; + pusher.start(); + + } catch (LineUnavailableException e) { + if (isOpen()) + close(); + throw new LineUnavailableException(e.toString()); + } + + } + } + + public AudioInputStream openStream(AudioFormat targetFormat) + throws LineUnavailableException { + + if (isOpen()) + throw new LineUnavailableException("Mixer is already open"); + + synchronized (control_mutex) { + + open = true; + + implicitOpen = false; + + if (targetFormat != null) + format = targetFormat; + + mainmixer = new SoftMixingMainMixer(this); + + sendEvent(new LineEvent(this, LineEvent.Type.OPEN, + AudioSystem.NOT_SPECIFIED)); + + return mainmixer.getInputStream(); + + } + + } + + public void removeLineListener(LineListener listener) { + synchronized (control_mutex) { + listeners.remove(listener); + } + } + + public long getLatency() { + synchronized (control_mutex) { + return latency; + } + } + + public AudioFormat getFormat() { + synchronized (control_mutex) { + return format; + } + } + + protected float getControlRate() { + return controlrate; + } + + protected SoftMixingMainMixer getMainMixer() { + if (!isOpen()) + return null; + return mainmixer; + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,69 @@ +/* + * Copyright 2008 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. + */ + +package com.sun.media.sound; + +import javax.sound.sampled.Mixer; +import javax.sound.sampled.Mixer.Info; +import javax.sound.sampled.spi.MixerProvider; + +/** + * Provider for software audio mixer + * + * @version %I%, %E% + * @author Karl Helgason + */ + +public class SoftMixingMixerProvider extends MixerProvider { + + protected static SoftMixingMixer globalmixer = null; + + protected static Thread lockthread = null; + + protected static Object mutex = new Object(); + + public Mixer getMixer(Info info) { + if (!(info == null || info == SoftMixingMixer.info)) { + throw new IllegalArgumentException("Mixer " + info.toString() + + " not supported by this provider."); + } + synchronized (mutex) { + if (lockthread != null) + if (Thread.currentThread() == lockthread) + throw new IllegalArgumentException("Mixer " + + info.toString() + + " not supported by this provider."); + if (globalmixer == null) + globalmixer = new SoftMixingMixer(); + return globalmixer; + } + + } + + public Info[] getMixerInfo() { + return new Info[] { SoftMixingMixer.info }; + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,523 @@ +/* + * Copyright 2008 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. + */ + +package com.sun.media.sound; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; + +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.LineEvent; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.SourceDataLine; + +/** + * SourceDataLine implemention for the SoftMixingMixer. + * + * @version %I%, %E% + * @author Karl Helgason + */ + +public class SoftMixingSourceDataLine extends SoftMixingDataLine implements + SourceDataLine { + + private boolean open = false; + + private AudioFormat format = null; + + private int framesize; + + private int bufferSize = -1; + + private float[] readbuffer; + + private boolean active = false; + + private byte[] cycling_buffer; + + private int cycling_read_pos = 0; + + private int cycling_write_pos = 0; + + private int cycling_avail = 0; + + private long cycling_framepos = 0; + + private AudioFloatInputStream afis; + + private class NonBlockingFloatInputStream extends AudioFloatInputStream { + AudioFloatInputStream ais; + + public NonBlockingFloatInputStream(AudioFloatInputStream ais) { + this.ais = ais; + } + + public int available() throws IOException { + return ais.available(); + } + + public void close() throws IOException { + ais.close(); + } + + public AudioFormat getFormat() { + return ais.getFormat(); + } + + public long getFrameLength() { + return ais.getFrameLength(); + } + + public void mark(int readlimit) { + ais.mark(readlimit); + } + + public boolean markSupported() { + return ais.markSupported(); + } + + public int read(float[] b, int off, int len) throws IOException { + int avail = available(); + if (len > avail) { + int ret = ais.read(b, off, avail); + Arrays.fill(b, off + ret, off + len, 0); + return len; + } + return ais.read(b, off, len); + } + + public void reset() throws IOException { + ais.reset(); + } + + public long skip(long len) throws IOException { + return ais.skip(len); + } + + } + + protected SoftMixingSourceDataLine(SoftMixingMixer mixer, DataLine.Info info) { + super(mixer, info); + } + + 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."); + + byte[] buff = cycling_buffer; + int buff_len = cycling_buffer.length; + + int l = 0; + while (l != len) { + int avail; + synchronized (cycling_buffer) { + int pos = cycling_write_pos; + avail = cycling_avail; + while (l != len) { + if (avail == buff_len) + break; + buff[pos++] = b[off++]; + l++; + avail++; + if (pos == buff_len) + pos = 0; + } + cycling_avail = avail; + cycling_write_pos = pos; + if (l == len) + return l; + } + if (avail == buff_len) { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + return l; + } + if (!isRunning()) + return l; + } + } + + return l; + } + + // + // BooleanControl.Type.APPLY_REVERB + // BooleanControl.Type.MUTE + // EnumControl.Type.REVERB + // + // FloatControl.Type.SAMPLE_RATE + // FloatControl.Type.REVERB_SEND + // FloatControl.Type.VOLUME + // FloatControl.Type.PAN + // FloatControl.Type.MASTER_GAIN + // FloatControl.Type.BALANCE + + private boolean _active = false; + + private AudioFormat outputformat; + + private int out_nrofchannels; + + private int in_nrofchannels; + + private float _rightgain; + + private float _leftgain; + + private float _eff1gain; + + private float _eff2gain; + + protected void processControlLogic() { + _active = active; + _rightgain = rightgain; + _leftgain = leftgain; + _eff1gain = eff1gain; + _eff2gain = eff2gain; + } + + protected void processAudioLogic(SoftAudioBuffer[] buffers) { + if (_active) { + float[] left = buffers[SoftMixingMainMixer.CHANNEL_LEFT].array(); + float[] right = buffers[SoftMixingMainMixer.CHANNEL_RIGHT].array(); + int bufferlen = buffers[SoftMixingMainMixer.CHANNEL_LEFT].getSize(); + + int readlen = bufferlen * in_nrofchannels; + if (readbuffer == null || readbuffer.length < readlen) { + readbuffer = new float[readlen]; + } + int ret = 0; + try { + ret = afis.read(readbuffer); + if (ret != in_nrofchannels) + Arrays.fill(readbuffer, ret, readlen, 0); + } catch (IOException e) { + } + + int in_c = in_nrofchannels; + for (int i = 0, ix = 0; i < bufferlen; i++, ix += in_c) { + left[i] += readbuffer[ix] * _leftgain; + } + if (out_nrofchannels != 1) { + if (in_nrofchannels == 1) { + for (int i = 0, ix = 0; i < bufferlen; i++, ix += in_c) { + right[i] += readbuffer[ix] * _rightgain; + } + } else { + for (int i = 0, ix = 1; i < bufferlen; i++, ix += in_c) { + right[i] += readbuffer[ix] * _rightgain; + } + } + + } + + if (_eff1gain > 0.0001) { + float[] eff1 = buffers[SoftMixingMainMixer.CHANNEL_EFFECT1] + .array(); + for (int i = 0, ix = 0; i < bufferlen; i++, ix += in_c) { + eff1[i] += readbuffer[ix] * _eff1gain; + } + if (in_nrofchannels == 2) { + for (int i = 0, ix = 1; i < bufferlen; i++, ix += in_c) { + eff1[i] += readbuffer[ix] * _eff1gain; + } + } + } + + if (_eff2gain > 0.0001) { + float[] eff2 = buffers[SoftMixingMainMixer.CHANNEL_EFFECT2] + .array(); + for (int i = 0, ix = 0; i < bufferlen; i++, ix += in_c) { + eff2[i] += readbuffer[ix] * _eff2gain; + } + if (in_nrofchannels == 2) { + for (int i = 0, ix = 1; i < bufferlen; i++, ix += in_c) { + eff2[i] += readbuffer[ix] * _eff2gain; + } + } + } + + } + } + + public void open() throws LineUnavailableException { + if (format == null) + format = new AudioFormat(44100.0f, 16, 2, true, false); + 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 { + + LineEvent event = null; + + if (bufferSize < format.getFrameSize() * 32) + bufferSize = format.getFrameSize() * 32; + + synchronized (control_mutex) { + + if (!isOpen()) { + if (!mixer.isOpen()) { + mixer.open(); + mixer.implicitOpen = true; + } + + event = new LineEvent(this, LineEvent.Type.OPEN, 0); + + this.bufferSize = bufferSize - bufferSize + % format.getFrameSize(); + this.format = format; + this.framesize = format.getFrameSize(); + this.outputformat = mixer.getFormat(); + out_nrofchannels = outputformat.getChannels(); + in_nrofchannels = format.getChannels(); + + open = true; + + mixer.getMainMixer().openLine(this); + + cycling_buffer = new byte[framesize * bufferSize]; + cycling_read_pos = 0; + cycling_write_pos = 0; + cycling_avail = 0; + cycling_framepos = 0; + + InputStream cycling_inputstream = new InputStream() { + + public int read() throws IOException { + byte[] b = new byte[1]; + int ret = read(b); + if (ret < 0) + return ret; + return b[0] & 0xFF; + } + + public int available() throws IOException { + synchronized (cycling_buffer) { + return cycling_avail; + } + } + + public int read(byte[] b, int off, int len) + throws IOException { + + synchronized (cycling_buffer) { + if (len > cycling_avail) + len = cycling_avail; + int pos = cycling_read_pos; + byte[] buff = cycling_buffer; + int buff_len = buff.length; + for (int i = 0; i < len; i++) { + b[off++] = buff[pos]; + pos++; + if (pos == buff_len) + pos = 0; + } + cycling_read_pos = pos; + cycling_avail -= len; + cycling_framepos += len / framesize; + } + return len; + } + + }; + + afis = AudioFloatInputStream + .getInputStream(new AudioInputStream( + cycling_inputstream, format, + AudioSystem.NOT_SPECIFIED)); + afis = new NonBlockingFloatInputStream(afis); + + if (Math.abs(format.getSampleRate() + - outputformat.getSampleRate()) > 0.000001) + afis = new AudioFloatInputStreamResampler(afis, + outputformat); + + } else { + if (!format.matches(getFormat())) { + throw new IllegalStateException( + "Line is already open with format " + getFormat() + + " and bufferSize " + getBufferSize()); + } + } + + } + + if (event != null) + sendEvent(event); + + } + + public int available() { + synchronized (cycling_buffer) { + return cycling_buffer.length - cycling_avail; + } + } + + public void drain() { + while (true) { + int avail; + synchronized (cycling_buffer) { + avail = cycling_avail; + } + if (avail != 0) + return; + try { + Thread.sleep(1); + } catch (InterruptedException e) { + return; + } + } + } + + public void flush() { + synchronized (cycling_buffer) { + cycling_read_pos = 0; + cycling_write_pos = 0; + cycling_avail = 0; + } + } + + public int getBufferSize() { + synchronized (control_mutex) { + return bufferSize; + } + } + + public AudioFormat getFormat() { + synchronized (control_mutex) { + return format; + } + } + + public int getFramePosition() { + return (int) getLongFramePosition(); + } + + public float getLevel() { + return AudioSystem.NOT_SPECIFIED; + } + + public long getLongFramePosition() { + synchronized (cycling_buffer) { + return cycling_framepos; + } + } + + public long getMicrosecondPosition() { + return (long) (getLongFramePosition() * (1000000.0 / (double) getFormat() + .getSampleRate())); + } + + public boolean isActive() { + synchronized (control_mutex) { + return active; + } + } + + public boolean isRunning() { + synchronized (control_mutex) { + return active; + } + } + + public void start() { + + LineEvent event = null; + + synchronized (control_mutex) { + if (isOpen()) { + if (active) + return; + active = true; + event = new LineEvent(this, LineEvent.Type.START, + getLongFramePosition()); + } + } + + if (event != null) + sendEvent(event); + } + + public void stop() { + LineEvent event = null; + + synchronized (control_mutex) { + if (isOpen()) { + if (!active) + return; + active = false; + event = new LineEvent(this, LineEvent.Type.STOP, + getLongFramePosition()); + } + } + + if (event != null) + sendEvent(event); + } + + public void close() { + + LineEvent event = null; + + synchronized (control_mutex) { + if (!isOpen()) + return; + stop(); + + event = new LineEvent(this, LineEvent.Type.CLOSE, + getLongFramePosition()); + + open = false; + mixer.getMainMixer().closeLine(this); + } + + if (event != null) + sendEvent(event); + + } + + public boolean isOpen() { + synchronized (control_mutex) { + return open; + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java --- a/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java Sun May 25 19:42:00 2008 +0200 +++ b/overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java Sun May 25 21:21:11 2008 +0200 @@ -331,7 +331,10 @@ return deviceid; } - protected float getControlRate() { + /** + * Returns the number of control changes per second. + */ + public float getControlRate() { return controlrate; } diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatConverter/GetFormat.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatConverter/GetFormat.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,41 @@ +/* + * 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 AudioFloatConverter getFormat method */ + +import javax.sound.sampled.*; +import com.sun.media.sound.*; + +public class GetFormat { + + public static void main(String[] args) throws Exception { + AudioFormat frm = new AudioFormat(8000, 16, 1, true, false); + AudioFloatConverter conv = AudioFloatConverter.getConverter(frm); + if(!conv.getFormat().matches(frm)) + throw new RuntimeException("Incorrect audio format returned."); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatConverter/ToFloatArray.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatConverter/ToFloatArray.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,143 @@ +/* + * 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 AudioFloatConverter toFloatArray method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ToFloatArray { + + public static void main(String[] args) throws Exception { + + float[] 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; + } + + // Check conversion from float2byte and byte2float. + for (int big = 0; big < 2; big+=1) + for (int signed = 0; signed < 2; signed+=1) + for (int bits = 8; bits <= 32; bits+=8) { + AudioFormat frm = new AudioFormat(44100, bits, 1, signed==1, big==1); + byte[] buff = new byte[testarray.length * frm.getFrameSize()]; + float[] testarray2 = new float[testarray.length]; + AudioFloatConverter conv = AudioFloatConverter.getConverter(frm); + conv.toByteArray(testarray, buff); + conv.toFloatArray(buff, testarray2); + for (int i = 0; i < testarray2.length; i++) { + if(Math.abs(testarray[i] - testarray2[i]) > 0.05) + throw new RuntimeException("Conversion failed for " + frm +" , arrays not equal enough!\n"); + } + } + + // Check big/little + for (int big = 0; big < 2; big+=1) + for (int signed = 0; signed < 2; signed+=1) + for (int bits = 8; bits <= 32; bits+=8) { + AudioFormat frm = new AudioFormat(44100, bits, 1, signed==1, big==1); + byte[] buff = new byte[testarray.length * frm.getFrameSize()]; + AudioFloatConverter conv = AudioFloatConverter.getConverter(frm); + conv.toByteArray(testarray, buff); + byte[] buff2 = new byte[testarray.length * frm.getFrameSize()]; + int fs = frm.getFrameSize(); + for (int i = 0; i < buff2.length; i+=fs) { + for (int j = 0; j < fs; j++) { + buff2[i+(fs-j-1)] = buff[i+j]; + } + } + float[] testarray2 = new float[testarray.length]; + AudioFormat frm2 = new AudioFormat(44100, bits, 1, signed==1, big==0); + AudioFloatConverter.getConverter(frm2).toFloatArray(buff2, testarray2); + for (int i = 0; i < testarray2.length; i++) { + if(Math.abs(testarray[i] - testarray2[i]) > 0.05) + { + throw new RuntimeException("Conversion failed for " + frm +" to " + frm2 + " , arrays not equal enough!\n"); + } + } + } + + // Check signed/unsigned + for (int big = 0; big < 2; big+=1) + for (int signed = 0; signed < 2; signed+=1) + for (int bits = 8; bits <= 32; bits+=8) { + AudioFormat frm = new AudioFormat(44100, bits, 1, signed==1, big==1); + byte[] b = new byte[testarray.length * frm.getFrameSize()]; + AudioFloatConverter conv = AudioFloatConverter.getConverter(frm); + conv.toByteArray(testarray, b); + int fs = frm.getFrameSize(); + if(big==1) + { + for(int i=0; i < b.length; i+= fs ) + b[i] = (b[i] >= 0) ? (byte)(0x80 | b[i]) : (byte)(0x7F & b[i]); + } + else + { + for(int i=(0+fs-1); i < b.length; i+= fs ) + b[i] = (b[i] >= 0) ? (byte)(0x80 | b[i]) : (byte)(0x7F & b[i]); + } + float[] testarray2 = new float[testarray.length]; + AudioFormat frm2 = new AudioFormat(44100, bits, 1, signed==0, big==1); + AudioFloatConverter.getConverter(frm2).toFloatArray(b, testarray2); + for (int i = 0; i < testarray2.length; i++) { + if(Math.abs(testarray[i] - testarray2[i]) > 0.05) + { + throw new RuntimeException("Conversion failed for " + frm +" to " + frm2 + " , arrays not equal enough!\n"); + } + } + } + + // Check if conversion 32->24, 24->16, 16->8 result in same float data + AudioFormat frm = new AudioFormat(44100, 32, 1, true, true); + byte[] b = new byte[testarray.length * frm.getFrameSize()]; + AudioFloatConverter.getConverter(frm).toByteArray(testarray, b); + for (int bits = 8; bits <= 32; bits+=8) { + AudioFormat frm2 = new AudioFormat(44100, bits, 1, true, true); + byte[] b2 = new byte[testarray.length * frm2.getFrameSize()]; + int fs1 = frm.getFrameSize(); + int fs2 = frm2.getFrameSize(); + int ii = 0; + for (int i = 0; i < b.length; i+=fs1) + for (int j = 0; j < fs2; j++) + b2[ii++] = b[i+j]; + float[] testarray2 = new float[testarray.length]; + AudioFloatConverter.getConverter(frm2).toFloatArray(b2, testarray2); + for (int i = 0; i < testarray2.length; i++) { + if(Math.abs(testarray[i] - testarray2[i]) > 0.05) + { + throw new RuntimeException("Conversion failed for " + frm +" to " + frm2 + " , arrays not equal enough!\n"); + } + } + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/Available.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/Available.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,81 @@ +/* + * 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 AudioFloatInputStream available method */ + +import java.io.*; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Available { + + static float[] test_float_array; + static byte[] test_byte_array; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + + static AudioFloatInputStream getStream1() + { + return AudioFloatInputStream.getInputStream(format, test_byte_array, 0, test_byte_array.length); + } + + static AudioFloatInputStream getStream2() + { + AudioInputStream strm = new AudioInputStream(new ByteArrayInputStream(test_byte_array), format, 1024); + return AudioFloatInputStream.getInputStream(strm); + } + + static void setUp() throws Exception { + test_float_array = new float[1024]; + test_byte_array = new byte[1024*format.getFrameSize()]; + for (int i = 0; i < 1024; i++) { + double ii = i / 1024.0; + ii = ii * ii; + test_float_array[i] = (float)Math.sin(10*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI); + test_float_array[i] *= 0.3; + } + AudioFloatConverter.getConverter(format).toByteArray(test_float_array, test_byte_array); + } + + public static void main(String[] args) throws Exception { + setUp(); + for (int i = 0; i < 2; i++) { + AudioFloatInputStream stream = null; + if(i == 0) stream = getStream1(); + if(i == 1) stream = getStream2(); + float[] buff = new float[512]; + if(stream.available() != 1024) + throw new RuntimeException("stream.available return incorrect value."); + stream.read(buff); + if(stream.available() != 512) + throw new RuntimeException("stream.available return incorrect value."); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/Close.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/Close.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,72 @@ +/* + * 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 AudioFloatInputStream close method */ + +import java.io.*; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Close { + + static float[] test_float_array; + static byte[] test_byte_array; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + + static AudioFloatInputStream getStream1() + { + return AudioFloatInputStream.getInputStream(format, test_byte_array, 0, test_byte_array.length); + } + + static AudioFloatInputStream getStream2() + { + AudioInputStream strm = new AudioInputStream(new ByteArrayInputStream(test_byte_array), format, 1024); + return AudioFloatInputStream.getInputStream(strm); + } + + static void setUp() throws Exception { + test_float_array = new float[1024]; + test_byte_array = new byte[1024*format.getFrameSize()]; + for (int i = 0; i < 1024; i++) { + double ii = i / 1024.0; + ii = ii * ii; + test_float_array[i] = (float)Math.sin(10*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI); + test_float_array[i] *= 0.3; + } + AudioFloatConverter.getConverter(format).toByteArray(test_float_array, test_byte_array); + } + + public static void main(String[] args) throws Exception { + setUp(); + getStream1().close(); + getStream2().close(); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/GetFormat.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/GetFormat.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,74 @@ +/* + * 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 AudioFloatInputStream getFormat method */ + +import java.io.*; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetFormat { + + static float[] test_float_array; + static byte[] test_byte_array; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + + static AudioFloatInputStream getStream1() + { + return AudioFloatInputStream.getInputStream(format, test_byte_array, 0, test_byte_array.length); + } + + static AudioFloatInputStream getStream2() + { + AudioInputStream strm = new AudioInputStream(new ByteArrayInputStream(test_byte_array), format, 1024); + return AudioFloatInputStream.getInputStream(strm); + } + + static void setUp() throws Exception { + test_float_array = new float[1024]; + test_byte_array = new byte[1024*format.getFrameSize()]; + for (int i = 0; i < 1024; i++) { + double ii = i / 1024.0; + ii = ii * ii; + test_float_array[i] = (float)Math.sin(10*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI); + test_float_array[i] *= 0.3; + } + AudioFloatConverter.getConverter(format).toByteArray(test_float_array, test_byte_array); + } + + public static void main(String[] args) throws Exception { + setUp(); + if(!getStream1().getFormat().matches(format)) + throw new RuntimeException("Incorrect audio format returned."); + if(!getStream2().getFormat().matches(format)) + throw new RuntimeException("Incorrect audio format returned."); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/GetFrameLength.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/GetFrameLength.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,74 @@ +/* + * 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 AudioFloatInputStream getFrameLength method */ + +import java.io.*; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetFrameLength { + + static float[] test_float_array; + static byte[] test_byte_array; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + + static AudioFloatInputStream getStream1() + { + return AudioFloatInputStream.getInputStream(format, test_byte_array, 0, test_byte_array.length); + } + + static AudioFloatInputStream getStream2() + { + AudioInputStream strm = new AudioInputStream(new ByteArrayInputStream(test_byte_array), format, 1024); + return AudioFloatInputStream.getInputStream(strm); + } + + static void setUp() throws Exception { + test_float_array = new float[1024]; + test_byte_array = new byte[1024*format.getFrameSize()]; + for (int i = 0; i < 1024; i++) { + double ii = i / 1024.0; + ii = ii * ii; + test_float_array[i] = (float)Math.sin(10*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI); + test_float_array[i] *= 0.3; + } + AudioFloatConverter.getConverter(format).toByteArray(test_float_array, test_byte_array); + } + + public static void main(String[] args) throws Exception { + setUp(); + if(getStream1().getFrameLength() != 1024L) + throw new RuntimeException("Incorrect frame length returned."); + if(getStream2().getFrameLength() != 1024L) + throw new RuntimeException("Incorrect frame length returned."); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/MarkSupported.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/MarkSupported.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,74 @@ +/* + * 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 AudioFloatInputStream markSupported method */ + +import java.io.*; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class MarkSupported { + + static float[] test_float_array; + static byte[] test_byte_array; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + + static AudioFloatInputStream getStream1() + { + return AudioFloatInputStream.getInputStream(format, test_byte_array, 0, test_byte_array.length); + } + + static AudioFloatInputStream getStream2() + { + AudioInputStream strm = new AudioInputStream(new ByteArrayInputStream(test_byte_array), format, 1024); + return AudioFloatInputStream.getInputStream(strm); + } + + static void setUp() throws Exception { + test_float_array = new float[1024]; + test_byte_array = new byte[1024*format.getFrameSize()]; + for (int i = 0; i < 1024; i++) { + double ii = i / 1024.0; + ii = ii * ii; + test_float_array[i] = (float)Math.sin(10*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI); + test_float_array[i] *= 0.3; + } + AudioFloatConverter.getConverter(format).toByteArray(test_float_array, test_byte_array); + } + + public static void main(String[] args) throws Exception { + setUp(); + if(!getStream1().markSupported()) + throw new RuntimeException("Mark not supported."); + if(!getStream2().markSupported()) + throw new RuntimeException("Mark not supported."); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/Read.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/Read.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,83 @@ +/* + * 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 AudioFloatInputStream read method */ + +import java.io.*; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Read { + + static float[] test_float_array; + static byte[] test_byte_array; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + + static AudioFloatInputStream getStream1() + { + return AudioFloatInputStream.getInputStream(format, test_byte_array, 0, test_byte_array.length); + } + + static AudioFloatInputStream getStream2() + { + AudioInputStream strm = new AudioInputStream(new ByteArrayInputStream(test_byte_array), format, 1024); + return AudioFloatInputStream.getInputStream(strm); + } + + static void setUp() throws Exception { + test_float_array = new float[1024]; + test_byte_array = new byte[1024*format.getFrameSize()]; + for (int i = 0; i < 1024; i++) { + double ii = i / 1024.0; + ii = ii * ii; + test_float_array[i] = (float)Math.sin(10*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI); + test_float_array[i] *= 0.3; + } + AudioFloatConverter.getConverter(format).toByteArray(test_float_array, test_byte_array); + } + + public static void main(String[] args) throws Exception { + setUp(); + + for (int i = 0; i < 2; i++) { + AudioFloatInputStream stream = null; + if(i == 0) stream = getStream1(); + if(i == 1) stream = getStream2(); + float v = 0; + stream.skip(512); + v = stream.read(); + if(!(Math.abs(v - test_float_array[512]) < 0.0001)) + { + throw new RuntimeException("Read returned unexpected value."); + } + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/ReadFloatArray.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/ReadFloatArray.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,81 @@ +/* + * 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 AudioFloatInputStream read(float[]) method */ + +import java.io.*; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ReadFloatArray { + + static float[] test_float_array; + static byte[] test_byte_array; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + + static AudioFloatInputStream getStream1() + { + return AudioFloatInputStream.getInputStream(format, test_byte_array, 0, test_byte_array.length); + } + + static AudioFloatInputStream getStream2() + { + AudioInputStream strm = new AudioInputStream(new ByteArrayInputStream(test_byte_array), format, 1024); + return AudioFloatInputStream.getInputStream(strm); + } + + static void setUp() throws Exception { + test_float_array = new float[1024]; + test_byte_array = new byte[1024*format.getFrameSize()]; + for (int i = 0; i < 1024; i++) { + double ii = i / 1024.0; + ii = ii * ii; + test_float_array[i] = (float)Math.sin(10*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI); + test_float_array[i] *= 0.3; + } + AudioFloatConverter.getConverter(format).toByteArray(test_float_array, test_byte_array); + } + + public static void main(String[] args) throws Exception { + setUp(); + + for (int i = 0; i < 2; i++) { + AudioFloatInputStream stream = null; + if(i == 0) stream = getStream1(); + if(i == 1) stream = getStream2(); + float[] buff = new float[1024]; + stream.read(buff); + for (int j = 0; j < buff.length; j++) + if(!(Math.abs(buff[j] - test_float_array[j]) < 0.0001)) + throw new RuntimeException("Incorrect data in buffer."); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/ReadFloatArrayIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/ReadFloatArrayIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,83 @@ +/* + * 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 AudioFloatInputStream read(float[], int, int) method */ + +import java.io.*; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ReadFloatArrayIntInt { + + static float[] test_float_array; + static byte[] test_byte_array; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + + static AudioFloatInputStream getStream1() + { + return AudioFloatInputStream.getInputStream(format, test_byte_array, 0, test_byte_array.length); + } + + static AudioFloatInputStream getStream2() + { + AudioInputStream strm = new AudioInputStream(new ByteArrayInputStream(test_byte_array), format, 1024); + return AudioFloatInputStream.getInputStream(strm); + } + + static void setUp() throws Exception { + test_float_array = new float[1024]; + test_byte_array = new byte[1024*format.getFrameSize()]; + for (int i = 0; i < 1024; i++) { + double ii = i / 1024.0; + ii = ii * ii; + test_float_array[i] = (float)Math.sin(10*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI); + test_float_array[i] *= 0.3; + } + AudioFloatConverter.getConverter(format).toByteArray(test_float_array, test_byte_array); + } + + public static void main(String[] args) throws Exception { + setUp(); + + for (int i = 0; i < 2; i++) { + AudioFloatInputStream stream = null; + if(i == 0) stream = getStream1(); + if(i == 1) stream = getStream2(); + float[] buff = new float[1024]; + stream.read(buff,0,512); + stream.read(buff,512,512); + for (int j = 0; j < buff.length; j++) + if(!(Math.abs(buff[j] - test_float_array[j]) < 0.0001)) + throw new RuntimeException("Incorrect data in buffer."); + + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/Reset.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/Reset.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,87 @@ +/* + * 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 AudioFloatInputStream reset method */ + +import java.io.*; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Reset { + + static float[] test_float_array; + static byte[] test_byte_array; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + + static AudioFloatInputStream getStream1() + { + return AudioFloatInputStream.getInputStream(format, test_byte_array, 0, test_byte_array.length); + } + + static AudioFloatInputStream getStream2() + { + AudioInputStream strm = new AudioInputStream(new ByteArrayInputStream(test_byte_array), format, 1024); + return AudioFloatInputStream.getInputStream(strm); + } + + static void setUp() throws Exception { + test_float_array = new float[1024]; + test_byte_array = new byte[1024*format.getFrameSize()]; + for (int i = 0; i < 1024; i++) { + double ii = i / 1024.0; + ii = ii * ii; + test_float_array[i] = (float)Math.sin(10*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI); + test_float_array[i] *= 0.3; + } + AudioFloatConverter.getConverter(format).toByteArray(test_float_array, test_byte_array); + } + + public static void main(String[] args) throws Exception { + setUp(); + + for (int i = 0; i < 2; i++) { + AudioFloatInputStream stream = null; + if(i == 0) stream = getStream1(); + if(i == 1) stream = getStream2(); + float[] buff = new float[512]; + float[] buff2 = new float[512]; + stream.read(buff); + stream.mark(512); + stream.read(buff); + stream.reset(); + stream.read(buff2); + for (int j = 0; j < buff2.length; j++) + if(!(Math.abs(buff[j] - buff2[j]) < 0.0001)) + throw new RuntimeException("Incorrect data in buffer."); + + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/Skip.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/AudioFloatInputStream/Skip.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,83 @@ +/* + * 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 AudioFloatInputStream skip method */ + +import java.io.*; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Skip { + + static float[] test_float_array; + static byte[] test_byte_array; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + + static AudioFloatInputStream getStream1() + { + return AudioFloatInputStream.getInputStream(format, test_byte_array, 0, test_byte_array.length); + } + + static AudioFloatInputStream getStream2() + { + AudioInputStream strm = new AudioInputStream(new ByteArrayInputStream(test_byte_array), format, 1024); + return AudioFloatInputStream.getInputStream(strm); + } + + static void setUp() throws Exception { + test_float_array = new float[1024]; + test_byte_array = new byte[1024*format.getFrameSize()]; + for (int i = 0; i < 1024; i++) { + double ii = i / 1024.0; + ii = ii * ii; + test_float_array[i] = (float)Math.sin(10*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(1.731 + 2*ii*2*Math.PI); + test_float_array[i] += (float)Math.sin(0.231 + 6.3*ii*2*Math.PI); + test_float_array[i] *= 0.3; + } + AudioFloatConverter.getConverter(format).toByteArray(test_float_array, test_byte_array); + } + + public static void main(String[] args) throws Exception { + setUp(); + + for (int i = 0; i < 2; i++) { + AudioFloatInputStream stream = null; + if(i == 0) stream = getStream1(); + if(i == 1) stream = getStream2(); + float[] buff = new float[512]; + stream.skip(512); + stream.read(buff); + for (int j = 0; j < buff.length; j++) + if(!(Math.abs(buff[j] - test_float_array[j+512]) < 0.0001)) + throw new RuntimeException("Incorrect data in buffer."); + + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/GetInputStream.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/GetInputStream.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,91 @@ +/* + * 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 getInputStream method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetInputStream { + + 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 < 2; i++) { + ModelByteBuffer buff; + if(i == 0) + buff = new ModelByteBuffer(test_file); + else + buff = new ModelByteBuffer(test_byte_array); + + byte[] b = new byte[test_byte_array.length]; + buff.getInputStream().read(b); + for (int j = 0; j < b.length; j++) + if(b[i] != test_byte_array[i]) + throw new RuntimeException("Byte array compare fails!"); + } + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/GetRoot.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/GetRoot.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,82 @@ +/* + * 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 getRoot method */ + +import java.io.File; +import java.io.FileOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetRoot { + + 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(); + + ModelByteBuffer buff = new ModelByteBuffer(test_file); + ModelByteBuffer buff2 = buff.subbuffer(10, 10); + ModelByteBuffer buff3 = buff2.subbuffer(2, 2); + if(buff != buff3.getRoot()) + throw new RuntimeException("ModelByteBuffer doesn't return correct root!"); + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/Load.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/Load.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,89 @@ +/* + * 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 load method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Load { + + 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(); + + ModelByteBuffer buff = new ModelByteBuffer(test_file); + + buff.load(); + if(buff.array() == null) + throw new RuntimeException("buf is null!"); + if(buff.array().length != test_byte_array.length) + throw new RuntimeException("buff.array().length length is incorrect!"); + byte[] b = buff.array(); + for (int i = 0; i < b.length; i++) + if(test_byte_array[i] != b[i]) + throw new RuntimeException("buff.array() incorrect!"); + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/LoadAll.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/LoadAll.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,93 @@ +/* + * 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 loadAll method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class LoadAll { + + 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(); + + ModelByteBuffer buff = new ModelByteBuffer(test_file); + List col = new ArrayList(); + col.add(buff); + ModelByteBuffer.loadAll(col); + if(buff.array() == null) + throw new RuntimeException("buf is null!"); + if(buff.array().length != test_byte_array.length) + throw new RuntimeException("buff.array().length length is incorrect!"); + byte[] b = buff.array(); + for (int i = 0; i < b.length; i++) + if(test_byte_array[i] != b[i]) + throw new RuntimeException("buff.array() incorrect!"); + + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/NewModelByteBufferByteArray.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/NewModelByteBufferByteArray.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,84 @@ +/* + * 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(byte[]) constructor */ + +import java.io.File; +import java.io.FileOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelByteBufferByteArray { + + 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(); + + ModelByteBuffer buff = new ModelByteBuffer(test_byte_array); + if(buff.array() != test_byte_array) + throw new RuntimeException("buff.bytearray incorrect!"); + if(buff.capacity() != test_byte_array.length) + throw new RuntimeException("buff.capacity() incorrect!"); + if(buff.arrayOffset() != 0) + throw new RuntimeException("buff.arrayOffset not 0!"); + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,86 @@ +/* + * 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(byte[],int,int) constructor */ + +import java.io.File; +import java.io.FileOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelByteBufferByteArrayIntInt { + + 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(); + + ModelByteBuffer buff = new ModelByteBuffer(test_byte_array,10,20); + if(buff.array() != test_byte_array) + throw new RuntimeException("buff.array() incorrect!"); + if(buff.capacity() != 20) + throw new RuntimeException("buff.capacity() not 20!"); + if(buff.arrayOffset() != 10) + throw new RuntimeException("buff.arrayOffset() not 10!"); + if(buff.getFile() != null) + throw new RuntimeException("buff.getFile() not null!"); + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/NewModelByteBufferFile.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/NewModelByteBufferFile.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,88 @@ +/* + * 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(File) constructor */ + +import java.io.File; +import java.io.FileOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelByteBufferFile { + + 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(); + + ModelByteBuffer buff = new ModelByteBuffer(test_file); + if(buff.array() != null) + throw new RuntimeException("buff.array() not null!"); + if(buff.capacity() != test_file.length()) + throw new RuntimeException("buff.capacity() incorrect!"); + if(buff.arrayOffset() != 0) + throw new RuntimeException("buff.arrayOffset() not 0!"); + if(buff.getFile() != test_file) + throw new RuntimeException("buff.getFile() incorrect!"); + if(buff.getFilePointer() != 0) + throw new RuntimeException("buff.getFilePointer() not 0!"); + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/NewModelByteBufferFileLongLong.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/NewModelByteBufferFileLongLong.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,88 @@ +/* + * 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(File,long,long) constructor */ + +import java.io.File; +import java.io.FileOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelByteBufferFileLongLong { + + 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(); + + ModelByteBuffer buff = new ModelByteBuffer(test_file,10,20); + if(buff.array() != null) + throw new RuntimeException("buff.array() not null!"); + if(buff.capacity() != 20) + throw new RuntimeException("buff.capacity() not 20!"); + if(buff.arrayOffset() != 0) + throw new RuntimeException("buff.arrayOffset() not 0!"); + if(buff.getFile() != test_file) + throw new RuntimeException("buff.getFile incorrect!"); + if(buff.getFilePointer() != 10) + throw new RuntimeException("buff.getFilePointer not 10!"); + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/SubbufferLong.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/SubbufferLong.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,92 @@ +/* + * 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 subbuffer(long) method */ + +import java.io.File; +import java.io.FileOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SubbufferLong { + + 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 < 2; i++) { + ModelByteBuffer buff; + if(i == 0) + buff = new ModelByteBuffer(test_file); + else + buff = new ModelByteBuffer(test_byte_array); + + ModelByteBuffer buff2 = buff.subbuffer(10); + if(buff2.getFilePointer() != buff.getFilePointer()) + throw new RuntimeException("buff2.getFilePointer() incorreect!"); + if(buff2.arrayOffset() != 10) + throw new RuntimeException("buff2.arrayOffset() not 10!"); + if(buff2.capacity() != buff.capacity()-10) + throw new RuntimeException("buff2.capacity() not correct!"); + } + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/SubbufferLongLong.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/SubbufferLongLong.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,92 @@ +/* + * 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 subbuffer(long,long) method */ + +import java.io.File; +import java.io.FileOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SubbufferLongLong { + + 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 < 2; i++) { + ModelByteBuffer buff; + if(i == 0) + buff = new ModelByteBuffer(test_file); + else + buff = new ModelByteBuffer(test_byte_array); + + ModelByteBuffer buff2 = buff.subbuffer(10,21); + if(buff2.getFilePointer() != buff.getFilePointer()) + throw new RuntimeException("buff2.getFilePointer() incorrect!"); + if(buff2.arrayOffset() != 10) + throw new RuntimeException("buff2.arrayOffset() not 10!"); + if(buff2.capacity() != 11) + throw new RuntimeException("buff2.capacity() not 11!"); + } + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/SubbufferLongLongBoolean.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/SubbufferLongLongBoolean.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,98 @@ +/* + * 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 subbuffer(long,long,boolean) method */ + +import java.io.File; +import java.io.FileOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SubbufferLongLongBoolean { + + 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 < 2; i++) { + ModelByteBuffer buff; + if(i == 0) + buff = new ModelByteBuffer(test_file); + else + buff = new ModelByteBuffer(test_byte_array); + + ModelByteBuffer buff2 = buff.subbuffer(10,21,true); + if(buff2.getRoot() != buff2); + if(buff2.capacity() != 11); + if(i == 0) + { + if(buff2.getFilePointer() != buff.getFilePointer()+10) + throw new RuntimeException("buff2.getFilePointer() incorrect!"); + } + else + { + if(buff2.arrayOffset() != 10) + throw new RuntimeException("buff2.arrayOffset() not 10!"); + } + } + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/Unload.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/Unload.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,83 @@ +/* + * 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 unload method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Unload { + + 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(); + + ModelByteBuffer buff = new ModelByteBuffer(test_file); + buff.load(); + buff.unload(); + if(buff.array() != null) + throw new RuntimeException("buff.array() not null!"); + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/WriteTo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBuffer/WriteTo.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,92 @@ +/* + * 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 writeTo method */ + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class WriteTo { + + 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 < 2; i++) { + ModelByteBuffer buff; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + if(i == 0) + buff = new ModelByteBuffer(test_file); + else + buff = new ModelByteBuffer(test_byte_array); + buff.writeTo(baos); + byte[] b = baos.toByteArray(); + for (int j = 0; j < b.length; j++) + if(b[i] != test_byte_array[i]) + throw new RuntimeException("baos.toByteArray() incorrect!"); + } + } + finally + { + tearDown(); + } + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/GetAttenuation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/GetAttenuation.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,97 @@ +/* + * 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 ModelByteBufferWavetable getAttenuation method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetAttenuation { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + public static void main(String[] args) throws Exception { + + setUp(); + + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer,format); + wavetable.setAttenuation(10f); + if(wavetable.getAttenuation() != 10f) + throw new RuntimeException("wavetable.getAttenuation() not 10!"); + wavetable.setAttenuation(20f); + if(wavetable.getAttenuation() != 20f) + throw new RuntimeException("wavetable.getAttenuation() not 20!"); + + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/GetChannels.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/GetChannels.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,97 @@ +/* + * 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 ModelByteBufferWavetable getChannels method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetChannels { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + public static void main(String[] args) throws Exception { + + setUp(); + + AudioFormat format1 = new AudioFormat(44100, 16, 1, true, false); + AudioFormat format2 = new AudioFormat(44100, 16, 2, true, false); + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer,format1,10f); + if(wavetable.getChannels() != 1) + throw new RuntimeException("wavetable.getChannels() not 1!"); + wavetable = new ModelByteBufferWavetable(buffer,format2,10f); + if(wavetable.getChannels() != 2) + throw new RuntimeException("wavetable.getChannels() not 2!"); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/GetLoopLength.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/GetLoopLength.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,96 @@ +/* + * 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 ModelByteBufferWavetable getLoopLength method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetLoopLength { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + public static void main(String[] args) throws Exception { + + setUp(); + + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer,format); + wavetable.setLoopLength(10f); + if(wavetable.getLoopLength() != 10f) + throw new RuntimeException("wavetable.getLoopLength() not 10!"); + wavetable.setLoopLength(20f); + if(wavetable.getLoopLength() != 20f) + throw new RuntimeException("wavetable.getLoopLength() not 20!"); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/GetLoopStart.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/GetLoopStart.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,96 @@ +/* + * 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 ModelByteBufferWavetable getLoopStart method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetLoopStart { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + public static void main(String[] args) throws Exception { + + setUp(); + + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer,format); + wavetable.setLoopStart(10f); + if(wavetable.getLoopStart() != 10f) + throw new RuntimeException("wavetable.getLoopStart() not 10!"); + wavetable.setLoopStart(20f); + if(wavetable.getLoopStart() != 20f) + throw new RuntimeException("wavetable.getLoopStart() not 20!"); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/GetPitchCorrection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/GetPitchCorrection.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,97 @@ +/* + * 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 ModelByteBufferWavetable getPitchCorrect method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetPitchCorrection { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + public static void main(String[] args) throws Exception { + + setUp(); + + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer,format); + wavetable.setPitchcorrection(10f); + if(wavetable.getPitchcorrection() != 10f) + throw new RuntimeException("wavetable.getPitchcorrection() not 10!"); + wavetable.setPitchcorrection(20f); + if(wavetable.getPitchcorrection() != 20f) + throw new RuntimeException("wavetable.getPitchcorrection() not 20!"); + + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/NewModelByteBufferWavetableModelByteBuffer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/NewModelByteBufferWavetableModelByteBuffer.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,94 @@ +/* + * 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 ModelByteBufferWavetable(ModelByteBuffer) method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelByteBufferWavetableModelByteBuffer { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + public static void main(String[] args) throws Exception { + + setUp(); + + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer_wave); + if(wavetable.getBuffer() != buffer_wave) + throw new RuntimeException("wavetable.getBuffer() incorrect!"); + if(!wavetable.getFormat().matches(format)) + throw new RuntimeException("wavetable.getFormat() incorrect!"); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/NewModelByteBufferWavetableModelByteBufferAudioFormat.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/NewModelByteBufferWavetableModelByteBufferAudioFormat.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,94 @@ +/* + * 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 ModelByteBufferWavetable(ModelByteBuffer, AudioFormat) method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelByteBufferWavetableModelByteBufferAudioFormat { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + public static void main(String[] args) throws Exception { + + setUp(); + + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer,format); + if(wavetable.getBuffer() != buffer) + throw new RuntimeException("wavetable.getBuffer() incorrect!"); + if(wavetable.getFormat() != format) + throw new RuntimeException("wavetable.getFormat() incorrect!"); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/NewModelByteBufferWavetableModelByteBufferAudioFormatFloat.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/NewModelByteBufferWavetableModelByteBufferAudioFormatFloat.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,94 @@ +/* + * 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 ModelByteBufferWavetable(ModelByteBuffer, AudioFormat) method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelByteBufferWavetableModelByteBufferAudioFormatFloat { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + public static void main(String[] args) throws Exception { + + setUp(); + + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer,format); + if(wavetable.getBuffer() != buffer) + throw new RuntimeException("wavetable.getBuffer() incorrect!"); + if(!wavetable.getFormat().matches(format)) + throw new RuntimeException("wavetable.getFormat() incorrect!"); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/NewModelByteBufferWavetableModelByteBufferFloat.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/NewModelByteBufferWavetableModelByteBufferFloat.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,96 @@ +/* + * 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 ModelByteBufferWavetable(ModelByteBuffer, AudioFormat, float) method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelByteBufferWavetableModelByteBufferFloat { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + public static void main(String[] args) throws Exception { + + setUp(); + + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer,format,10f); + if(wavetable.getBuffer() != buffer) + throw new RuntimeException("wavetable.getBuffer() incorrect!"); + if(!wavetable.getFormat().matches(format)) + throw new RuntimeException("wavetable.getFormat() incorrect!"); + if(wavetable.getPitchcorrection() != 10f) + throw new RuntimeException("wavetable.getPitchcorrection() not 10!"); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/Open.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/Open.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,92 @@ +/* + * 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 ModelByteBufferWavetable open method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Open { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + public static void main(String[] args) throws Exception { + + setUp(); + + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer,format); + if(wavetable.open(44100) != null) + throw new RuntimeException("wavetable.open(44100) doesn't return null!"); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/Set8BitExtensionBuffer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/Set8BitExtensionBuffer.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,119 @@ +/* + * 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 ModelByteBufferWavetable set8BitExtensionBuffer method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Set8BitExtensionBuffer { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + static float compare(float[] a, float[] b) + { + float ac_error = 0; + int counter = 0; + for (int i = 0; i < a.length; i++) { + ac_error += Math.abs(a[i] - b[i]); + counter++; + } + return ac_error / ((float)counter); + + } + + public static void main(String[] args) throws Exception { + + setUp(); + + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer16_8,format,10f); + float[] f1 = new float[testarray.length]; + float[] f2 = new float[testarray.length]; + wavetable.openStream().read(f1); + wavetable.set8BitExtensionBuffer(buffer8); + if(wavetable.get8BitExtensionBuffer() != buffer8) + throw new RuntimeException("wavetable.get8BitExtensionBuffer() incorrect!"); + wavetable.openStream().read(f2); + // f2 should have more accurity than f1, + // about 256 times more, or 8 bits + float spec1 = compare(f1, testarray); + float spec2 = compare(f2, testarray); + if((spec1/spec2) <= 200) + throw new RuntimeException("(spec1/spec2) <= 200!"); + + + } + + + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/SetLoopType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelByteBufferWavetable/SetLoopType.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,96 @@ +/* + * 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 ModelByteBufferWavetable SetLoopType method */ + +import java.io.ByteArrayOutputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetLoopType { + + static float[] testarray; + static byte[] test_byte_array; + static byte[] test_byte_array_8ext; + static AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + static AudioFormat format24 = new AudioFormat(44100, 24, 1, true, false); + static ModelByteBuffer buffer; + static ModelByteBuffer buffer_wave; + static ModelByteBuffer buffer8; + static ModelByteBuffer buffer16_8; + static ModelByteBuffer buffer24; + + 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); + buffer = new ModelByteBuffer(test_byte_array); + + byte[] test_byte_array2 = new byte[testarray.length*3]; + buffer24 = new ModelByteBuffer(test_byte_array2); + test_byte_array_8ext = new byte[testarray.length]; + byte[] test_byte_array_8_16 = new byte[testarray.length*2]; + AudioFloatConverter.getConverter(format24).toByteArray(testarray, test_byte_array2); + int ix = 0; + int x = 0; + for (int i = 0; i < test_byte_array_8ext.length; i++) { + test_byte_array_8ext[i] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + test_byte_array_8_16[x++] = test_byte_array2[ix++]; + } + buffer16_8 = new ModelByteBuffer(test_byte_array_8_16); + buffer8 = new ModelByteBuffer(test_byte_array_8ext); + + AudioInputStream ais = new AudioInputStream(buffer.getInputStream(), format, testarray.length); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + AudioSystem.write(ais, AudioFileFormat.Type.WAVE, baos); + buffer_wave = new ModelByteBuffer(baos.toByteArray()); + } + + public static void main(String[] args) throws Exception { + + setUp(); + + ModelByteBufferWavetable wavetable = new ModelByteBufferWavetable(buffer,format); + wavetable.setLoopType(1); + if(wavetable.getLoopType() != 1) + throw new RuntimeException("wavetable.getLoopType() not 1!"); + wavetable.setLoopType(2); + if(wavetable.getLoopType() != 2) + throw new RuntimeException("wavetable.getLoopType() not 2!"); + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelDestination/NewModelDestination.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelDestination/NewModelDestination.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,46 @@ +/* + * 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 ModelDestination constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelDestination { + + public static void main(String[] args) throws Exception { + ModelDestination dest = new ModelDestination(); + if(dest.getIdentifier() != ModelDestination.DESTINATION_NONE) + throw new RuntimeException("dest.getIdentifier() is not equals ModelDestination.DESTINATION_NONE!"); + if(!(dest.getTransform() instanceof ModelStandardTransform)) + throw new RuntimeException("dest.getTransform() is not instancoef ModelStandardTransform!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelDestination/NewModelDestinationModelIdentifier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelDestination/NewModelDestinationModelIdentifier.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,46 @@ +/* + * 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 ModelDestination(ModelIdentifier) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelDestinationModelIdentifier { + + public static void main(String[] args) throws Exception { + ModelDestination dest = new ModelDestination(ModelDestination.DESTINATION_EG1_ATTACK); + if(dest.getIdentifier() != ModelDestination.DESTINATION_EG1_ATTACK) + throw new RuntimeException("dest.getIdentifier() is not equals ModelDestination.DESTINATION_EG1_ATTACK!"); + if(!(dest.getTransform() instanceof ModelStandardTransform)) + throw new RuntimeException("dest.getTransform() is not instancoef ModelStandardTransform!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelDestination/SetIdentifier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelDestination/SetIdentifier.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelByteBufferWavetable setIdentifier(ModelIdentifier) method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetIdentifier { + + public static void main(String[] args) throws Exception { + ModelDestination dest = new ModelDestination(); + dest.setIdentifier(ModelDestination.DESTINATION_EG1_ATTACK); + if(dest.getIdentifier() != ModelDestination.DESTINATION_EG1_ATTACK) + throw new RuntimeException("dest.getIdentifier() is not equals ModelDestination.DESTINATION_EG1_ATTACK!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelDestination/SetTransform.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelDestination/SetTransform.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,46 @@ +/* + * 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 ModelByteBufferWavetable setTransform(ModelTransform) method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetTransform{ + + public static void main(String[] args) throws Exception { + ModelDestination dest = new ModelDestination(); + ModelStandardTransform newtransform = new ModelStandardTransform(); + dest.setTransform(newtransform); + if(dest.getTransform() != newtransform) + throw new RuntimeException("dest.getTransform() is incorrect!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/EqualsObject.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/EqualsObject.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,54 @@ +/* + * 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 ModelIdentifier equals method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class EqualsObject { + + public static void main(String[] args) throws Exception { + ModelIdentifier id = new ModelIdentifier("test","a",1); + ModelIdentifier id2 = new ModelIdentifier("test","a",1); + ModelIdentifier id3 = new ModelIdentifier("test","a",2); + ModelIdentifier id4 = new ModelIdentifier("test","b",1); + ModelIdentifier id5 = new ModelIdentifier("hello","a",1); + if(!id.equals(id2)) + throw new RuntimeException("Compare failed!"); + if(id.equals(id3)) + throw new RuntimeException("Compare failed!"); + if(id.equals(id4)) + throw new RuntimeException("Compare failed!"); + if(id.equals(id5)) + throw new RuntimeException("Compare failed!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/NewModelIdentifierString.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/NewModelIdentifierString.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,48 @@ +/* + * 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 ModelIdentifier(String) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelIdentifierString { + + public static void main(String[] args) throws Exception { + ModelIdentifier id = new ModelIdentifier("test"); + if(!id.getObject().equals("test")) + throw new RuntimeException("id.getObject() doesn't return \"test\"!"); + if(id.getVariable() != null) + throw new RuntimeException("id.getVariable() doesn't return null!"); + if(id.getInstance() != 0) + throw new RuntimeException("id.getInstance() doesn't return 0!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/NewModelIdentifierStringInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/NewModelIdentifierStringInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,48 @@ +/* + * 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 ModelIdentifier(String, integer) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelIdentifierStringInt { + + public static void main(String[] args) throws Exception { + ModelIdentifier id = new ModelIdentifier("test",1); + if(!id.getObject().equals("test")) + throw new RuntimeException("id.getObject() doesn't return \"test\"!"); + if(id.getVariable() != null) + throw new RuntimeException("id.getVariable() doesn't return null!"); + if(id.getInstance() != 1) + throw new RuntimeException("id.getInstance() doesn't return 1!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/NewModelIdentifierStringString.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/NewModelIdentifierStringString.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,48 @@ +/* + * 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 ModelIdentifier(String,String) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelIdentifierStringString { + + public static void main(String[] args) throws Exception { + ModelIdentifier id = new ModelIdentifier("test","a"); + if(!id.getObject().equals("test")) + throw new RuntimeException("id.getObject() doesn't return \"test\"!"); + if(!id.getVariable().equals("a")) + throw new RuntimeException("id.getVariable() doesn't return \"a\"!"); + if(id.getInstance() != 0) + throw new RuntimeException("id.getInstance() doesn't return 0!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/NewModelIdentifierStringStringInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/NewModelIdentifierStringStringInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,48 @@ +/* + * 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 ModelIdentifier(String,String,int) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelIdentifierStringStringInt { + + public static void main(String[] args) throws Exception { + ModelIdentifier id = new ModelIdentifier("test","a",1);; + if(!id.getObject().equals("test")) + throw new RuntimeException("id.getObject() doesn't return \"test\"!"); + if(!id.getVariable().equals("a")) + throw new RuntimeException("id.getVariable() doesn't return \"a\"!"); + if(id.getInstance() != 1) + throw new RuntimeException("id.getInstance() doesn't return 1!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/SetInstance.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/SetInstance.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelIdentifier setInstance method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetInstance { + + public static void main(String[] args) throws Exception { + ModelIdentifier id = new ModelIdentifier("test","a",1); + id.setInstance(2); + if(id.getInstance() != 2) + throw new RuntimeException("id.getInstance() doesn't return 2!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/SetObject.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/SetObject.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelIdentifier setObject method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetObject { + + public static void main(String[] args) throws Exception { + ModelIdentifier id = new ModelIdentifier("test","a",1); + id.setObject("hello"); + if(!id.getObject().equals("hello")) + throw new RuntimeException("id.getObject() does't return \"hello\"!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/SetVariable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelIdentifier/SetVariable.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelIdentifier setVariable method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetVariable { + + public static void main(String[] args) throws Exception { + ModelIdentifier id = new ModelIdentifier("test","a",1); + id.setVariable("b"); + if(!id.getVariable().equals("b")) + throw new RuntimeException("id.getVariable() does't return \"b\"!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/GetOscillators.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/GetOscillators.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,44 @@ +/* + * 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 ModelPerformer getOscillators method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetOscillators { + + public static void main(String[] args) throws Exception { + ModelPerformer performer = new ModelPerformer(); + if(performer.getOscillators() == null) + throw new RuntimeException("performer.getOscillators() returned null!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetConnectionBlocks.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetConnectionBlocks.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,48 @@ +/* + * 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 ModelPerformer setConnectionBlocks method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetConnectionBlocks { + + public static void main(String[] args) throws Exception { + ModelPerformer performer = new ModelPerformer(); + List newlist = new ArrayList(); + performer.setConnectionBlocks(newlist); + if(performer.getConnectionBlocks() != newlist) + throw new RuntimeException("performer.getConnectionBlocks() returned incorrect data!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetDefaultConnectionsEnabled.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetDefaultConnectionsEnabled.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,49 @@ +/* + * 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 ModelPerformer setDefaultConnectionsEnabled method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetDefaultConnectionsEnabled { + + public static void main(String[] args) throws Exception { + ModelPerformer performer = new ModelPerformer(); + performer.setDefaultConnectionsEnabled(true); + if(performer.isDefaultConnectionsEnabled() != true) + throw new RuntimeException("performer.isAddDefaultConnectionsEnabled() didn't return true!"); + performer.setDefaultConnectionsEnabled(false); + if(performer.isDefaultConnectionsEnabled() != false) + throw new RuntimeException("performer.isAddDefaultConnectionsEnabled() didn't return false!"); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetExclusiveClass.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetExclusiveClass.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelPerformer setExclusiveClass method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetExclusiveClass { + + public static void main(String[] args) throws Exception { + ModelPerformer performer = new ModelPerformer(); + performer.setExclusiveClass(10); + if(performer.getExclusiveClass() != 10) + throw new RuntimeException("performer.getExclusiveClass() didn't return 10!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetKeyFrom.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetKeyFrom.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelPerformer setKeyFrom method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetKeyFrom { + + public static void main(String[] args) throws Exception { + ModelPerformer performer = new ModelPerformer(); + performer.setKeyFrom(10); + if(performer.getKeyFrom() != 10) + throw new RuntimeException("performer.getKeyFrom() didn't return 10!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetKeyTo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetKeyTo.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelPerformer setKeyTo method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetKeyTo { + + public static void main(String[] args) throws Exception { + ModelPerformer performer = new ModelPerformer(); + performer.setKeyTo(10); + if(performer.getKeyTo() != 10) + throw new RuntimeException("performer.getKeyTo() didn't return 10!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetName.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetName.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelPerformer setName method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetName { + + public static void main(String[] args) throws Exception { + ModelPerformer performer = new ModelPerformer(); + performer.setName("hello"); + if(!performer.getName().equals("hello")) + throw new RuntimeException("performer.getName() didn't return \"hello\"!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetSelfNonExclusive.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetSelfNonExclusive.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,48 @@ +/* + * 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 ModelPerformer setSelfNonExclusive method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetSelfNonExclusive { + + public static void main(String[] args) throws Exception { + ModelPerformer performer = new ModelPerformer(); + performer.setSelfNonExclusive(true); + if(performer.isSelfNonExclusive() != true) + throw new RuntimeException("performer.isSelfNonExclusive() didn't return true!"); + performer.setSelfNonExclusive(false); + if(performer.isSelfNonExclusive() != false) + throw new RuntimeException("performer.isSelfNonExclusive() didn't return false!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetVelFrom.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetVelFrom.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelPerformer setVelFrom method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetVelFrom { + + public static void main(String[] args) throws Exception { + ModelPerformer performer = new ModelPerformer(); + performer.setVelFrom(10); + if(performer.getVelFrom() != 10) + throw new RuntimeException("performer.getVelFrom() didn't return 10!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetVelTo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelPerformer/SetVelTo.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelPerformer setVelTo method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetVelTo { + + public static void main(String[] args) throws Exception { + ModelPerformer performer = new ModelPerformer(); + performer.setVelTo(10); + if(performer.getVelTo() != 10) + throw new RuntimeException("performer.getVelTo() didn't return 10!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSource.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSource.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,48 @@ +/* + * 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 ModelSource() constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelSource { + + public static void main(String[] args) throws Exception { + ModelSource src = new ModelSource(); + if(src.getIdentifier() != ModelSource.SOURCE_NONE) + throw new RuntimeException("src.getIdentifier() doesn't return ModelSource.SOURCE_NONE!"); + if(!(src.getTransform() instanceof ModelStandardTransform)) + throw new RuntimeException("src.getTransform() doesn't return object which is instance of ModelStandardTransform!"); + + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSourceModelIdentifier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSourceModelIdentifier.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,46 @@ +/* + * 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 ModelSource(ModelIdentifier) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelSourceModelIdentifier { + + public static void main(String[] args) throws Exception { + ModelSource src = new ModelSource(ModelSource.SOURCE_NOTEON_KEYNUMBER); + if(src.getIdentifier() != ModelSource.SOURCE_NOTEON_KEYNUMBER) + throw new RuntimeException("src.getIdentifier() doesn't return ModelSource.SOURCE_NOTEON_KEYNUMBER!"); + if(!(src.getTransform() instanceof ModelStandardTransform)) + throw new RuntimeException("src.getTransform() doesn't return object which is instance of ModelStandardTransform!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSourceModelIdentifierBoolean.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSourceModelIdentifierBoolean.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,49 @@ +/* + * 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 ModelSource(ModelIdentifier,boolean) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelSourceModelIdentifierBoolean { + + public static void main(String[] args) throws Exception { + ModelSource src = new ModelSource(ModelSource.SOURCE_NOTEON_KEYNUMBER,ModelStandardTransform.DIRECTION_MAX2MIN); + if(src.getIdentifier() != ModelSource.SOURCE_NOTEON_KEYNUMBER) + throw new RuntimeException("src.getIdentifier() doesn't return ModelSource.SOURCE_NOTEON_KEYNUMBER!"); + if(!(src.getTransform() instanceof ModelStandardTransform)) + throw new RuntimeException("src.getTransform() doesn't return object which is instance of ModelStandardTransform!"); + ModelStandardTransform trans = (ModelStandardTransform)src.getTransform(); + if(trans.getDirection() != ModelStandardTransform.DIRECTION_MAX2MIN) + throw new RuntimeException("trans.getDirection() doesn't return ModelStandardTransform.DIRECTION_MAX2MIN!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSourceModelIdentifierBooleanBoolean.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSourceModelIdentifierBooleanBoolean.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,51 @@ +/* + * 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 ModelSource(ModelIdentifier,boolean,boolean) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelSourceModelIdentifierBooleanBoolean { + + public static void main(String[] args) throws Exception { + ModelSource src = new ModelSource(ModelSource.SOURCE_NOTEON_KEYNUMBER,ModelStandardTransform.DIRECTION_MAX2MIN,ModelStandardTransform.POLARITY_BIPOLAR); + if(src.getIdentifier() != ModelSource.SOURCE_NOTEON_KEYNUMBER) + throw new RuntimeException("src.getIdentifier() doesn't return ModelSource.SOURCE_NOTEON_KEYNUMBER!"); + if(!(src.getTransform() instanceof ModelStandardTransform)) + throw new RuntimeException("src.getTransform() doesn't return object which is instance of ModelStandardTransform!"); + ModelStandardTransform trans = (ModelStandardTransform)src.getTransform(); + if(trans.getDirection() != ModelStandardTransform.DIRECTION_MAX2MIN) + throw new RuntimeException("trans.getDirection() doesn't return ModelStandardTransform.DIRECTION_MAX2MIN!"); + if(trans.getPolarity() != ModelStandardTransform.POLARITY_BIPOLAR) + throw new RuntimeException("trans.getPolarity() doesn't return ModelStandardTransform.POLARITY_BIPOLAR!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSourceModelIdentifierBooleanBooleanInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSourceModelIdentifierBooleanBooleanInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,56 @@ +/* + * 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 ModelSource(ModelIdentifier,boolean,boolean,int) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelSourceModelIdentifierBooleanBooleanInt { + + public static void main(String[] args) throws Exception { + ModelSource src = new ModelSource(ModelSource.SOURCE_NOTEON_KEYNUMBER, + ModelStandardTransform.DIRECTION_MAX2MIN, + ModelStandardTransform.POLARITY_BIPOLAR, + ModelStandardTransform.TRANSFORM_CONCAVE); + if(src.getIdentifier() != ModelSource.SOURCE_NOTEON_KEYNUMBER) + throw new RuntimeException("src.getIdentifier() doesn't return ModelSource.SOURCE_NOTEON_KEYNUMBER!"); + if(!(src.getTransform() instanceof ModelStandardTransform)) + throw new RuntimeException("src.getTransform() doesn't return object which is instance of ModelStandardTransform!"); + ModelStandardTransform trans = (ModelStandardTransform)src.getTransform(); + if(trans.getDirection() != ModelStandardTransform.DIRECTION_MAX2MIN) + throw new RuntimeException("trans.getDirection() doesn't return ModelStandardTransform.DIRECTION_MAX2MIN!"); + if(trans.getPolarity() != ModelStandardTransform.POLARITY_BIPOLAR) + throw new RuntimeException("trans.getPolarity() doesn't return ModelStandardTransform.POLARITY_BIPOLAR!"); + if(trans.getTransform() != ModelStandardTransform.TRANSFORM_CONCAVE) + throw new RuntimeException("trans.getTransform() doesn't return ModelStandardTransform.TRANSFORM_CONCAVE!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSourceModelIdentifierModelTransform.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/NewModelSourceModelIdentifierModelTransform.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,47 @@ +/* + * 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 ModelSource(ModelIdentifier,ModelTransform) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelSourceModelIdentifierModelTransform { + + public static void main(String[] args) throws Exception { + ModelStandardTransform trans = new ModelStandardTransform(); + ModelSource src = new ModelSource(ModelSource.SOURCE_NOTEON_KEYNUMBER, trans); + if(src.getIdentifier() != ModelSource.SOURCE_NOTEON_KEYNUMBER) + throw new RuntimeException("src.getIdentifier() doesn't return ModelSource.SOURCE_NOTEON_KEYNUMBER!"); + if(src.getTransform() != trans) + throw new RuntimeException("src.getTransform() doesn't return trans!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/SetIdentifier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/SetIdentifier.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelSource setIdentifier method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetIdentifier { + + public static void main(String[] args) throws Exception { + ModelSource src = new ModelSource(); + src.setIdentifier(ModelSource.SOURCE_NOTEON_KEYNUMBER); + if(src.getIdentifier() != ModelSource.SOURCE_NOTEON_KEYNUMBER) + throw new RuntimeException("src.getIdentifier() doesn't return ModelSource.SOURCE_NOTEON_KEYNUMBER!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/SetTransform.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelSource/SetTransform.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,46 @@ +/* + * 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 ModelSource setTransform method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetTransform { + + public static void main(String[] args) throws Exception { + ModelSource src = new ModelSource(); + ModelStandardTransform trans = new ModelStandardTransform(); + src.setTransform(trans); + if(src.getTransform() != trans) + throw new RuntimeException("src.getTransform() doesn't return trans!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/NewModelStandardTransform.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/NewModelStandardTransform.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,48 @@ +/* + * 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 ModelStandardTransform constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelStandardTransform { + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform(); + if(transform.getDirection() != ModelStandardTransform.DIRECTION_MIN2MAX) + throw new RuntimeException("transform.getDirection() doesn't return ModelStandardTransform.DIRECTION_MIN2MAX!"); + if(transform.getPolarity() != ModelStandardTransform.POLARITY_UNIPOLAR) + throw new RuntimeException("transform.getPolarity() doesn't return ModelStandardTransform.POLARITY_UNIPOLAR!"); + if(transform.getTransform() != ModelStandardTransform.TRANSFORM_LINEAR) + throw new RuntimeException("transform.getTransform() doesn't return ModelStandardTransform.TRANSFORM_LINEAR!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/NewModelStandardTransformBoolean.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/NewModelStandardTransformBoolean.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,48 @@ +/* + * 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 ModelStandardTransform(boolean) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelStandardTransformBoolean { + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform(ModelStandardTransform.DIRECTION_MAX2MIN); + if(transform.getDirection() != ModelStandardTransform.DIRECTION_MAX2MIN) + throw new RuntimeException("transform.getDirection() doesn't return ModelStandardTransform.DIRECTION_MAX2MIN!"); + if(transform.getPolarity() != ModelStandardTransform.POLARITY_UNIPOLAR) + throw new RuntimeException("transform.getPolarity() doesn't return ModelStandardTransform.POLARITY_UNIPOLAR!"); + if(transform.getTransform() != ModelStandardTransform.TRANSFORM_LINEAR) + throw new RuntimeException("transform.getTransform() doesn't return ModelStandardTransform.TRANSFORM_LINEAR!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/NewModelStandardTransformBooleanBoolean.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/NewModelStandardTransformBooleanBoolean.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,50 @@ +/* + * 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 ModelStandardTransform(boolean,boolean) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelStandardTransformBooleanBoolean { + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform( + ModelStandardTransform.DIRECTION_MAX2MIN, + ModelStandardTransform.POLARITY_BIPOLAR); + if(transform.getDirection() != ModelStandardTransform.DIRECTION_MAX2MIN) + throw new RuntimeException("transform.getDirection() doesn't return ModelStandardTransform.DIRECTION_MAX2MIN!"); + if(transform.getPolarity() != ModelStandardTransform.POLARITY_BIPOLAR) + throw new RuntimeException("transform.getPolarity() doesn't return ModelStandardTransform.POLARITY_BIPOLAR!"); + if(transform.getTransform() != ModelStandardTransform.TRANSFORM_LINEAR) + throw new RuntimeException("transform.getTransform() doesn't return ModelStandardTransform.TRANSFORM_LINEAR!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/NewModelStandardTransformBooleanBooleanInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/NewModelStandardTransformBooleanBooleanInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,51 @@ +/* + * 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 ModelStandardTransform(boolean,boolean,int) constructor */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewModelStandardTransformBooleanBooleanInt { + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform( + ModelStandardTransform.DIRECTION_MAX2MIN, + ModelStandardTransform.POLARITY_BIPOLAR, + ModelStandardTransform.TRANSFORM_CONVEX); + if(transform.getDirection() != ModelStandardTransform.DIRECTION_MAX2MIN) + throw new RuntimeException("transform.getDirection() doesn't return ModelStandardTransform.DIRECTION_MAX2MIN!"); + if(transform.getPolarity() != ModelStandardTransform.POLARITY_BIPOLAR) + throw new RuntimeException("transform.getPolarity() doesn't return ModelStandardTransform.POLARITY_BIPOLAR!"); + if(transform.getTransform() != ModelStandardTransform.TRANSFORM_CONVEX) + throw new RuntimeException("transform.getTransform() doesn't return ModelStandardTransform.TRANSFORM_CONVEX!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/SetDirection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/SetDirection.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelStandardTransform setDirection method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetDirection { + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform(); + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + if(transform.getDirection() != ModelStandardTransform.DIRECTION_MAX2MIN) + throw new RuntimeException("transform.getDirection() doesn't return ModelStandardTransform.DIRECTION_MAX2MIN!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/SetPolarity.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/SetPolarity.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,45 @@ +/* + * 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 ModelStandardTransform setPolarity method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetPolarity { + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform(); + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + if(transform.getPolarity() != ModelStandardTransform.POLARITY_BIPOLAR) + throw new RuntimeException("transform.getPolarity() doesn't return ModelStandardTransform.POLARITY_BIPOLAR!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/SetTransform.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/SetTransform.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,74 @@ +/* + * 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 ModelStandardTransform setTransform method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetTransform { + + + private static boolean checkLinearity(ModelStandardTransform transform) + { + double lastx = 0; + for (int p = 0; p < 2; p++) + for (int d = 0; d < 2; d++) + for (double i = 0; i < 1.0; i+=0.001) { + if(p == 0) + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + else + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + if(d == 0) + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + else + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + double x = transform.transform(i); + if(i == 0) + lastx = x; + else + { + if(lastx - x > 0.2) return false; + lastx = x; + } + } + return true; + } + + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform(); + transform.setTransform(ModelStandardTransform.TRANSFORM_CONVEX); + if(transform.getTransform() != ModelStandardTransform.TRANSFORM_CONVEX) + throw new RuntimeException("transform.getTransform() doesn't return ModelStandardTransform.TRANSFORM_CONVEX!"); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/TransformAbsolute.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/TransformAbsolute.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,73 @@ +/* + * 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 ModelStandardTransform transform method */ + +import com.sun.media.sound.ModelStandardTransform; + +public class TransformAbsolute { + + private static boolean checkLinearity(ModelStandardTransform transform) + { + double lastx = 0; + for (int p = 0; p < 2; p++) + for (int d = 0; d < 2; d++) + for (double i = 0; i < 1.0; i+=0.001) { + if(p == 0) + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + else + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + if(d == 0) + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + else + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + double x = transform.transform(i); + if(i == 0) + lastx = x; + else + { + if(lastx - x > 0.2) return false; + lastx = x; + } + } + return true; + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + + } + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform(); + transform.setTransform(ModelStandardTransform.TRANSFORM_ABSOLUTE); + assertTrue(Math.abs(transform.transform(0.2f) - 0.2f) < 0.0001f); + assertTrue(Math.abs(transform.transform(-0.8f) - 0.8f) < 0.0001f); + assertTrue(checkLinearity(transform)); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/TransformConcave.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/TransformConcave.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,98 @@ +/* + * 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 ModelStandardTransform transform method */ + +import com.sun.media.sound.ModelStandardTransform; + +public class TransformConcave { + + private static boolean checkLinearity(ModelStandardTransform transform) + { + double lastx = 0; + for (int p = 0; p < 2; p++) + for (int d = 0; d < 2; d++) + for (double i = 0; i < 1.0; i+=0.001) { + if(p == 0) + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + else + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + if(d == 0) + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + else + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + double x = transform.transform(i); + if(i == 0) + lastx = x; + else + { + if(lastx - x > 0.2) return false; + lastx = x; + } + } + return true; + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform(); + transform.setTransform(ModelStandardTransform.TRANSFORM_CONCAVE); + assertTrue(checkLinearity(transform)); + + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + assertTrue(Math.abs(transform.transform(0.0f) - 0.0f) < 0.0001f); + assertTrue(transform.transform(0.5f) < 0.5f); + assertTrue(Math.abs(transform.transform(1.0f) - 1.0f) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + assertTrue(Math.abs(transform.transform(1.0f) - 0.0f) < 0.0001f); + assertTrue(transform.transform(0.5f) < 0.5f); + assertTrue(Math.abs(transform.transform(0.0f) - 1.0f) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + assertTrue(Math.abs(transform.transform(0.0f) + 1.0f) < 0.0001f); + assertTrue(transform.transform(0.25f) > -0.5f); + assertTrue(Math.abs(transform.transform(0.5f) - 0.0f) < 0.0001f); + assertTrue(transform.transform(0.75f) < 0.5f); + assertTrue(Math.abs(transform.transform(1.0f) - 1.0f) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + assertTrue(Math.abs(transform.transform(1.0f) + 1.0f) < 0.0001f); + assertTrue(transform.transform(0.75f) > -0.5f); + assertTrue(Math.abs(transform.transform(0.50f) - 0.0f) < 0.0001f); + assertTrue(transform.transform(0.25f) < 0.5f); + assertTrue(Math.abs(transform.transform(0.0f) - 1.0f) < 0.0001f); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/TransformConvex.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/TransformConvex.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,98 @@ +/* + * 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 ModelStandardTransform transform method */ + +import com.sun.media.sound.ModelStandardTransform; + +public class TransformConvex { + + private static boolean checkLinearity(ModelStandardTransform transform) + { + double lastx = 0; + for (int p = 0; p < 2; p++) + for (int d = 0; d < 2; d++) + for (double i = 0; i < 1.0; i+=0.001) { + if(p == 0) + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + else + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + if(d == 0) + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + else + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + double x = transform.transform(i); + if(i == 0) + lastx = x; + else + { + if(lastx - x > 0.2) return false; + lastx = x; + } + } + return true; + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform(); + transform.setTransform(ModelStandardTransform.TRANSFORM_CONVEX); + assertTrue(checkLinearity(transform)); + + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + assertTrue(Math.abs(transform.transform(0.0f) - 0.0f) < 0.0001f); + assertTrue(transform.transform(0.5f) > 0.5f); + assertTrue(Math.abs(transform.transform(1.0f) - 1.0f) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + assertTrue(Math.abs(transform.transform(1.0f) - 0.0f) < 0.0001f); + assertTrue(transform.transform(0.5f) > 0.5f); + assertTrue(Math.abs(transform.transform(0.0f) - 1.0f) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + assertTrue(Math.abs(transform.transform(0.0f) + 1.0f) < 0.0001f); + assertTrue(transform.transform(0.25f) < -0.5f); + assertTrue(Math.abs(transform.transform(0.5f) - 0.0f) < 0.0001f); + assertTrue(transform.transform(0.75f) > 0.5f); + assertTrue(Math.abs(transform.transform(1.0f) - 1.0f) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + assertTrue(Math.abs(transform.transform(1.0f) + 1.0f) < 0.0001f); + assertTrue(transform.transform(0.75f) < -0.5f); + assertTrue(Math.abs(transform.transform(0.50f) - 0.0f) < 0.0001f); + assertTrue(transform.transform(0.25f) > 0.5f); + assertTrue(Math.abs(transform.transform(0.0f) - 1.0f) < 0.0001f); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/TransformLinear.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/TransformLinear.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,90 @@ +/* + * 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 ModelStandardTransform transform method */ + +import com.sun.media.sound.ModelStandardTransform; + +public class TransformLinear { + + private static boolean checkLinearity(ModelStandardTransform transform) + { + double lastx = 0; + for (int p = 0; p < 2; p++) + for (int d = 0; d < 2; d++) + for (double i = 0; i < 1.0; i+=0.001) { + if(p == 0) + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + else + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + if(d == 0) + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + else + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + double x = transform.transform(i); + if(i == 0) + lastx = x; + else + { + if(lastx - x > 0.2) return false; + lastx = x; + } + } + return true; + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform(); + transform.setTransform(ModelStandardTransform.TRANSFORM_LINEAR); + assertTrue(checkLinearity(transform)); + + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + assertTrue(Math.abs(transform.transform(0.2f) - 0.2f) < 0.0001f); + assertTrue(Math.abs(transform.transform(0.8f) - 0.8f) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + assertTrue(Math.abs(transform.transform(0.2f) - 0.8f) < 0.0001f); + assertTrue(Math.abs(transform.transform(0.8f) - 0.2f) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + assertTrue(Math.abs(transform.transform(0.2f) - (-0.6f)) < 0.0001f); + assertTrue(Math.abs(transform.transform(0.8f) - (0.6f)) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + assertTrue(Math.abs(transform.transform(0.2f) - (0.6f)) < 0.0001f); + assertTrue(Math.abs(transform.transform(0.8f) - (-0.6f)) < 0.0001f); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/TransformSwitch.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/ModelStandardTransform/TransformSwitch.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,63 @@ +/* + * 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 ModelStandardTransform transform method */ + +import com.sun.media.sound.ModelStandardTransform; + +public class TransformSwitch { + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + ModelStandardTransform transform = new ModelStandardTransform(); + transform.setTransform(ModelStandardTransform.TRANSFORM_SWITCH); + + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + assertTrue(Math.abs(transform.transform(0.2f) - 0.0f) < 0.0001f); + assertTrue(Math.abs(transform.transform(0.8f) - 1.0f) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + transform.setPolarity(ModelStandardTransform.POLARITY_UNIPOLAR); + assertTrue(Math.abs(transform.transform(0.2f) - 1.0f) < 0.0001f); + assertTrue(Math.abs(transform.transform(0.8f) - 0.0f) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MIN2MAX); + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + assertTrue(Math.abs(transform.transform(0.2f) + 1.0f) < 0.0001f); + assertTrue(Math.abs(transform.transform(0.8f) - 1.0f) < 0.0001f); + + transform.setDirection(ModelStandardTransform.DIRECTION_MAX2MIN); + transform.setPolarity(ModelStandardTransform.POLARITY_BIPOLAR); + assertTrue(Math.abs(transform.transform(0.2f) - 1.0f) < 0.0001f); + assertTrue(Math.abs(transform.transform(0.8f) + 1.0f) < 0.0001f); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/Available.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/Available.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,78 @@ +/* + * 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 RiffReader available method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Available { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeByte(10); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + RIFFReader readchunk = reader.nextChunk(); + int avail = readchunk.available(); + readchunk.readByte(); + assertEquals(avail - 1,readchunk.available()); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/Close.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/Close.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,72 @@ +/* + * 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 RiffReader close method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Close { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + reader.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/GetFilePointer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/GetFilePointer.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,78 @@ +/* + * 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 RiffReader getFilePointer method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetFilePointer { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeByte(10); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + RIFFReader readchunk = reader.nextChunk(); + long p = readchunk.getFilePointer(); + readchunk.readByte(); + assertEquals(p+1,readchunk.getFilePointer()); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/GetSize.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/GetSize.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,77 @@ +/* + * 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 RiffReader getSize method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetSize { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeByte(10); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getSize(), (long)readchunk.available()); + readchunk.readByte(); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/HasNextChunk.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/HasNextChunk.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,85 @@ +/* + * 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 RiffReader hasNextChunk method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class HasNextChunk { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean a) throws Exception + { + if(!a) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeByte(10); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + assertTrue(reader.hasNextChunk()); + RIFFReader readchunk = reader.nextChunk(); + readchunk.readByte(); + readchunk.close(); + assertTrue(!reader.hasNextChunk()); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/Read.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/Read.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,79 @@ +/* + * 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 RiffReader read method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Read { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.write((byte)33); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + assertEquals(reader.getFormat(), "RIFF"); + assertEquals(reader.getType(), "TEST"); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getFormat(), "TSCH"); + assertEquals(readchunk.read(), 33); + fis.close(); + reader = null; + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadByte.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadByte.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,79 @@ +/* + * 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 RiffReader read(byte) method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ReadByte { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeByte((byte)33); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + assertEquals(reader.getFormat(), "RIFF"); + assertEquals(reader.getType(), "TEST"); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getFormat(), "TSCH"); + assertEquals((int)reader.readByte(), 33); + fis.close(); + reader = null; + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadByteArrayIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadByteArrayIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,81 @@ +/* + * 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 RiffReader read(byte[], int, int) method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ReadByteArrayIntInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.write(new byte[] {1,2,3}); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + assertEquals(reader.getFormat(), "RIFF"); + assertEquals(reader.getType(), "TEST"); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getFormat(), "TSCH"); + assertEquals(readchunk.read(), 1); + assertEquals(readchunk.read(), 2); + assertEquals(readchunk.read(), 3); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,79 @@ +/* + * 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 RiffReader readInt method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ReadInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeInt(133); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + assertEquals(reader.getFormat(), "RIFF"); + assertEquals(reader.getType(), "TEST"); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getFormat(), "TSCH"); + assertEquals(reader.readInt(), 133); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadLong.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadLong.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,79 @@ +/* + * 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 RiffReader readLong method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ReadLong { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeLong(133L); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + assertEquals(reader.getFormat(), "RIFF"); + assertEquals(reader.getType(), "TEST"); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getFormat(), "TSCH"); + assertEquals(reader.readLong(), 133L); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadShort.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadShort.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,79 @@ +/* + * 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 RiffReader readShort method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ReadShort { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeShort((short)133); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + assertEquals(reader.getFormat(), "RIFF"); + assertEquals(reader.getType(), "TEST"); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getFormat(), "TSCH"); + assertEquals(reader.readShort(), (short)133); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadString.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadString.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,79 @@ +/* + * 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 RiffReader readString method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ReadString { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeString("HELLO",5); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + assertEquals(reader.getFormat(), "RIFF"); + assertEquals(reader.getType(), "TEST"); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getFormat(), "TSCH"); + assertEquals(reader.readString(5), "HELLO"); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadUnsignedByte.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadUnsignedByte.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,79 @@ +/* + * 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 RiffReader readUnsignedByte method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ReadUnsignedByte { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeUnsignedByte(77); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + assertEquals(reader.getFormat(), "RIFF"); + assertEquals(reader.getType(), "TEST"); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getFormat(), "TSCH"); + assertEquals(reader.readUnsignedByte(), 77); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadUnsignedInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadUnsignedInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,79 @@ +/* + * 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 RiffReader readUnsignedInt method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ReadUnsignedInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeUnsignedInt(55377); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + assertEquals(reader.getFormat(), "RIFF"); + assertEquals(reader.getType(), "TEST"); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getFormat(), "TSCH"); + assertEquals(reader.readUnsignedInt(), 55377L); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadUnsignedShort.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/ReadUnsignedShort.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,79 @@ +/* + * 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 RiffReader readUnsignedShort method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ReadUnsignedShort { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.writeUnsignedShort(377); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + assertEquals(reader.getFormat(), "RIFF"); + assertEquals(reader.getType(), "TEST"); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getFormat(), "TSCH"); + assertEquals(reader.readUnsignedShort(), 377); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/Skip.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/Skip.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,78 @@ +/* + * 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 RiffReader skip method */ + +import java.io.File; +import java.io.FileInputStream; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Skip { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + writer = new RIFFWriter(tempfile, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.write((byte)33); + chunk.write((byte)44); + writer.close(); + writer = null; + FileInputStream fis = new FileInputStream(tempfile); + reader = new RIFFReader(fis); + RIFFReader readchunk = reader.nextChunk(); + reader.skip(1); + assertEquals(readchunk.read(), 44); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/WriteOutputStream.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/RiffReaderWriter/WriteOutputStream.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,81 @@ +/* + * 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 RiffWriter(OutputStream) constructor */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class WriteOutputStream { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + RIFFWriter writer = null; + RIFFReader reader = null; + File tempfile = File.createTempFile("test",".riff"); + try + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + writer = new RIFFWriter(baos, "TEST"); + RIFFWriter chunk = writer.writeChunk("TSCH"); + chunk.write((byte)33); + writer.close(); + writer = null; + ByteArrayInputStream fis = new ByteArrayInputStream(baos.toByteArray()); + reader = new RIFFReader(fis); + assertEquals(reader.getFormat(), "RIFF"); + assertEquals(reader.getType(), "TEST"); + RIFFReader readchunk = reader.nextChunk(); + assertEquals(readchunk.getFormat(), "TSCH"); + assertEquals(readchunk.read(), 33); + fis.close(); + reader = null; + + + } + finally + { + if(writer != null) + writer.close(); + if(reader != null) + reader.close(); + + if(tempfile.exists()) + if(!tempfile.delete()) + tempfile.deleteOnExit(); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelInstrument.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelInstrument.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,86 @@ +/* + * 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 SimpleInstrument add(ModelInstrument) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelInstrument { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + SimpleInstrument subins = new SimpleInstrument(); + subins.add(performers[0]); + instrument.add(subins); + instrument.add(performers[1]); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(performers[i].getExclusiveClass(), performers2[i].getExclusiveClass()); + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelInstrumentIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelInstrumentIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,91 @@ +/* + * 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 SimpleInstrument add(ModelInstrument,int,int) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelInstrumentIntInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + SimpleInstrument subins = new SimpleInstrument(); + subins.add(performers[0]); + instrument.add(subins, 18, 40); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(performers[i].getExclusiveClass(), performers2[i].getExclusiveClass()); + if(performers[i].getKeyFrom() < 18) + assertEquals(18, performers2[i].getKeyFrom()); + else + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + if(performers[i].getKeyTo() > 40) + assertEquals(40, performers2[i].getKeyTo()); + else + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelInstrumentIntIntIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelInstrumentIntIntIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,97 @@ +/* + * 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 SimpleInstrument add(ModelInstrument,int,int,int,int) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelInstrumentIntIntIntInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + SimpleInstrument subins = new SimpleInstrument(); + subins.add(performers[0]); + instrument.add(subins,18,40,20,75); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(performers[i].getExclusiveClass(), performers2[i].getExclusiveClass()); + if(performers[i].getKeyFrom() < 18) + assertEquals(18, performers2[i].getKeyFrom()); + else + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + if(performers[i].getKeyTo() > 40) + assertEquals(40, performers2[i].getKeyTo()); + else + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + if(performers[i].getVelFrom() < 20) + assertEquals(20, performers2[i].getVelFrom()); + else + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + if(performers[i].getVelTo() > 75) + assertEquals(75, performers2[i].getVelTo()); + else + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelInstrumentIntIntIntIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelInstrumentIntIntIntIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,97 @@ +/* + * 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 SimpleInstrument add(ModelInstrument,int,int,int,int,int) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelInstrumentIntIntIntIntInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + SimpleInstrument subins = new SimpleInstrument(); + subins.add(performers[0]); + instrument.add(subins,18,40,20,75,12); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(12, performers2[i].getExclusiveClass()); + if(performers[i].getKeyFrom() < 18) + assertEquals(18, performers2[i].getKeyFrom()); + else + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + if(performers[i].getKeyTo() > 40) + assertEquals(40, performers2[i].getKeyTo()); + else + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + if(performers[i].getVelFrom() < 20) + assertEquals(20, performers2[i].getVelFrom()); + else + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + if(performers[i].getVelTo() > 75) + assertEquals(75, performers2[i].getVelTo()); + else + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformer.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,83 @@ +/* + * 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 SimpleInstrument add(ModelPerformer) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelPerformer { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + instrument.add(performers[0]); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(performers[i].getExclusiveClass(), performers2[i].getExclusiveClass()); + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerArray.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerArray.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,83 @@ +/* + * 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 SimpleInstrument add(ModelPerformer[]) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelPerformerArray { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + instrument.add(performers); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(performers[i].getExclusiveClass(), performers2[i].getExclusiveClass()); + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerArrayIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerArrayIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,89 @@ +/* + * 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 SimpleInstrument add(ModelPerformer[],int,int) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelPerformerArrayIntInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + instrument.add(performers,18,40); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(performers[i].getExclusiveClass(), performers2[i].getExclusiveClass()); + if(performers[i].getKeyFrom() < 18) + assertEquals(18, performers2[i].getKeyFrom()); + else + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + if(performers[i].getKeyTo() > 40) + assertEquals(40, performers2[i].getKeyTo()); + else + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerArrayIntIntIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerArrayIntIntIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,95 @@ +/* + * 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 SimpleInstrument add(ModelPerformer[],int,int,int,int) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelPerformerArrayIntIntIntInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + instrument.add(performers,18,40,20,75); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(performers[i].getExclusiveClass(), performers2[i].getExclusiveClass()); + if(performers[i].getKeyFrom() < 18) + assertEquals(18, performers2[i].getKeyFrom()); + else + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + if(performers[i].getKeyTo() > 40) + assertEquals(40, performers2[i].getKeyTo()); + else + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + if(performers[i].getVelFrom() < 20) + assertEquals(20, performers2[i].getVelFrom()); + else + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + if(performers[i].getVelTo() > 75) + assertEquals(75, performers2[i].getVelTo()); + else + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerArrayIntIntIntIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerArrayIntIntIntIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,95 @@ +/* + * 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 SimpleInstrument add(ModelPerformer[],int,int,int,int,int) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelPerformerArrayIntIntIntIntInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + instrument.add(performers,18,40,20,75,12); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(12, performers2[i].getExclusiveClass()); + if(performers[i].getKeyFrom() < 18) + assertEquals(18, performers2[i].getKeyFrom()); + else + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + if(performers[i].getKeyTo() > 40) + assertEquals(40, performers2[i].getKeyTo()); + else + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + if(performers[i].getVelFrom() < 20) + assertEquals(20, performers2[i].getVelFrom()); + else + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + if(performers[i].getVelTo() > 75) + assertEquals(75, performers2[i].getVelTo()); + else + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,89 @@ +/* + * 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 SimpleInstrument add(ModelPerformer,int,int) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelPerformerIntInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + instrument.add(performers[0],18,40); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(performers[i].getExclusiveClass(), performers2[i].getExclusiveClass()); + if(performers[i].getKeyFrom() < 18) + assertEquals(18, performers2[i].getKeyFrom()); + else + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + if(performers[i].getKeyTo() > 40) + assertEquals(40, performers2[i].getKeyTo()); + else + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerIntIntIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerIntIntIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,95 @@ +/* + * 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 SimpleInstrument add(ModelPerformer,int,int,int,int) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelPerformerIntIntIntInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + instrument.add(performers[0],18,40,20,75); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(performers[i].getExclusiveClass(), performers2[i].getExclusiveClass()); + if(performers[i].getKeyFrom() < 18) + assertEquals(18, performers2[i].getKeyFrom()); + else + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + if(performers[i].getKeyTo() > 40) + assertEquals(40, performers2[i].getKeyTo()); + else + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + if(performers[i].getVelFrom() < 20) + assertEquals(20, performers2[i].getVelFrom()); + else + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + if(performers[i].getVelTo() > 75) + assertEquals(75, performers2[i].getVelTo()); + else + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerIntIntIntIntInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/AddModelPerformerIntIntIntIntInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,95 @@ +/* + * 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 SimpleInstrument add(ModelPerformer,int,int,int,int,int) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddModelPerformerIntIntIntIntInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + instrument.add(performers[0],18,40,20,75,12); + ModelPerformer[] performers2 = instrument.getPerformers(); + for (int i = 0; i < performers2.length; i++) { + assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks()); + assertEquals(12, performers2[i].getExclusiveClass()); + if(performers[i].getKeyFrom() < 18) + assertEquals(18, performers2[i].getKeyFrom()); + else + assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom()); + if(performers[i].getKeyTo() > 40) + assertEquals(40, performers2[i].getKeyTo()); + else + assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo()); + if(performers[i].getVelFrom() < 20) + assertEquals(20, performers2[i].getVelFrom()); + else + assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom()); + if(performers[i].getVelTo() > 75) + assertEquals(75, performers2[i].getVelTo()); + else + assertEquals(performers[i].getVelTo(), performers2[i].getVelTo()); + assertEquals(performers[i].getOscillators(), performers2[i].getOscillators()); + assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive()); + assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled()); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/Clear.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/Clear.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,73 @@ +/* + * 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 SimpleInstrument clear method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Clear { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + instrument.add(performers[0]); + instrument.clear(); + assertEquals(instrument.getPerformers().length, 0); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/SetName.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/SetName.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,72 @@ +/* + * 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 SimpleInstrument setName(String) method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetName { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + instrument.setName("hello"); + assertEquals(instrument.getName(), "hello"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/SetPatch.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleInstrument/SetPatch.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,75 @@ +/* + * 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 SimpleInstrument setPatch(Patch) method */ + +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetPatch { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + + SimpleInstrument instrument = new SimpleInstrument(); + + ModelPerformer[] performers = new ModelPerformer[2]; + + performers[0] = new ModelPerformer(); + performers[0].setExclusiveClass(1); + performers[0].setKeyFrom(36); + performers[0].setKeyTo(48); + performers[0].setVelFrom(16); + performers[0].setVelTo(80); + performers[0].setSelfNonExclusive(true); + performers[0].setDefaultConnectionsEnabled(false); + performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + performers[1] = new ModelPerformer(); + performers[1].setExclusiveClass(0); + performers[1].setKeyFrom(12); + performers[1].setKeyTo(24); + performers[1].setVelFrom(20); + performers[1].setVelTo(90); + performers[1].setSelfNonExclusive(false); + performers[0].setDefaultConnectionsEnabled(true); + performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); + performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); + + Patch patch = new Patch(0,36); + instrument.setPatch(patch); + assertEquals(instrument.getPatch().getProgram(), patch.getProgram()); + assertEquals(instrument.getPatch().getBank(), patch.getBank()); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/AddInstrument.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/AddInstrument.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,51 @@ +/* + * 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 SimpleSoundbank addInstrument method */ + +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddInstrument { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + SimpleSoundbank soundbank = new SimpleSoundbank(); + SimpleInstrument ins = new SimpleInstrument(); + ins.setPatch(new Patch(3,7)); + soundbank.addInstrument(ins); + assertEquals(soundbank.getInstruments().length, 1); + assertEquals(soundbank.getInstruments()[0], ins); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/AddResource.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/AddResource.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,52 @@ +/* + * 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 SimpleSoundbank addResource method */ + +import javax.sound.midi.SoundbankResource; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AddResource { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + SimpleSoundbank soundbank = new SimpleSoundbank(); + SoundbankResource res = new SoundbankResource(soundbank, "test", null) { + public Object getData() { + return null; + }}; + soundbank.addResource(res); + assertEquals(soundbank.getResources().length, 1); + assertEquals(soundbank.getResources()[0], res); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/GetInstrument.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/GetInstrument.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,50 @@ +/* + * 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 SimpleSoundbank getInstrument method */ + +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetInstrument { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + SimpleSoundbank soundbank = new SimpleSoundbank(); + SimpleInstrument ins = new SimpleInstrument(); + ins.setPatch(new Patch(3,7)); + soundbank.addInstrument(ins); + assertEquals(soundbank.getInstrument(new Patch(3,7)), ins); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/RemoveInstrument.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/RemoveInstrument.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,58 @@ +/* + * 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 SimpleSoundbank removeInstrument method */ + +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class RemoveInstrument { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean a) throws Exception + { + if(!a) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + SimpleSoundbank soundbank = new SimpleSoundbank(); + SimpleInstrument ins = new SimpleInstrument(); + ins.setPatch(new Patch(3,7)); + soundbank.addInstrument(ins); + soundbank.removeInstrument(ins); + assertEquals(soundbank.getInstruments().length, 0); + assertTrue(soundbank.getInstrument(new Patch(3,7)) == null); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/SetDescription.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/SetDescription.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,47 @@ +/* + * 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 SimpleSoundbank setDescription method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetDescription { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + SimpleSoundbank soundbank = new SimpleSoundbank(); + soundbank.setDescription("hello"); + assertEquals(soundbank.getDescription(), "hello"); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/SetName.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/SetName.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,47 @@ +/* + * 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 SimpleSoundbank setName method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetName { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + SimpleSoundbank soundbank = new SimpleSoundbank(); + soundbank.setName("hello"); + assertEquals(soundbank.getName(), "hello"); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/SetVendor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/SetVendor.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,47 @@ +/* + * 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 SimpleSoundbank setVendor method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetVendor { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + SimpleSoundbank soundbank = new SimpleSoundbank(); + soundbank.setVendor("hello"); + assertEquals(soundbank.getVendor(), "hello"); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/SetVersion.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SimpleSoundbank/SetVersion.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,47 @@ +/* + * 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 SimpleSoundbank setVersion method */ + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SetVersion { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + public static void main(String[] args) throws Exception { + SimpleSoundbank soundbank = new SimpleSoundbank(); + soundbank.setVersion("hello"); + assertEquals(soundbank.getVersion(), "hello"); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioBuffer/Array.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioBuffer/Array.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,54 @@ +/* + * 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 SoftAudioBuffer array method */ + +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Array { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioFormat frm = new AudioFormat(8000, 8, 1, true, false); + SoftAudioBuffer buff = new SoftAudioBuffer(377, frm); + float[] ar = buff.array(); + assertEquals(ar.length, 377); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioBuffer/Clear.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioBuffer/Clear.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,56 @@ +/* + * 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 SoftAudioBuffer clear method */ + +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Clear { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioFormat frm = new AudioFormat(8000, 8, 1, true, false); + SoftAudioBuffer buff = new SoftAudioBuffer(377, frm); + buff.array(); + assertTrue(!buff.isSilent()); + buff.clear(); + assertTrue(buff.isSilent()); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioBuffer/Get.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioBuffer/Get.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,68 @@ +/* + * 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 SoftAudioBuffer get method */ + +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Get { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioFormat frm = new AudioFormat(8000, 16, 1, true, false); + SoftAudioBuffer buff = new SoftAudioBuffer(100, frm); + float[] ar = buff.array(); + for (int i = 0; i < ar.length; i++) { + if(i % 2 == 0) + ar[i] = 1; + if(i % 2 == 0) + ar[i] = -0.5f; + } + + byte[] bbuff = new byte[ar.length*frm.getFrameSize()]; + buff.get(bbuff, 0); + float[] ar2 = new float[ar.length]; + AudioFloatConverter.getConverter(frm).toFloatArray(bbuff, ar2); + + for (int i = 0; i < ar2.length; i++) + if(Math.abs(ar[i] - ar2[i]) > 0.001) + throw new Exception("conversion failure!"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioBuffer/NewSoftAudioBuffer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioBuffer/NewSoftAudioBuffer.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,55 @@ +/* + * 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 SoftAudioBuffer constructor */ + +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewSoftAudioBuffer { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioFormat frm = new AudioFormat(8000, 8, 1, true, false); + SoftAudioBuffer buff = new SoftAudioBuffer(377, frm); + assertEquals(buff.getSize(), 377); + assertEquals(buff.getFormat(), frm); + assertTrue(buff.isSilent()); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioSynthesizer/GetFormat.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioSynthesizer/GetFormat.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,61 @@ +/* + * 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 SoftAudioSynthesizer getFormat method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetFormat { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + AudioFormat defformat = synth.getFormat(); + assertTrue(defformat != null); + synth.openStream(null, null); + assertTrue(synth.getFormat().toString().equals(defformat.toString())); + synth.close(); + AudioFormat custformat = new AudioFormat(8000, 16, 1, true, false); + synth.openStream(custformat, null); + assertTrue(synth.getFormat().toString().equals(custformat.toString())); + synth.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioSynthesizer/GetPropertyInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioSynthesizer/GetPropertyInfo.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,53 @@ +/* + * 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 SoftAudioSynthesizer getPropertyInfo method */ + +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetPropertyInfo { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + AudioSynthesizerPropertyInfo[] info = synth.getPropertyInfo(null); + assertTrue(info != null); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioSynthesizer/Open.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioSynthesizer/Open.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,54 @@ +/* + * 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 SoftAudioSynthesizer open method */ + +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Open { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + SourceDataLine line = AudioSystem.getSourceDataLine(new AudioFormat(44100, 16, 2, true, false)); + synth.open(line, null); + synth.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioSynthesizer/OpenStream.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftAudioSynthesizer/OpenStream.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,54 @@ +/* + * 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 SoftAudioSynthesizer openStream method */ + +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class OpenStream { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + assertTrue(synth.isOpen()); + synth.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/AllNotesOff.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/AllNotesOff.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,64 @@ +/* + * 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 SoftChannel allNotesOff method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AllNotesOff { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.noteOn(60, 64); + soft.read(1); + VoiceStatus[] v = soft.synth.getVoiceStatus(); + assertEquals(v[0].note, 60); + assertEquals(v[0].active, true); + channel.allNotesOff(); + soft.read(1); + v = soft.synth.getVoiceStatus(); + assertEquals(v[0].active, false); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/AllSoundOff.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/AllSoundOff.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,64 @@ +/* + * 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 SoftChannel allSoundOff method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class AllSoundOff { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.noteOn(60, 64); + soft.read(1); + VoiceStatus[] v = soft.synth.getVoiceStatus(); + assertEquals(v[0].note, 60); + assertEquals(v[0].active, true); + channel.allSoundOff(); + soft.read(1); + v = soft.synth.getVoiceStatus(); + assertEquals(v[0].active, false); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/ChannelPressure.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/ChannelPressure.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,59 @@ +/* + * 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 SoftChannel channelPressure method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ChannelPressure { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.setChannelPressure(10); + assertEquals(channel.getChannelPressure(), 10); + channel.setChannelPressure(90); + assertEquals(channel.getChannelPressure(), 90); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/Controller.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/Controller.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,62 @@ +/* + * 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 SoftChannel controller method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Controller { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + for (int i = 0; i < 128; i++) { + if(i == 0 || i == 32) continue; + channel.controlChange(i, 10); + assertEquals(channel.getController(i), 10); + channel.controlChange(i, 100); + assertEquals(channel.getController(i), 100); + } + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/LocalControl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/LocalControl.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,60 @@ +/* + * 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 SoftChannel localControl method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class LocalControl { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + // Local control not supported + // because this is a software synthesizer + // localControl() should always return false + assertEquals(channel.localControl(true), false); + assertEquals(channel.localControl(false), false); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/Mono.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/Mono.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,59 @@ +/* + * 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 SoftChannel mono method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Mono { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.setMono(true); + assertEquals(channel.getMono(), true); + channel.setMono(false); + assertEquals(channel.getMono(), false); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/Mute.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/Mute.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,59 @@ +/* + * 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 SoftChannel mute method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Mute { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.setMute(true); + assertEquals(channel.getMute(), true); + channel.setMute(false); + assertEquals(channel.getMute(), false); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/NoteOff.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/NoteOff.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,64 @@ +/* + * 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 SoftChannel noteOff method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NoteOff { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.noteOn(60, 64); + soft.read(1); + VoiceStatus[] v = soft.synth.getVoiceStatus(); + assertEquals(v[0].note, 60); + assertEquals(v[0].active, true); + channel.noteOff(60); + soft.read(1); + v = soft.synth.getVoiceStatus();; + assertEquals(v[0].active, false); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/NoteOff2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/NoteOff2.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,64 @@ +/* + * 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 SoftChannel noteOff method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NoteOff2 { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.noteOn(60, 64); + soft.read(1); + VoiceStatus[] v = soft.synth.getVoiceStatus(); + assertEquals(v[0].note, 60); + assertEquals(v[0].active, true); + channel.noteOff(60); + soft.read(1); + v = soft.synth.getVoiceStatus();; + assertEquals(v[0].active, false); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/NoteOn.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/NoteOn.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,64 @@ +/* + * 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 SoftChannel noteOn method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NoteOn { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.noteOn(60, 64); + soft.read(1); + VoiceStatus[] v = soft.synth.getVoiceStatus(); + assertEquals(v[0].note, 60); + assertEquals(v[0].active, true); + channel.noteOn(60, 0); + soft.read(1); + v = soft.synth.getVoiceStatus(); + assertEquals(v[0].active, false); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/Omni.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/Omni.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,61 @@ +/* + * 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 SoftChannel omni method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Omni { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.setOmni(true); + // Poly or Omni not supported by GM2 + // getOmni() should always return false + assertEquals(channel.getOmni(), false); + channel.setOmni(false); + assertEquals(channel.getOmni(), false); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/PitchBend.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/PitchBend.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,59 @@ +/* + * 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 SoftChannel pitchBend method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class PitchBend { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.setPitchBend(10); + assertEquals(channel.getPitchBend(), 10); + channel.setPitchBend(9000); + assertEquals(channel.getPitchBend(), 9000); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/PolyPressure.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/PolyPressure.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,61 @@ +/* + * 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 SoftChannel polyPressure method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class PolyPressure { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + for (int i = 0; i < 128; i++) { + channel.setPolyPressure(i, 10); + assertEquals(channel.getPolyPressure(i),10); + channel.setPolyPressure(i, 100); + assertEquals(channel.getPolyPressure(i),100); + } + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/ProgramChange.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/ProgramChange.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,59 @@ +/* + * 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 SoftChannel programChange method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ProgramChange { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.programChange(36); + assertEquals(channel.getProgram(), 36); + channel.programChange(48); + assertEquals(channel.getProgram(), 48); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/ResetAllControllers.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/ResetAllControllers.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,132 @@ +/* + * 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 SoftChannel resetAllControllers method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ResetAllControllers { + + public static boolean[] dontResetControls = new boolean[128]; + static { + for (int i = 0; i < dontResetControls.length; i++) + dontResetControls[i] = false; + + dontResetControls[0] = true; // Bank Select (MSB) + dontResetControls[32] = true; // Bank Select (LSB) + dontResetControls[7] = true; // Channel Volume (MSB) + dontResetControls[8] = true; // Balance (MSB) + dontResetControls[10] = true; // Pan (MSB) + dontResetControls[11] = true; // Expression (MSB) + dontResetControls[91] = true; // Effects 1 Depth (default: Reverb Send) + dontResetControls[92] = true; // Effects 2 Depth (default: Tremolo Depth) + dontResetControls[93] = true; // Effects 3 Depth (default: Chorus Send) + dontResetControls[94] = true; // Effects 4 Depth (default: Celeste [Detune] Depth) + dontResetControls[95] = true; // Effects 5 Depth (default: Phaser Depth) + dontResetControls[70] = true; // Sound Controller 1 (default: Sound Variation) + dontResetControls[71] = true; // Sound Controller 2 (default: Timbre / Harmonic Quality) + dontResetControls[72] = true; // Sound Controller 3 (default: Release Time) + dontResetControls[73] = true; // Sound Controller 4 (default: Attack Time) + dontResetControls[74] = true; // Sound Controller 5 (default: Brightness) + dontResetControls[75] = true; // Sound Controller 6 (GM2 default: Decay Time) + dontResetControls[76] = true; // Sound Controller 7 (GM2 default: Vibrato Rate) + dontResetControls[77] = true; // Sound Controller 8 (GM2 default: Vibrato Depth) + dontResetControls[78] = true; // Sound Controller 9 (GM2 default: Vibrato Delay) + dontResetControls[79] = true; // Sound Controller 10 (GM2 default: Undefined) + dontResetControls[120] = true; // All Sound Off + dontResetControls[121] = true; // Reset All Controllers + dontResetControls[122] = true; // Local Control On/Off + dontResetControls[123] = true; // All Notes Off + dontResetControls[124] = true; // Omni Mode Off + dontResetControls[125] = true; // Omni Mode On + dontResetControls[126] = true; // Poly Mode Off + dontResetControls[127] = true; // Poly Mode On + + dontResetControls[6] = true; // Data Entry (MSB) + dontResetControls[38] = true; // Data Entry (LSB) + dontResetControls[96] = true; // Data Increment + dontResetControls[97] = true; // Data Decrement + dontResetControls[98] = true; // Non-Registered Parameter Number (LSB) + dontResetControls[99] = true; // Non-Registered Parameter Number(MSB) + dontResetControls[100] = true; // RPN = Null + dontResetControls[101] = true; // RPN = Null + } + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + // First let all controls contain non-default values + for (int i = 0; i < 128; i++) + channel.setPolyPressure(i, 10); + channel.setChannelPressure(10); + channel.setPitchBend(2192); + for (int i = 0; i < 120; i++) + channel.controlChange(i, 1); + channel.resetAllControllers(); + + // Now check if resetAllControllers did what it was suppose to do + + for (int i = 0; i < 128; i++) + assertEquals(channel.getPolyPressure(i), 0); + assertEquals(channel.getChannelPressure(), 0); + assertEquals(channel.getPitchBend(),8192); + for (int i = 0; i < 120; i++) + if(!dontResetControls[i]) + assertEquals(channel.getController(i), 0); + assertEquals(channel.getController(71), 64); // Filter Resonance + assertEquals(channel.getController(72), 64); // Release Time + assertEquals(channel.getController(73), 64); // Attack Time + assertEquals(channel.getController(74), 64); // Brightness + assertEquals(channel.getController(75), 64); // Decay Time + assertEquals(channel.getController(76), 64); // Vibrato Rate + assertEquals(channel.getController(77), 64); // Vibrato Depth + assertEquals(channel.getController(78), 64); // Vibrato Delay + assertEquals(channel.getController(8), 64); // Balance + assertEquals(channel.getController(11), 127); // Expression + assertEquals(channel.getController(98), 127); // NRPN Null + assertEquals(channel.getController(99), 127); // NRPN Null + assertEquals(channel.getController(100), 127); // RPN = Null + assertEquals(channel.getController(101), 127); // RPN = Null + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/SoftTestUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/SoftTestUtils.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,111 @@ +/* + * 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. + */ + +import java.io.IOException; + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SoftTestUtils { + + public AudioSynthesizer synth = new SoftSynthesizer(); + public AudioInputStream stream; + public byte[] tmpbuffer = new byte[1024]; + + public static SF2Soundbank createTestSoundBank() + { + SF2Soundbank sf2 = new SF2Soundbank(); + AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + float[] data = new float[44100+1000]; + float fr = 440/format.getSampleRate(); + for (int i = 0; i < data.length; i++) + data[i] = (float)Math.sin(i*fr*2*Math.PI); + byte[] bdata = new byte[data.length*format.getFrameSize()]; + AudioFloatConverter.getConverter(format).toByteArray(data, bdata); + SF2Sample sample = new SF2Sample(sf2); + sample.setName("Test Sample"); + sample.setData(bdata); + sample.setStartLoop(500); + sample.setEndLoop(data.length - 500); + sample.setSampleRate((long) format.getSampleRate()); + sample.setOriginalPitch(69); + sf2.addResource(sample); + SF2Layer layer = new SF2Layer(sf2); + layer.setName("Test Layer"); + sf2.addResource(layer); + SF2LayerRegion region = new SF2LayerRegion(); + region.putInteger(SF2Region.GENERATOR_SAMPLEMODES, 1); + region.setSample(sample); + layer.getRegions().add(region); + SF2Instrument ins = new SF2Instrument(sf2); + ins.setName("Test Instrument"); + sf2.addInstrument(ins); + SF2InstrumentRegion insregion = new SF2InstrumentRegion(); + insregion.setLayer(layer); + ins.getRegions().add(insregion); + + return sf2; + } + + public SoftTestUtils() throws Exception { + stream = synth.openStream(null, null); + synth.unloadAllInstruments(synth.getDefaultSoundbank()); + synth.loadAllInstruments(createTestSoundBank()); + } + + public void close() throws Exception { + stream.close(); + stream = null; + synth.close(); + synth = null; + } + + public void read(double seconds) throws IOException + { + int bufflen = + stream.getFormat().getFrameSize() * + (int)(stream.getFormat().getFrameRate() * seconds); + while(bufflen != 0) + { + if(bufflen > 1024) + bufflen -= stream.read(tmpbuffer,0,1024); + else + bufflen -= stream.read(tmpbuffer,0, bufflen); + } + } + + public VoiceStatus findVoice(int channel, int note) { + VoiceStatus[] v = synth.getVoiceStatus(); + for (int k = 0; k < v.length; k++) + if(v[k].active) + if(v[k].channel == channel) + if(v[k].note == note) + return v[k]; + return null; + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/Solo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftChannel/Solo.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,59 @@ +/* + * 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 SoftChannel solo method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Solo { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + + channel.setSolo(true); + assertEquals(channel.getSolo(), true); + channel.setSolo(false); + assertEquals(channel.getSolo(), false); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftCubicResampler/Interpolate.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftCubicResampler/Interpolate.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,113 @@ +/* + * 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 SoftCubicResampler interpolate method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Interpolate { + + private static float getResamplerTestValue(double i) + { + return (float)Math.sin(i / 10.0); + } + + private static void perfectInterpolation(float[] in_offset, float in_end, + float[] startpitch, float pitchstep, float[] out, int[] out_offset, + int out_end) { + + float pitch = startpitch[0]; + float ix = in_offset[0]; + int ox = out_offset[0]; + float ix_end = in_end; + int ox_end = out_end; + if (pitchstep == 0f) { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + } + } else { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + pitch += pitchstep; + } + } + in_offset[0] = ix; + out_offset[0] = ox; + startpitch[0] = pitch; + + } + + private static float testResampler(SoftAbstractResampler resampler, float p_pitch, float p_pitch2) + { + float[] testbuffer = new float[4096]; + float[] testbuffer2 = new float[1024]; + float[] testbuffer3 = new float[1024]; + for (int i = 0; i < testbuffer.length; i++) + testbuffer[i] = getResamplerTestValue(i); + int pads = resampler.getPadding(); + float pitchstep = (p_pitch2 - p_pitch)/1024f; + int[] out_offset2 = {0}; + int[] out_offset3 = {0}; + resampler.interpolate(testbuffer, new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer2, out_offset2, testbuffer2.length); + perfectInterpolation(new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer3, out_offset3, testbuffer3.length); + int out_off = out_offset2[0]; + if(out_offset3[0] < out_off) + out_off = out_offset3[0]; + float ac_error = 0; + int counter = 0; + for (int i = pads; i < out_off; i++) { + ac_error += Math.abs(testbuffer2[i] - testbuffer3[i]); + counter++; + } + return ac_error / ((float)counter); + } + + private static void fail(String error) throws Exception + { + throw new RuntimeException(error); + } + + public static void main(String[] args) throws Exception { + SoftCubicResampler resampler = new SoftCubicResampler(); + float max = testResampler(resampler, 0.3f, 0.3f); + if(max > 0.005) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 0.3f, 0.01f); + if(max > 0.005) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 1.0f, 0.00f); + if(max > 0.005) + fail("Interpolation failed, error="+max); + } +} \ No newline at end of file diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftLanczosResampler/Interpolate.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftLanczosResampler/Interpolate.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,113 @@ +/* + * 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 SoftLanczosResampler interpolate method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Interpolate { + + private static float getResamplerTestValue(double i) + { + return (float)Math.sin(i / 10.0); + } + + private static void perfectInterpolation(float[] in_offset, float in_end, + float[] startpitch, float pitchstep, float[] out, int[] out_offset, + int out_end) { + + float pitch = startpitch[0]; + float ix = in_offset[0]; + int ox = out_offset[0]; + float ix_end = in_end; + int ox_end = out_end; + if (pitchstep == 0f) { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + } + } else { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + pitch += pitchstep; + } + } + in_offset[0] = ix; + out_offset[0] = ox; + startpitch[0] = pitch; + + } + + private static float testResampler(SoftAbstractResampler resampler, float p_pitch, float p_pitch2) + { + float[] testbuffer = new float[4096]; + float[] testbuffer2 = new float[1024]; + float[] testbuffer3 = new float[1024]; + for (int i = 0; i < testbuffer.length; i++) + testbuffer[i] = getResamplerTestValue(i); + int pads = resampler.getPadding(); + float pitchstep = (p_pitch2 - p_pitch)/1024f; + int[] out_offset2 = {0}; + int[] out_offset3 = {0}; + resampler.interpolate(testbuffer, new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer2, out_offset2, testbuffer2.length); + perfectInterpolation(new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer3, out_offset3, testbuffer3.length); + int out_off = out_offset2[0]; + if(out_offset3[0] < out_off) + out_off = out_offset3[0]; + float ac_error = 0; + int counter = 0; + for (int i = pads; i < out_off; i++) { + ac_error += Math.abs(testbuffer2[i] - testbuffer3[i]); + counter++; + } + return ac_error / ((float)counter); + } + + private static void fail(String error) throws Exception + { + throw new RuntimeException(error); + } + + public static void main(String[] args) throws Exception { + SoftLanczosResampler resampler = new SoftLanczosResampler(); + float max = testResampler(resampler, 0.3f, 0.3f); + if(max > 0.01) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 0.3f, 0.01f); + if(max > 0.01) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 1.0f, 0.00f); + if(max > 0.01) + fail("Interpolation failed, error="+max); + } +} \ No newline at end of file diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_mix.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_mix.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,97 @@ +/* + * 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 SoftLimiter processAudio method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ProcessAudio_replace_mix { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + + SoftAudioBuffer in1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer in2 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out2 = new SoftAudioBuffer(250, synth.getFormat()); + + float[] testdata1 = new float[in1.getSize()]; + float[] testdata2 = new float[in2.getSize()]; + float[] n1a = in1.array(); + float[] n2a = in2.array(); + float[] out1a = out1.array(); + float[] out2a = out2.array(); + for (int i = 0; i < n1a.length; i++) { + testdata1[i] = (float)Math.sin(i*0.3)*0.9f; + testdata2[i] = (float)Math.sin(i*0.4)*0.9f; + n1a[i] = testdata1[i]; + n2a[i] = testdata2[i]; + out1a[i] = 1; + out2a[i] = 1; + } + + SoftLimiter limiter = new SoftLimiter(); + limiter.init(synth.getFormat().getSampleRate(), + synth.getControlRate()); + limiter.setMixMode(true); + limiter.setInput(0, in1); + limiter.setInput(1, in2); + limiter.setOutput(0, out1); + limiter.setOutput(1, out2); + limiter.processControlLogic(); + limiter.processAudio(); + limiter.processControlLogic(); + limiter.processAudio(); + // Limiter should delay audio by one buffer, + // and there should almost no different in output v.s. input + for (int i = 0; i < n1a.length; i++) { + if(Math.abs(out1a[i] - testdata1[i] - 1) > 0.00001) + throw new Exception("input != output"); + if(Math.abs(out2a[i] - testdata2[i] - 1) > 0.00001) + throw new Exception("input != output"); + } + + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_mix_mono.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_mix_mono.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,84 @@ +/* + * 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 SoftLimiter processAudio method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ProcessAudio_replace_mix_mono { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftSynthesizer synth = new SoftSynthesizer(); + synth.openStream(new AudioFormat(44100, 16, 1, true, false), null); + + SoftAudioBuffer in1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out1 = new SoftAudioBuffer(250, synth.getFormat()); + + float[] testdata1 = new float[in1.getSize()]; + float[] n1a = in1.array(); + float[] out1a = out1.array(); + for (int i = 0; i < n1a.length; i++) { + testdata1[i] = (float)Math.sin(i*0.3)*0.9f; + n1a[i] = testdata1[i]; + out1a[i] = 1; + } + + SoftLimiter limiter = new SoftLimiter(); + limiter.init(synth.getFormat().getSampleRate(), + synth.getControlRate()); + limiter.setMixMode(true); + limiter.setInput(0, in1); + limiter.setOutput(0, out1); + limiter.processControlLogic(); + limiter.processAudio(); + limiter.processControlLogic(); + limiter.processAudio(); + // Limiter should delay audio by one buffer, + // and there should almost no different in output v.s. input + for (int i = 0; i < n1a.length; i++) { + if(Math.abs(out1a[i] - testdata1[i] - 1) > 0.00001) + throw new Exception("input != output"); + } + + synth.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_mix_mono_overdrive.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_mix_mono_overdrive.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,85 @@ +/* + * 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 SoftLimiter processAudio method */ + + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ProcessAudio_replace_mix_mono_overdrive { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftSynthesizer synth = new SoftSynthesizer(); + synth.openStream(new AudioFormat(44100, 16, 1, true, false), null); + + SoftAudioBuffer in1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out1 = new SoftAudioBuffer(250, synth.getFormat()); + + float[] testdata1 = new float[in1.getSize()]; + float[] n1a = in1.array(); + float[] out1a = out1.array(); + for (int i = 0; i < n1a.length; i++) { + testdata1[i] = (float)Math.sin(i*0.3)*2.5f; + n1a[i] = testdata1[i]; + out1a[i] = 1; + } + + SoftLimiter limiter = new SoftLimiter(); + limiter.init(synth.getFormat().getSampleRate(), + synth.getControlRate()); + limiter.setMixMode(true); + limiter.setInput(0, in1); + limiter.setOutput(0, out1); + limiter.processControlLogic(); + limiter.processAudio(); + limiter.processControlLogic(); + limiter.processAudio(); + // Limiter should delay audio by one buffer, + // and there should almost no different in output v.s. input + for (int i = 0; i < n1a.length; i++) { + if(Math.abs(out1a[i]-1) > 1.0) + throw new Exception("abs(output)>1"); + } + + synth.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_mix_overdrive.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_mix_overdrive.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,96 @@ +/* + * 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 SoftLimiter processAudio method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ProcessAudio_replace_mix_overdrive { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + + SoftAudioBuffer in1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer in2 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out2 = new SoftAudioBuffer(250, synth.getFormat()); + + float[] testdata1 = new float[in1.getSize()]; + float[] testdata2 = new float[in2.getSize()]; + float[] n1a = in1.array(); + float[] n2a = in2.array(); + float[] out1a = out1.array(); + float[] out2a = out2.array(); + for (int i = 0; i < n1a.length; i++) { + testdata1[i] = (float)Math.sin(i*0.3)*2.5f; + testdata2[i] = (float)Math.sin(i*0.4)*2.5f; + n1a[i] = testdata1[i]; + n2a[i] = testdata2[i]; + out1a[i] = 1; + out2a[i] = 1; + } + + SoftLimiter limiter = new SoftLimiter(); + limiter.init(synth.getFormat().getSampleRate(), + synth.getControlRate()); + limiter.setMixMode(true); + limiter.setInput(0, in1); + limiter.setInput(1, in2); + limiter.setOutput(0, out1); + limiter.setOutput(1, out2); + limiter.processControlLogic(); + limiter.processAudio(); + limiter.processControlLogic(); + limiter.processAudio(); + // Limiter should delay audio by one buffer, + // and there should almost no different in output v.s. input + for (int i = 0; i < n1a.length; i++) { + if(Math.abs(out1a[i]-1) > 1.0) + throw new Exception("abs(output)>1"); + if(Math.abs(out2a[i]-1) > 1.0) + throw new Exception("abs(output)>1"); + } + + synth.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_normal.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_normal.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,96 @@ +/* + * 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 SoftLimiter processAudio method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ProcessAudio_replace_normal { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + + SoftAudioBuffer in1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer in2 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out2 = new SoftAudioBuffer(250, synth.getFormat()); + + float[] testdata1 = new float[in1.getSize()]; + float[] testdata2 = new float[in2.getSize()]; + float[] n1a = in1.array(); + float[] n2a = in2.array(); + float[] out1a = out1.array(); + float[] out2a = out2.array(); + for (int i = 0; i < n1a.length; i++) { + testdata1[i] = (float)Math.sin(i*0.3)*0.9f; + testdata2[i] = (float)Math.sin(i*0.4)*0.9f; + n1a[i] = testdata1[i]; + n2a[i] = testdata2[i]; + out1a[i] = 1; + out2a[i] = 1; + } + + SoftLimiter limiter = new SoftLimiter(); + limiter.init(synth.getFormat().getSampleRate(), + synth.getControlRate()); + limiter.setMixMode(false); + limiter.setInput(0, in1); + limiter.setInput(1, in2); + limiter.setOutput(0, out1); + limiter.setOutput(1, out2); + limiter.processControlLogic(); + limiter.processAudio(); + limiter.processControlLogic(); + limiter.processAudio(); + // Limiter should delay audio by one buffer, + // and there should almost no different in output v.s. input + for (int i = 0; i < n1a.length; i++) { + if(Math.abs(out1a[i] - testdata1[i]) > 0.00001) + throw new Exception("input != output"); + if(Math.abs(out2a[i] - testdata2[i]) > 0.00001) + throw new Exception("input != output"); + } + + synth.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_normal_mono.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_normal_mono.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,84 @@ +/* + * 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 SoftLimiter processAudio method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ProcessAudio_replace_normal_mono { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftSynthesizer synth = new SoftSynthesizer(); + synth.openStream(new AudioFormat(44100, 16, 1, true, false), null); + + SoftAudioBuffer in1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out1 = new SoftAudioBuffer(250, synth.getFormat()); + + float[] testdata1 = new float[in1.getSize()]; + float[] n1a = in1.array(); + float[] out1a = out1.array(); + for (int i = 0; i < n1a.length; i++) { + testdata1[i] = (float)Math.sin(i*0.3)*0.9f; + n1a[i] = testdata1[i]; + out1a[i] = 1; + } + + SoftLimiter limiter = new SoftLimiter(); + limiter.init(synth.getFormat().getSampleRate(), + synth.getControlRate()); + limiter.setMixMode(false); + limiter.setInput(0, in1); + limiter.setOutput(0, out1); + limiter.processControlLogic(); + limiter.processAudio(); + limiter.processControlLogic(); + limiter.processAudio(); + // Limiter should delay audio by one buffer, + // and there should almost no different in output v.s. input + for (int i = 0; i < n1a.length; i++) { + if(Math.abs(out1a[i] - testdata1[i]) > 0.00001) + throw new Exception("input != output"); + } + + synth.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_overdrive.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_overdrive.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,96 @@ +/* + * 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 SoftLimiter processAudio method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ProcessAudio_replace_overdrive { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + + SoftAudioBuffer in1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer in2 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out2 = new SoftAudioBuffer(250, synth.getFormat()); + + float[] testdata1 = new float[in1.getSize()]; + float[] testdata2 = new float[in2.getSize()]; + float[] n1a = in1.array(); + float[] n2a = in2.array(); + float[] out1a = out1.array(); + float[] out2a = out2.array(); + for (int i = 0; i < n1a.length; i++) { + testdata1[i] = (float)Math.sin(i*0.3)*2.5f; + testdata2[i] = (float)Math.sin(i*0.4)*2.5f; + n1a[i] = testdata1[i]; + n2a[i] = testdata2[i]; + out1a[i] = 1; + out2a[i] = 1; + } + + SoftLimiter limiter = new SoftLimiter(); + limiter.init(synth.getFormat().getSampleRate(), + synth.getControlRate()); + limiter.setMixMode(false); + limiter.setInput(0, in1); + limiter.setInput(1, in2); + limiter.setOutput(0, out1); + limiter.setOutput(1, out2); + limiter.processControlLogic(); + limiter.processAudio(); + limiter.processControlLogic(); + limiter.processAudio(); + // Limiter should delay audio by one buffer, + // and there should almost no different in output v.s. input + for (int i = 0; i < n1a.length; i++) { + if(Math.abs(out1a[i]) > 1.0) + throw new Exception("abs(output)>1"); + if(Math.abs(out2a[i]) > 1.0) + throw new Exception("abs(output)>1"); + } + + synth.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_overdrive_mono.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftLimiter/ProcessAudio_replace_overdrive_mono.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,84 @@ +/* + * 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 SoftLimiter processAudio method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class ProcessAudio_replace_overdrive_mono { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftSynthesizer synth = new SoftSynthesizer(); + synth.openStream(new AudioFormat(44100, 16, 1, true, false), null); + + SoftAudioBuffer in1 = new SoftAudioBuffer(250, synth.getFormat()); + SoftAudioBuffer out1 = new SoftAudioBuffer(250, synth.getFormat()); + + float[] testdata1 = new float[in1.getSize()]; + float[] n1a = in1.array(); + float[] out1a = out1.array(); + for (int i = 0; i < n1a.length; i++) { + testdata1[i] = (float)Math.sin(i*0.3)*2.5f; + n1a[i] = testdata1[i]; + out1a[i] = 1; + } + + SoftLimiter limiter = new SoftLimiter(); + limiter.init(synth.getFormat().getSampleRate(), + synth.getControlRate()); + limiter.setMixMode(false); + limiter.setInput(0, in1); + limiter.setOutput(0, out1); + limiter.processControlLogic(); + limiter.processAudio(); + limiter.processControlLogic(); + limiter.processAudio(); + // Limiter should delay audio by one buffer, + // and there should almost no different in output v.s. input + for (int i = 0; i < n1a.length; i++) { + if(Math.abs(out1a[i]) > 1.0) + throw new Exception("abs(output)>1"); + } + + synth.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftLinearResampler/Interpolate.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftLinearResampler/Interpolate.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,113 @@ +/* + * 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 SoftLinearResampler interpolate method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Interpolate { + + private static float getResamplerTestValue(double i) + { + return (float)Math.sin(i / 10.0); + } + + private static void perfectInterpolation(float[] in_offset, float in_end, + float[] startpitch, float pitchstep, float[] out, int[] out_offset, + int out_end) { + + float pitch = startpitch[0]; + float ix = in_offset[0]; + int ox = out_offset[0]; + float ix_end = in_end; + int ox_end = out_end; + if (pitchstep == 0f) { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + } + } else { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + pitch += pitchstep; + } + } + in_offset[0] = ix; + out_offset[0] = ox; + startpitch[0] = pitch; + + } + + private static float testResampler(SoftAbstractResampler resampler, float p_pitch, float p_pitch2) + { + float[] testbuffer = new float[4096]; + float[] testbuffer2 = new float[1024]; + float[] testbuffer3 = new float[1024]; + for (int i = 0; i < testbuffer.length; i++) + testbuffer[i] = getResamplerTestValue(i); + int pads = resampler.getPadding(); + float pitchstep = (p_pitch2 - p_pitch)/1024f; + int[] out_offset2 = {0}; + int[] out_offset3 = {0}; + resampler.interpolate(testbuffer, new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer2, out_offset2, testbuffer2.length); + perfectInterpolation(new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer3, out_offset3, testbuffer3.length); + int out_off = out_offset2[0]; + if(out_offset3[0] < out_off) + out_off = out_offset3[0]; + float ac_error = 0; + int counter = 0; + for (int i = pads; i < out_off; i++) { + ac_error += Math.abs(testbuffer2[i] - testbuffer3[i]); + counter++; + } + return ac_error / ((float)counter); + } + + private static void fail(String error) throws Exception + { + throw new RuntimeException(error); + } + + public static void main(String[] args) throws Exception { + SoftLinearResampler resampler = new SoftLinearResampler(); + float max = testResampler(resampler, 0.3f, 0.3f); + if(max > 0.001) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 0.3f, 0.01f); + if(max > 0.001) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 1.0f, 0.00f); + if(max > 0.001) + fail("Interpolation failed, error="+max); + } +} \ No newline at end of file diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftLinearResampler2/Interpolate.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftLinearResampler2/Interpolate.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,113 @@ +/* + * 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 SoftLinearResampler2 interpolate method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Interpolate { + + private static float getResamplerTestValue(double i) + { + return (float)Math.sin(i / 10.0); + } + + private static void perfectInterpolation(float[] in_offset, float in_end, + float[] startpitch, float pitchstep, float[] out, int[] out_offset, + int out_end) { + + float pitch = startpitch[0]; + float ix = in_offset[0]; + int ox = out_offset[0]; + float ix_end = in_end; + int ox_end = out_end; + if (pitchstep == 0f) { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + } + } else { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + pitch += pitchstep; + } + } + in_offset[0] = ix; + out_offset[0] = ox; + startpitch[0] = pitch; + + } + + private static float testResampler(SoftAbstractResampler resampler, float p_pitch, float p_pitch2) + { + float[] testbuffer = new float[4096]; + float[] testbuffer2 = new float[1024]; + float[] testbuffer3 = new float[1024]; + for (int i = 0; i < testbuffer.length; i++) + testbuffer[i] = getResamplerTestValue(i); + int pads = resampler.getPadding(); + float pitchstep = (p_pitch2 - p_pitch)/1024f; + int[] out_offset2 = {0}; + int[] out_offset3 = {0}; + resampler.interpolate(testbuffer, new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer2, out_offset2, testbuffer2.length); + perfectInterpolation(new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer3, out_offset3, testbuffer3.length); + int out_off = out_offset2[0]; + if(out_offset3[0] < out_off) + out_off = out_offset3[0]; + float ac_error = 0; + int counter = 0; + for (int i = pads; i < out_off; i++) { + ac_error += Math.abs(testbuffer2[i] - testbuffer3[i]); + counter++; + } + return ac_error / ((float)counter); + } + + private static void fail(String error) throws Exception + { + throw new RuntimeException(error); + } + + public static void main(String[] args) throws Exception { + SoftLinearResampler2 resampler = new SoftLinearResampler2(); + float max = testResampler(resampler, 0.3f, 0.3f); + if(max > 0.2) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 0.3f, 0.01f); + if(max > 0.2) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 1.0f, 0.00f); + if(max > 0.2) + fail("Interpolation failed, error="+max); + } +} \ No newline at end of file diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftPointResampler/Interpolate.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftPointResampler/Interpolate.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,113 @@ +/* + * 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 SoftPointResampler interpolate method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Interpolate { + + private static float getResamplerTestValue(double i) + { + return (float)Math.sin(i / 10.0); + } + + private static void perfectInterpolation(float[] in_offset, float in_end, + float[] startpitch, float pitchstep, float[] out, int[] out_offset, + int out_end) { + + float pitch = startpitch[0]; + float ix = in_offset[0]; + int ox = out_offset[0]; + float ix_end = in_end; + int ox_end = out_end; + if (pitchstep == 0f) { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + } + } else { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + pitch += pitchstep; + } + } + in_offset[0] = ix; + out_offset[0] = ox; + startpitch[0] = pitch; + + } + + private static float testResampler(SoftAbstractResampler resampler, float p_pitch, float p_pitch2) + { + float[] testbuffer = new float[4096]; + float[] testbuffer2 = new float[1024]; + float[] testbuffer3 = new float[1024]; + for (int i = 0; i < testbuffer.length; i++) + testbuffer[i] = getResamplerTestValue(i); + int pads = resampler.getPadding(); + float pitchstep = (p_pitch2 - p_pitch)/1024f; + int[] out_offset2 = {0}; + int[] out_offset3 = {0}; + resampler.interpolate(testbuffer, new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer2, out_offset2, testbuffer2.length); + perfectInterpolation(new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer3, out_offset3, testbuffer3.length); + int out_off = out_offset2[0]; + if(out_offset3[0] < out_off) + out_off = out_offset3[0]; + float ac_error = 0; + int counter = 0; + for (int i = pads; i < out_off; i++) { + ac_error += Math.abs(testbuffer2[i] - testbuffer3[i]); + counter++; + } + return ac_error / ((float)counter); + } + + private static void fail(String error) throws Exception + { + throw new RuntimeException(error); + } + + public static void main(String[] args) throws Exception { + SoftPointResampler resampler = new SoftPointResampler(); + float max = testResampler(resampler, 0.3f, 0.3f); + if(max > 0.2) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 0.3f, 0.01f); + if(max > 0.2) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 1.0f, 0.00f); + if(max > 0.2) + fail("Interpolation failed, error="+max); + } +} \ No newline at end of file diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftProvider/GetDevice.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftProvider/GetDevice.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,70 @@ +/* + * 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 SoftProvider getDevice method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetDevice { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + + private static class FakeInfo extends Info { + public FakeInfo() { + super("a", "b", "c", "d"); + } + } + + public static void main(String[] args) throws Exception { + SoftProvider provider = new SoftProvider(); + Info[] infos = provider.getDeviceInfo(); + assertTrue(infos.length > 0); + for (int i = 0; i < infos.length; i++) { + assertTrue(infos[i] != null); + MidiDevice d = provider.getDevice(infos[i]); + assertTrue(d instanceof SoftSynthesizer); + } + assertTrue(provider.getDevice(new FakeInfo()) == null); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Close.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Close.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,59 @@ +/* + * 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 SoftReceiver close method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Close { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + assertEquals(soft.synth.getReceivers().size(), 1); + receiver.close(); + assertEquals(soft.synth.getReceivers().size(), 0); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_ActiveSense.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_ActiveSense.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,82 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_ActiveSense { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void sendActiveSens(Receiver r) throws Exception + { + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.ACTIVE_SENSING); + r.send(smsg, -1); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + sendActiveSens(receiver); + + // 1. Check if notes are keept active + // if send active sens every 200-300 msec + + sendActiveSens(receiver); + channel.noteOn(60, 64); + assertTrue(soft.findVoice(0,60) != null); + for (int i = 0; i < 10; i++) { + soft.read(0.2); // read 200 msec + sendActiveSens(receiver); + assertTrue(soft.findVoice(0,60) != null); + } + // 2. Now we stop send active sense message + // and the note should be killed off + soft.read(2); + assertTrue(soft.findVoice(0,60) == null); + + + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_AllNotesOff.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_AllNotesOff.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,64 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_AllNotesOff { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + channel.noteOn(60, 64); + soft.read(1); + assertTrue(soft.findVoice(0,60) != null); + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 123,0); + receiver.send(smsg, -1); + soft.read(1); + assertTrue(soft.findVoice(0,60) == null); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_AllSoundOff.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_AllSoundOff.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,64 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_AllSoundOff { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + channel.noteOn(60, 64); + soft.read(1); + assertTrue(soft.findVoice(0,60) != null); + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 120,0); + receiver.send(smsg, -1); + soft.read(1); + assertTrue(soft.findVoice(0,60) == null); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_ChannelPressure.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_ChannelPressure.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,63 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_ChannelPressure { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.CHANNEL_PRESSURE,0, 10,0); + receiver.send(smsg, -1); + assertEquals(channel.getChannelPressure(), 10); + smsg.setMessage(ShortMessage.CHANNEL_PRESSURE,0, 90,0); + receiver.send(smsg, -1); + assertEquals(channel.getChannelPressure(), 90); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_Controller.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_Controller.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,66 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_Controller { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + ShortMessage smsg = new ShortMessage(); + for (int i = 0; i < 128; i++) { + if(i == 0 || i == 32) continue; + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, i,10); + receiver.send(smsg, -1); + assertEquals(channel.getController(i), 10); + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, i,100); + receiver.send(smsg, -1); + assertEquals(channel.getController(i), 100); + } + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_Mono.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_Mono.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,75 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_Mono { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 126,100); + receiver.send(smsg, -1); + assertEquals(channel.getMono(), false); + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 126,1); + receiver.send(smsg, -1); + assertEquals(channel.getMono(), true); + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 127,0); + receiver.send(smsg, -1); + assertEquals(channel.getMono(), false); + + // Check if send mono triggers AllNotesOff + channel.noteOn(60, 64); + soft.read(1); + assertTrue(soft.findVoice(0,60) != null); + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 127,0); + receiver.send(smsg, -1); + soft.read(1); + assertTrue(soft.findVoice(0,60) == null); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_NoteOff.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_NoteOff.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,65 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_NoteOff { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.NOTE_ON,0, 60, 64); + receiver.send(smsg, -1); + soft.read(1); + assertTrue(soft.findVoice(0,60) != null); + smsg.setMessage(ShortMessage.NOTE_OFF,0, 60, 0); + receiver.send(smsg, -1); + soft.read(1); + assertTrue(soft.findVoice(0,60) == null); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_NoteOn.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_NoteOn.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,65 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_NoteOn { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.NOTE_ON,0, 60, 64); + receiver.send(smsg, -1); + soft.read(1); + assertTrue(soft.findVoice(0,60) != null); + smsg.setMessage(ShortMessage.NOTE_ON,0, 60, 0); + receiver.send(smsg, -1); + soft.read(1); + assertTrue(soft.findVoice(0,60) == null); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_NoteOn_AllChannels.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_NoteOn_AllChannels.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,71 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_NoteOn_AllChannels { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + for (int i = 0; i < 15; i++) { + if(i == 9) i++; + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.NOTE_ON,i, 60, 64); + receiver.send(smsg, -1); + soft.read(1); + VoiceStatus voice = soft.findVoice(i,60); + assertTrue(voice != null); + smsg.setMessage(ShortMessage.NOTE_ON,i, 60, 0); + receiver.send(smsg, -1); + soft.read(1); + voice = soft.findVoice(i,60); + assertTrue(voice == null); + soft.read(1); + } + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_NoteOn_Delayed.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_NoteOn_Delayed.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,67 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_NoteOn_Delayed { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.NOTE_ON,0, 60, 64); + receiver.send(smsg, 2000000); // Delay sending note for 2 sec + soft.read(1); + assertTrue(soft.findVoice(0,60) == null); + soft.read(2); + assertTrue(soft.findVoice(0,60) != null); + smsg.setMessage(ShortMessage.NOTE_ON,0, 60, 0); + receiver.send(smsg, -1); + soft.read(1); + assertTrue(soft.findVoice(0,60) == null); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_NoteOn_Multiple.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_NoteOn_Multiple.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,76 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_NoteOn_Multiple { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.NOTE_ON,0, 60, 64); + receiver.send(smsg, -1); + smsg.setMessage(ShortMessage.NOTE_ON,0, 61, 64); + receiver.send(smsg, -1); + smsg.setMessage(ShortMessage.NOTE_ON,0, 62, 64); + receiver.send(smsg, -1); + soft.read(1); + assertTrue(soft.findVoice(0,60) != null); + assertTrue(soft.findVoice(0,61) != null); + assertTrue(soft.findVoice(0,62) != null); + + smsg.setMessage(ShortMessage.NOTE_ON,0, 60, 0); + receiver.send(smsg, -1); + smsg.setMessage(ShortMessage.NOTE_ON,0, 61, 0); + receiver.send(smsg, -1); + soft.read(1); + assertTrue(soft.findVoice(0,60) == null); + assertTrue(soft.findVoice(0,61) == null); + assertTrue(soft.findVoice(0,62) != null); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_Omni.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_Omni.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,74 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_Omni { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 125,0); + receiver.send(smsg, -1); + // Poly or Omni not supported by GM2 + // getOmni() should always return false + assertEquals(channel.getOmni(), false); + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 124,0); + receiver.send(smsg, -1); + assertEquals(channel.getOmni(), false); + + // Check if send omni triggers AllNotesOff + channel.noteOn(60, 64); + soft.read(1); + assertTrue(soft.findVoice(0,60) != null); + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 124,0); + receiver.send(smsg, -1); + soft.read(1); + assertTrue(soft.findVoice(0,60) == null); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_PitchBend.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_PitchBend.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,63 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_PitchBend { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.PITCH_BEND,0, 10,0); + receiver.send(smsg, -1); + assertEquals(channel.getPitchBend(), 10); + smsg.setMessage(ShortMessage.PITCH_BEND,0, 9000%128,9000/128); + receiver.send(smsg, -1); + assertEquals(channel.getPitchBend(), 9000); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_PolyPressure.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_PolyPressure.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,65 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_PolyPressure { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + ShortMessage smsg = new ShortMessage(); + for (int i = 0; i < 128; i++) { + smsg.setMessage(ShortMessage.POLY_PRESSURE,0, i, 10); + receiver.send(smsg, -1); + assertEquals(channel.getPolyPressure(i),10); + smsg.setMessage(ShortMessage.POLY_PRESSURE,0, i, 100); + receiver.send(smsg, -1); + assertEquals(channel.getPolyPressure(i),100); + } + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_ProgramChange.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_ProgramChange.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,63 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_ProgramChange { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.PROGRAM_CHANGE,0, 36,0); + receiver.send(smsg, -1); + assertEquals(channel.getProgram(), 36); + smsg.setMessage(ShortMessage.PROGRAM_CHANGE,0, 48,0); + receiver.send(smsg, -1); + assertEquals(channel.getProgram(), 48); + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_ResetAllControllers.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/Send_ResetAllControllers.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,136 @@ +/* + * 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 SoftReceiver send method */ + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Send_ResetAllControllers { + + public static boolean[] dontResetControls = new boolean[128]; + static { + for (int i = 0; i < dontResetControls.length; i++) + dontResetControls[i] = false; + + dontResetControls[0] = true; // Bank Select (MSB) + dontResetControls[32] = true; // Bank Select (LSB) + dontResetControls[7] = true; // Channel Volume (MSB) + dontResetControls[8] = true; // Balance (MSB) + dontResetControls[10] = true; // Pan (MSB) + dontResetControls[11] = true; // Expression (MSB) + dontResetControls[91] = true; // Effects 1 Depth (default: Reverb Send) + dontResetControls[92] = true; // Effects 2 Depth (default: Tremolo Depth) + dontResetControls[93] = true; // Effects 3 Depth (default: Chorus Send) + dontResetControls[94] = true; // Effects 4 Depth (default: Celeste [Detune] Depth) + dontResetControls[95] = true; // Effects 5 Depth (default: Phaser Depth) + dontResetControls[70] = true; // Sound Controller 1 (default: Sound Variation) + dontResetControls[71] = true; // Sound Controller 2 (default: Timbre / Harmonic Quality) + dontResetControls[72] = true; // Sound Controller 3 (default: Release Time) + dontResetControls[73] = true; // Sound Controller 4 (default: Attack Time) + dontResetControls[74] = true; // Sound Controller 5 (default: Brightness) + dontResetControls[75] = true; // Sound Controller 6 (GM2 default: Decay Time) + dontResetControls[76] = true; // Sound Controller 7 (GM2 default: Vibrato Rate) + dontResetControls[77] = true; // Sound Controller 8 (GM2 default: Vibrato Depth) + dontResetControls[78] = true; // Sound Controller 9 (GM2 default: Vibrato Delay) + dontResetControls[79] = true; // Sound Controller 10 (GM2 default: Undefined) + dontResetControls[120] = true; // All Sound Off + dontResetControls[121] = true; // Reset All Controllers + dontResetControls[122] = true; // Local Control On/Off + dontResetControls[123] = true; // All Notes Off + dontResetControls[124] = true; // Omni Mode Off + dontResetControls[125] = true; // Omni Mode On + dontResetControls[126] = true; // Poly Mode Off + dontResetControls[127] = true; // Poly Mode On + + dontResetControls[6] = true; // Data Entry (MSB) + dontResetControls[38] = true; // Data Entry (LSB) + dontResetControls[96] = true; // Data Increment + dontResetControls[97] = true; // Data Decrement + dontResetControls[98] = true; // Non-Registered Parameter Number (LSB) + dontResetControls[99] = true; // Non-Registered Parameter Number(MSB) + dontResetControls[100] = true; // RPN = Null + dontResetControls[101] = true; // RPN = Null + } + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTestUtils soft = new SoftTestUtils(); + MidiChannel channel = soft.synth.getChannels()[0]; + Receiver receiver = soft.synth.getReceiver(); + + // First let all controls contain non-default values + for (int i = 0; i < 128; i++) + channel.setPolyPressure(i, 10); + channel.setChannelPressure(10); + channel.setPitchBend(2192); + for (int i = 0; i < 120; i++) + channel.controlChange(i, 1); + + ShortMessage smsg = new ShortMessage(); + smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 121,0); + receiver.send(smsg, -1); + + // Now check if resetAllControllers did what it was suppose to do + + for (int i = 0; i < 128; i++) + assertEquals(channel.getPolyPressure(i), 0); + assertEquals(channel.getChannelPressure(), 0); + assertEquals(channel.getPitchBend(),8192); + for (int i = 0; i < 120; i++) + if(!dontResetControls[i]) + assertEquals(channel.getController(i), 0); + assertEquals(channel.getController(71), 64); // Filter Resonance + assertEquals(channel.getController(72), 64); // Release Time + assertEquals(channel.getController(73), 64); // Attack Time + assertEquals(channel.getController(74), 64); // Brightness + assertEquals(channel.getController(75), 64); // Decay Time + assertEquals(channel.getController(76), 64); // Vibrato Rate + assertEquals(channel.getController(77), 64); // Vibrato Depth + assertEquals(channel.getController(78), 64); // Vibrato Delay + assertEquals(channel.getController(8), 64); // Balance + assertEquals(channel.getController(11), 127); // Expression + assertEquals(channel.getController(98), 127); // NRPN Null + assertEquals(channel.getController(99), 127); // NRPN Null + assertEquals(channel.getController(100), 127); // RPN = Null + assertEquals(channel.getController(101), 127); // RPN = Null + + soft.close(); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/SoftTestUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftReceiver/SoftTestUtils.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,111 @@ +/* + * 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. + */ + +import java.io.IOException; + +import javax.sound.midi.*; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class SoftTestUtils { + + public AudioSynthesizer synth = new SoftSynthesizer(); + public AudioInputStream stream; + public byte[] tmpbuffer = new byte[1024]; + + public static SF2Soundbank createTestSoundBank() + { + SF2Soundbank sf2 = new SF2Soundbank(); + AudioFormat format = new AudioFormat(44100, 16, 1, true, false); + float[] data = new float[44100+1000]; + float fr = 440/format.getSampleRate(); + for (int i = 0; i < data.length; i++) + data[i] = (float)Math.sin(i*fr*2*Math.PI); + byte[] bdata = new byte[data.length*format.getFrameSize()]; + AudioFloatConverter.getConverter(format).toByteArray(data, bdata); + SF2Sample sample = new SF2Sample(sf2); + sample.setName("Test Sample"); + sample.setData(bdata); + sample.setStartLoop(500); + sample.setEndLoop(data.length - 500); + sample.setSampleRate((long) format.getSampleRate()); + sample.setOriginalPitch(69); + sf2.addResource(sample); + SF2Layer layer = new SF2Layer(sf2); + layer.setName("Test Layer"); + sf2.addResource(layer); + SF2LayerRegion region = new SF2LayerRegion(); + region.putInteger(SF2Region.GENERATOR_SAMPLEMODES, 1); + region.setSample(sample); + layer.getRegions().add(region); + SF2Instrument ins = new SF2Instrument(sf2); + ins.setName("Test Instrument"); + sf2.addInstrument(ins); + SF2InstrumentRegion insregion = new SF2InstrumentRegion(); + insregion.setLayer(layer); + ins.getRegions().add(insregion); + + return sf2; + } + + public SoftTestUtils() throws Exception { + stream = synth.openStream(null, null); + synth.unloadAllInstruments(synth.getDefaultSoundbank()); + synth.loadAllInstruments(createTestSoundBank()); + } + + public void close() throws Exception { + stream.close(); + stream = null; + synth.close(); + synth = null; + } + + public void read(double seconds) throws IOException + { + int bufflen = + stream.getFormat().getFrameSize() * + (int)(stream.getFormat().getFrameRate() * seconds); + while(bufflen != 0) + { + if(bufflen > 1024) + bufflen -= stream.read(tmpbuffer,0,1024); + else + bufflen -= stream.read(tmpbuffer,0, bufflen); + } + } + + public VoiceStatus findVoice(int channel, int note) { + VoiceStatus[] v = synth.getVoiceStatus(); + for (int k = 0; k < v.length; k++) + if(v[k].active) + if(v[k].channel == channel) + if(v[k].note == note) + return v[k]; + return null; + } + +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSincResampler/Interpolate.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSincResampler/Interpolate.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,113 @@ +/* + * 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 SoftSincResampler interpolate method */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Interpolate { + + private static float getResamplerTestValue(double i) + { + return (float)Math.sin(i / 10.0); + } + + private static void perfectInterpolation(float[] in_offset, float in_end, + float[] startpitch, float pitchstep, float[] out, int[] out_offset, + int out_end) { + + float pitch = startpitch[0]; + float ix = in_offset[0]; + int ox = out_offset[0]; + float ix_end = in_end; + int ox_end = out_end; + if (pitchstep == 0f) { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + } + } else { + while (ix < ix_end && ox < ox_end) { + out[ox++] = getResamplerTestValue(ix); + ix += pitch; + pitch += pitchstep; + } + } + in_offset[0] = ix; + out_offset[0] = ox; + startpitch[0] = pitch; + + } + + private static float testResampler(SoftAbstractResampler resampler, float p_pitch, float p_pitch2) + { + float[] testbuffer = new float[4096]; + float[] testbuffer2 = new float[1024]; + float[] testbuffer3 = new float[1024]; + for (int i = 0; i < testbuffer.length; i++) + testbuffer[i] = getResamplerTestValue(i); + int pads = resampler.getPadding(); + float pitchstep = (p_pitch2 - p_pitch)/1024f; + int[] out_offset2 = {0}; + int[] out_offset3 = {0}; + resampler.interpolate(testbuffer, new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer2, out_offset2, testbuffer2.length); + perfectInterpolation(new float[] {pads}, testbuffer.length - pads, new float[] {p_pitch}, pitchstep, testbuffer3, out_offset3, testbuffer3.length); + int out_off = out_offset2[0]; + if(out_offset3[0] < out_off) + out_off = out_offset3[0]; + float ac_error = 0; + int counter = 0; + for (int i = pads; i < out_off; i++) { + ac_error += Math.abs(testbuffer2[i] - testbuffer3[i]); + counter++; + } + return ac_error / ((float)counter); + } + + private static void fail(String error) throws Exception + { + throw new RuntimeException(error); + } + + public static void main(String[] args) throws Exception { + SoftSincResampler resampler = new SoftSincResampler(); + float max = testResampler(resampler, 0.3f, 0.3f); + if(max > 0.0001) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 0.3f, 0.01f); + if(max > 0.0001) + fail("Interpolation failed, error="+max); + max = testResampler(resampler, 1.0f, 0.00f); + if(max > 0.0001) + fail("Interpolation failed, error="+max); + } +} \ No newline at end of file diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/Close.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/Close.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,58 @@ +/* + * 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 SoftSynthesizer close method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class Close { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + synth.close(); + assertTrue(!synth.isOpen()); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetAvailableInstruments.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetAvailableInstruments.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,63 @@ +/* + * 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 SoftSynthesizer getAvailableInstruments method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Soundbank; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetAvailableInstruments { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + Soundbank defsbk = synth.getDefaultSoundbank(); + if(defsbk != null) + { + assertTrue(defsbk.getInstruments().length == synth.getAvailableInstruments().length); + } + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetChannels.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetChannels.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,64 @@ +/* + * 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 SoftSynthesizer getChannels method */ + +import javax.sound.midi.MidiChannel; +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetChannels { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + assertTrue(synth.getChannels() != null); + assertTrue(synth.getChannels().length == 16); + MidiChannel[] channels = synth.getChannels(); + for (int i = 0; i < channels.length; i++) { + assertTrue(channels[i] != null); + } + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetDefaultSoundbank.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetDefaultSoundbank.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,58 @@ +/* + * 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 SoftSynthesizer getDefaultSoundbank method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetDefaultSoundbank { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + assertTrue(synth.getDefaultSoundbank() != null); + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetDeviceInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetDeviceInfo.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,56 @@ +/* + * 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 SoftSynthesizer getDeviceInfo method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetDeviceInfo { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + assertTrue(synth.getDeviceInfo() != null); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetLatency.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetLatency.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,58 @@ +/* + * 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 SoftSynthesizer getLatency method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetLatency { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.open(); + assertTrue(synth.getLatency() != -1); + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetLoadedInstruments.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetLoadedInstruments.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,65 @@ +/* + * 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 SoftSynthesizer getLoadedInstruments method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Soundbank; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetLoadedInstruments { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + Soundbank defsbk = synth.getDefaultSoundbank(); + if(defsbk != null) + { + synth.unloadAllInstruments(defsbk); + synth.loadAllInstruments(defsbk); + assertTrue(synth.getLoadedInstruments().length != 0); + } + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetMaxPolyphony.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetMaxPolyphony.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,58 @@ +/* + * 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 SoftSynthesizer getMaxPolyphony method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetMaxPolyphony { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + assertTrue(synth.getMaxPolyphony() != -1); + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetMaxReceivers.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetMaxReceivers.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,56 @@ +/* + * 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 SoftSynthesizer getMaxReceivers method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetMaxReceivers { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + assertTrue(synth.getMaxReceivers() == -1); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetMaxTransmitters.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetMaxTransmitters.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,56 @@ +/* + * 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 SoftSynthesizer getMaxTransmitters method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetMaxTransmitters { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + assertTrue(synth.getMaxTransmitters() == 0); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetMicrosecondPosition.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetMicrosecondPosition.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,64 @@ +/* + * 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 SoftSynthesizer getMicrosecondPosition method */ + +import java.io.IOException; + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetMicrosecondPosition { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + AudioInputStream stream = synth.openStream(null, null); + assertTrue(synth.getMicrosecondPosition() == 0); + AudioFormat format = stream.getFormat(); + byte[] buff = new byte[((int)format.getFrameRate())*format.getFrameSize()];; + stream.read(buff); + assertTrue(Math.abs(synth.getMicrosecondPosition()-1000000) < 10000); + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetReceiver.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetReceiver.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,63 @@ +/* + * 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 SoftSynthesizer getReceiver method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Receiver; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetReceiver { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.open(null,null); + Receiver recv = synth.getReceiver(); + assertTrue(recv != null); + Receiver recv2 = synth.getReceiver(); + assertTrue(recv2 != null); + assertTrue(recv2 != recv); + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetReceiver2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetReceiver2.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,62 @@ +/* + * Copyright 2008 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 SoftSynthesizer getReceiver method */ + +import javax.sound.midi.Receiver; +import javax.sound.midi.ShortMessage; + +import com.sun.media.sound.AudioSynthesizer; +import com.sun.media.sound.SoftSynthesizer; + +public class GetReceiver2 { + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + Receiver recv = synth.getReceiver(); + assertTrue(recv != null); + ShortMessage sm = new ShortMessage(); + sm.setMessage(ShortMessage.NOTE_OFF, 0, 64, 64); + synth.open(null,null); + recv.send(sm, -1); + synth.close(); + try + { + recv.send(sm, -1); + throw new RuntimeException("Exception not thrown!"); + } + catch(Exception e) + { + // Just checking if exception is thrown + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetReceivers.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetReceivers.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,63 @@ +/* + * 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 SoftSynthesizer getReceivers method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Receiver; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetReceivers { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.open(null,null); + assertTrue(synth.getReceivers().size() == 0); + Receiver recv = synth.getReceiver(); + assertTrue(synth.getReceivers().size() == 1); + recv.close(); + assertTrue(synth.getReceivers().size() == 0); + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetTransmitter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetTransmitter.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,63 @@ +/* + * 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 SoftSynthesizer getTransmitter method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetTransmitter { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.open(null,null); + try + { + synth.getTransmitter(); + throw new Exception("MidiUnavailableException not thrown!"); + } catch (MidiUnavailableException e) { + } + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetTransmitters.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetTransmitters.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,58 @@ +/* + * 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 SoftSynthesizer getTransmitters method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetTransmitters { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.open(null,null); + assertTrue(synth.getTransmitters().size() == 0); + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetVoiceStatus.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/GetVoiceStatus.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,61 @@ +/* + * 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 SoftSynthesizer getVoiceStatus method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.VoiceStatus; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class GetVoiceStatus { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + VoiceStatus[] v = synth.getVoiceStatus(); + assertTrue(v != null); + assertTrue(synth.getChannels().length != synth.getMaxPolyphony()); + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/ImplicitOpenClose.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/ImplicitOpenClose.java Sun May 25 21:21:11 2008 +0200 @@ -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 SoftSynthesizer implicit open/close using getReceiver. */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiSystem; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Receiver; +import javax.sound.midi.Synthesizer; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class ImplicitOpenClose { + + public static void main(String[] args) throws Exception { + Synthesizer synth = new SoftSynthesizer(); + + ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth; + + // Test single open/close cycle + + Receiver recv = rcd.getReceiverReferenceCounting(); + if(!synth.isOpen()) + throw new Exception("Synthesizer not open!"); + recv.close(); + if(synth.isOpen()) + throw new Exception("Synthesizer not closed!"); + + // Test using 2 receiver cycle + + Receiver recv1 = rcd.getReceiverReferenceCounting(); + if(!synth.isOpen()) + throw new Exception("Synthesizer not open!"); + Receiver recv2 = rcd.getReceiverReferenceCounting(); + if(!synth.isOpen()) + throw new Exception("Synthesizer not open!"); + + recv2.close(); + if(!synth.isOpen()) + throw new Exception("Synthesizer was closed!"); + recv1.close(); + if(synth.isOpen()) + throw new Exception("Synthesizer not closed!"); + + // Test for explicit,implicit conflict + + synth.open(); + Receiver recv3 = rcd.getReceiverReferenceCounting(); + if(!synth.isOpen()) + throw new Exception("Synthesizer not open!"); + recv3.close(); + if(!synth.isOpen()) + throw new Exception("Synthesizer was closed!"); + synth.close(); + if(synth.isOpen()) + throw new Exception("Synthesizer not closed!"); + + // Test for implicit,explicit conflict + + recv3 = rcd.getReceiverReferenceCounting(); + synth.open(); + if(!synth.isOpen()) + throw new Exception("Synthesizer not open!"); + recv3.close(); + if(!synth.isOpen()) + throw new Exception("Synthesizer was closed!"); + synth.close(); + if(synth.isOpen()) + throw new Exception("Synthesizer not closed!"); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/IsOpen.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/IsOpen.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,59 @@ +/* + * 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 SoftSynthesizer isOpen method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class IsOpen { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + assertTrue(synth.isOpen()); + synth.close(); + assertTrue(!synth.isOpen()); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/IsSoundbankSupported.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/IsSoundbankSupported.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,95 @@ +/* + * 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 SoftSynthesizer isSoundbankSupported method */ + +import javax.sound.midi.Instrument; +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Soundbank; +import javax.sound.midi.SoundbankResource; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class IsSoundbankSupported { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + SimpleSoundbank sbk = new SimpleSoundbank(); + SimpleInstrument ins = new SimpleInstrument(); + sbk.addInstrument(ins); + assertTrue(synth.isSoundbankSupported(sbk)); + Soundbank dummysbk = new Soundbank() + { + public String getName() { + return null; + } + public String getVersion() { + return null; + } + public String getVendor() { + return null; + } + public String getDescription() { + return null; + } + public SoundbankResource[] getResources() { + return null; + } + public Instrument[] getInstruments() { + Instrument ins = new Instrument(null, null, null, null) + { + public Object getData() { + return null; + } + }; + return new Instrument[] {ins}; + } + public Instrument getInstrument(Patch patch) { + return null; + } + }; + assertTrue(!synth.isSoundbankSupported(dummysbk)); + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/LoadAllInstruments.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/LoadAllInstruments.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,73 @@ +/* + * 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 SoftSynthesizer loadAllInstruments method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Soundbank; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class LoadAllInstruments { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + Soundbank defsbk = synth.getDefaultSoundbank(); + if(defsbk != null) + { + assertTrue(synth.getLoadedInstruments().length == 0); + synth.unloadAllInstruments(defsbk); + SimpleSoundbank sbk = new SimpleSoundbank(); + SimpleInstrument ins = new SimpleInstrument(); + ins.setPatch(new Patch(0,1)); + sbk.addInstrument(ins); + SimpleInstrument ins2 = new SimpleInstrument(); + ins2.setPatch(new Patch(0,2)); + sbk.addInstrument(ins2); + synth.loadAllInstruments(sbk); + assertTrue(synth.getLoadedInstruments().length == 2); + } + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/LoadInstrument.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/LoadInstrument.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,73 @@ +/* + * 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 SoftSynthesizer loadAllInstrument method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Soundbank; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class LoadInstrument { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + Soundbank defsbk = synth.getDefaultSoundbank(); + if(defsbk != null) + { + assertTrue(synth.getLoadedInstruments().length == 0); + synth.unloadAllInstruments(defsbk); + SimpleSoundbank sbk = new SimpleSoundbank(); + SimpleInstrument ins = new SimpleInstrument(); + ins.setPatch(new Patch(0,1)); + sbk.addInstrument(ins); + SimpleInstrument ins2 = new SimpleInstrument(); + ins2.setPatch(new Patch(0,2)); + sbk.addInstrument(ins2); + synth.loadInstrument(ins2); + assertTrue(synth.getLoadedInstruments().length == 1); + } + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/LoadInstruments.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/LoadInstruments.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,73 @@ +/* + * 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 SoftSynthesizer loadAllInstruments method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Soundbank; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class LoadInstruments { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + Soundbank defsbk = synth.getDefaultSoundbank(); + if(defsbk != null) + { + assertTrue(synth.getLoadedInstruments().length == 0); + synth.unloadAllInstruments(defsbk); + SimpleSoundbank sbk = new SimpleSoundbank(); + SimpleInstrument ins = new SimpleInstrument(); + ins.setPatch(new Patch(0,1)); + sbk.addInstrument(ins); + SimpleInstrument ins2 = new SimpleInstrument(); + ins2.setPatch(new Patch(0,2)); + sbk.addInstrument(ins2); + synth.loadInstruments(sbk, new Patch[] {ins2.getPatch()}); + assertTrue(synth.getLoadedInstruments().length == 1); + } + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/Open.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/Open.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,58 @@ +/* + * 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 SoftSynthesizer open method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class Open { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.open(); + assertTrue(synth.isOpen()); + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/OpenStream.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/OpenStream.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,58 @@ +/* + * 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 SoftSynthesizer openStream method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class OpenStream { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + assertTrue(synth.isOpen()); + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/RemapInstrument.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/RemapInstrument.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,76 @@ +/* + * 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 SoftSynthesizer remapInstrument method */ + +import javax.sound.midi.Instrument; +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Soundbank; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class RemapInstrument { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + Soundbank defsbk = synth.getDefaultSoundbank(); + if(defsbk != null) + { + Instrument ins0 = defsbk.getInstrument(new Patch(0,0)); + Instrument ins10 = defsbk.getInstrument(new Patch(0,10)); + assertTrue(synth.remapInstrument(ins0, ins10)); + Instrument[] loaded = synth.getLoadedInstruments(); + for (int i = 0; i < loaded.length; i++) { + if(loaded[i].getPatch().getBank() == 0) + if(loaded[i].getPatch().getProgram() == 10) + { + assertEquals(loaded[i].getName(), ins0.getName()); + break; + } + } + + } + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/TestRender1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/TestRender1.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,210 @@ +/* + * 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 SoftSynthesizer simple note rendering in many settings */ + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.OutputStream; +import java.util.HashMap; +import java.util.Map; + +import javax.sound.sampled.*; +import javax.sound.midi.*; + +import com.sun.media.sound.*; + +public class TestRender1 { + + public static double send(Sequence seq, Receiver recv) { + float divtype = seq.getDivisionType(); + assert (seq.getDivisionType() == Sequence.PPQ); + Track[] tracks = seq.getTracks(); + int[] trackspos = new int[tracks.length]; + int mpq = 60000000 / 100; + int seqres = seq.getResolution(); + long lasttick = 0; + long curtime = 0; + while (true) { + MidiEvent selevent = null; + int seltrack = -1; + for (int i = 0; i < tracks.length; i++) { + int trackpos = trackspos[i]; + Track track = tracks[i]; + if (trackpos < track.size()) { + MidiEvent event = track.get(trackpos); + if (selevent == null + || event.getTick() < selevent.getTick()) { + selevent = event; + seltrack = i; + } + } + } + if (seltrack == -1) + break; + trackspos[seltrack]++; + long tick = selevent.getTick(); + if (divtype == Sequence.PPQ) + curtime += ((tick - lasttick) * mpq) / seqres; + else + curtime = (long) ((tick * 1000000.0 * divtype) / seqres); + lasttick = tick; + MidiMessage msg = selevent.getMessage(); + if (msg instanceof MetaMessage) { + if (divtype == Sequence.PPQ) + if (((MetaMessage) msg).getType() == 0x51) { + byte[] data = ((MetaMessage) msg).getData(); + mpq = ((data[0] & 0xff) << 16) + | ((data[1] & 0xff) << 8) | (data[2] & 0xff); + } + } else { + if (recv != null) + recv.send(msg, curtime); + } + } + + return curtime / 1000000.0; + } + + public static void test(AudioFormat format, Map info) + throws Exception { + OutputStream nullout = new OutputStream() { + public void write(int b) throws IOException { + } + + public void write(byte[] b, int off, int len) throws IOException { + } + + public void write(byte[] b) throws IOException { + } + }; + render(nullout, format, info); + } + + public static void render(OutputStream os, AudioFormat format, + Map info) throws Exception { + AudioSynthesizer synth = (AudioSynthesizer) new SoftSynthesizer(); + AudioInputStream stream = synth.openStream(format, info); + Receiver recv = synth.getReceiver(); + Soundbank defsbk = synth.getDefaultSoundbank(); + if (defsbk != null) + synth.unloadAllInstruments(defsbk); + synth.loadAllInstruments(soundbank); + + double totalTime = 5; + send(sequence, recv); + + long len = (long) (stream.getFormat().getFrameRate() * (totalTime + 4)); + stream = new AudioInputStream(stream, stream.getFormat(), len); + + long t = System.currentTimeMillis(); + AudioSystem.write(stream, AudioFileFormat.Type.WAVE, os); + t = System.currentTimeMillis() - t; + stream.close(); + } + + + static Soundbank soundbank; + + static Sequence sequence; + + public static void main(String[] args) throws Exception { + + File fb = new File(System.getProperty("test.src", "."), + "ding.sf2"); + InputStream sb = new FileInputStream(fb); + soundbank = MidiSystem.getSoundbank(sb); + sb.close(); + + File fi = new File(System.getProperty("test.src", "."), + "expresso.mid"); + InputStream si = new FileInputStream(fi); + sequence = MidiSystem.getSequence(si); + si.close(); + + AudioFormat format; + Map info = new HashMap(); + { + format = new AudioFormat(22050, 16, 2, true, false); + test(format, info); + format = new AudioFormat(44100, 16, 2, true, false); + test(format, info); + } + { + format = new AudioFormat(44100, 8, 2, true, false); + test(format, info); + format = new AudioFormat(44100, 16, 2, true, false); + test(format, info); + format = new AudioFormat(44100, 24, 2, true, false); + test(format, info); + } + { + format = new AudioFormat(44100, 16, 1, true, false); + test(format, info); + format = new AudioFormat(44100, 16, 2, true, false); + test(format, info); + } + { + format = new AudioFormat(44100, 16, 2, true, false); + + info.clear(); + info.put("control rate", 100f); + test(format, info); + info.clear(); + info.put("control rate", 147f); + test(format, info); + + } + { + format = new AudioFormat(44100, 16, 2, true, false); + + info.clear(); + info.put("interpolation", "point"); + test(format, info); + info.clear(); + info.put("interpolation", "linear"); + test(format, info); + info.clear(); + info.put("interpolation", "cubic"); + test(format, info); + } + { + format = new AudioFormat(44100, 16, 2, true, false); + info.clear(); + info.put("max polyphony", 4); + test(format, info); + info.clear(); + info.put("max polyphony", 16); + test(format, info); + info.clear(); + + } + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/UnloadAllInstruments.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/UnloadAllInstruments.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,69 @@ +/* + * 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 SoftSynthesizer unloadAllInstruments method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Soundbank; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class UnloadAllInstruments { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + Soundbank defsbk = synth.getDefaultSoundbank(); + if(defsbk != null) + { + assertTrue(synth.getLoadedInstruments().length == 0); + synth.unloadAllInstruments(defsbk); + assertTrue(synth.getAvailableInstruments().length == 0); + synth.loadAllInstruments(defsbk); + assertTrue(synth.getLoadedInstruments().length != 0); + synth.unloadAllInstruments(defsbk); + assertTrue(synth.getLoadedInstruments().length == 0); + } + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/UnloadInstrument.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/UnloadInstrument.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,75 @@ +/* + * 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 SoftSynthesizer unloadInstrument method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Soundbank; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class UnloadInstrument { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + Soundbank defsbk = synth.getDefaultSoundbank(); + if(defsbk != null) + { + assertTrue(synth.getLoadedInstruments().length == 0); + synth.unloadAllInstruments(defsbk); + SimpleSoundbank sbk = new SimpleSoundbank(); + SimpleInstrument ins = new SimpleInstrument(); + ins.setPatch(new Patch(0,1)); + sbk.addInstrument(ins); + SimpleInstrument ins2 = new SimpleInstrument(); + ins2.setPatch(new Patch(0,2)); + sbk.addInstrument(ins2); + synth.loadInstrument(ins2); + assertTrue(synth.getLoadedInstruments().length == 1); + synth.unloadInstrument(ins2); + assertTrue(synth.getLoadedInstruments().length == 0); + } + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/UnloadInstruments.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/UnloadInstruments.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,75 @@ +/* + * 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 SoftSynthesizer unloadInstruments method */ + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.midi.Soundbank; +import javax.sound.sampled.*; +import javax.sound.midi.MidiDevice.Info; + +import com.sun.media.sound.*; + +public class UnloadInstruments { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + AudioSynthesizer synth = new SoftSynthesizer(); + synth.openStream(null, null); + Soundbank defsbk = synth.getDefaultSoundbank(); + if(defsbk != null) + { + assertTrue(synth.getLoadedInstruments().length == 0); + synth.unloadAllInstruments(defsbk); + SimpleSoundbank sbk = new SimpleSoundbank(); + SimpleInstrument ins = new SimpleInstrument(); + ins.setPatch(new Patch(0,1)); + sbk.addInstrument(ins); + SimpleInstrument ins2 = new SimpleInstrument(); + ins2.setPatch(new Patch(0,2)); + sbk.addInstrument(ins2); + synth.loadInstrument(ins2); + assertTrue(synth.getLoadedInstruments().length == 1); + synth.unloadInstruments(sbk, new Patch[] {ins2.getPatch()}); + assertTrue(synth.getLoadedInstruments().length == 0); + } + synth.close(); + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/ding.sf2 Binary file overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/ding.sf2 has changed diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/expresso.mid Binary file overlays/openjdk/jdk/test/com/sun/media/sound/SoftSynthesizer/expresso.mid has changed diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/GetName.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/GetName.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,54 @@ +/* + * 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 SoftTuning getName method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetName { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTuning tuning = new SoftTuning(); + tuning.setName("custom"); + assertEquals(tuning.getName(), "custom"); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/GetTuning.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/GetTuning.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,56 @@ +/* + * 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 SoftTuning getTuning method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetTuning { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTuning tuning = new SoftTuning(); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) { + assertTrue(Math.abs(tunings[i]-i*100) < 0.00001); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/GetTuningInt.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/GetTuningInt.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,53 @@ +/* + * 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 SoftTuning getTuning(int) method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class GetTuningInt { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTuning tuning = new SoftTuning(); + assertTrue(Math.abs(tuning.getTuning(36)-3600) < 0.00001); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load1.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,101 @@ +/* + * 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 SoftTuning load method */ + +import java.io.UnsupportedEncodingException; + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Load1 { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + // http://www.midi.org/about-midi/tuning.shtml + // 0x01 BULK TUNING DUMP + SoftTuning tuning = new SoftTuning(); + byte[] name; + name = "Testing123 ".getBytes("ascii"); + + int[] msg = new int[24+3*128]; + int[] head = {0xf0,0x7e,0x7f,0x08,0x01,0x00}; + int ox = 0; + for (int i = 0; i < head.length; i++) + msg[ox++] = head[i]; + for (int i = 0; i < name.length; i++) + msg[ox++] = name[i]; + for (int i = 0; i < 128; i++) { + msg[ox++] = i; + msg[ox++] = 64; + msg[ox++] = 0; + } + + // Calc checksum + int x = msg[1] & 0xFF; // 7E + x = x ^ (msg[2] & 0xFF); // + x = x ^ (msg[4] & 0xFF); // nn + x = x ^ (msg[5] & 0xFF); // tt + for (int i = 22; i < msg.length - 2; i++) + x = x ^ (msg[i] & 0xFF); + msg[ox++] = (x & 127); + + msg[ox++] = 0xf7; + byte[] bmsg = new byte[msg.length]; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + + tuning.load(bmsg); + assertEquals(tuning.getName(), "Testing123 "); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) + assertTrue(Math.abs(tunings[i]-(i*100 + 50)) < 0.00001); + + // Check if tuning fails if checksum is wrong + /* + msg[msg.length - 2] += 10; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + tuning = new SoftTuning(); + tuning.load(bmsg); + assertTrue(!tuning.getName().equals("Testing123 ")); + */ + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load2.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,71 @@ +/* + * 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 SoftTuning load method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Load2 { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + // http://www.midi.org/about-midi/tuning.shtml + // 0x02 SINGLE NOTE TUNING CHANGE (REAL-TIME) + SoftTuning tuning = new SoftTuning(); + int[] msg = {0xf0,0x7f,0x7f,0x08,0x02,0x10,0x02, + 36,36,64,0, + 40,70,0,0, + 0xf7}; + byte[] bmsg = new byte[msg.length]; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + tuning.load(bmsg); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) { + if(i == 36) + assertTrue(Math.abs(tunings[i]-3650)< 0.00001); + else if(i == 40) + assertTrue(Math.abs(tunings[i]-7000) < 0.00001); + else + assertTrue(Math.abs(tunings[i]-i*100) < 0.00001); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load4.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load4.java Sun May 25 21:21:11 2008 +0200 @@ -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 SoftTuning load method */ + +import java.io.UnsupportedEncodingException; + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Load4 { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + // http://www.midi.org/about-midi/tuning_extens.shtml + // 0x04 KEY-BASED TUNING DUMP + SoftTuning tuning = new SoftTuning(); + byte[] name; + name = "Testing123 ".getBytes("ascii"); + + int[] msg = new int[25+3*128]; + int[] head = {0xf0,0x7e,0x7f,0x08,0x04,0x00,0x00}; + int ox = 0; + for (int i = 0; i < head.length; i++) + msg[ox++] = head[i]; + for (int i = 0; i < name.length; i++) + msg[ox++] = name[i]; + for (int i = 0; i < 128; i++) { + msg[ox++] = i; + msg[ox++] = 64; + msg[ox++] = 0; + } + + // Calc checksum + int x = msg[1] & 0xFF; + for (int i = 2; i < msg.length - 2; i++) + x = x ^ (msg[i] & 0xFF); + msg[ox++] = (x & 127); + + msg[ox++] = 0xf7; + byte[] bmsg = new byte[msg.length]; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + + tuning.load(bmsg); + assertEquals(tuning.getName(), "Testing123 "); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) + assertTrue(Math.abs(tunings[i]-(i*100 + 50)) < 0.00001); + + // Check if tuning fails if checksum is wrong + msg[msg.length - 2] += 10; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + tuning = new SoftTuning(); + tuning.load(bmsg); + assertTrue(!tuning.getName().equals("Testing123 ")); + + // Check if tuning fails if checksum is wrong + msg[msg.length - 2] += 10; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + tuning = new SoftTuning(); + tuning.load(bmsg); + assertTrue(!tuning.getName().equals("Testing123 ")); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load5.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load5.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,87 @@ +/* + * 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 SoftTuning load method */ + +import java.io.UnsupportedEncodingException; + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Load5 { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + // http://www.midi.org/about-midi/tuning_extens.shtml + // 0x05 SCALE/OCTAVE TUNING DUMP, 1 byte format + SoftTuning tuning = new SoftTuning(); + + byte[] name; + name = "Testing123 ".getBytes("ascii"); + int[] msg = {0xf0,0x7e,0x7f,0x08,0x05,0,0, + name[0],name[1],name[2],name[3],name[4],name[5],name[6], + name[7],name[8],name[9],name[10],name[11],name[12],name[13], + name[14],name[15], + 5,10,15,20,25,30,35,40,45,50,51,52,0, + 0xf7}; + // Calc checksum + int x = msg[1] & 0xFF; + for (int i = 2; i < msg.length - 2; i++) + x = x ^ (msg[i] & 0xFF); + msg[msg.length-2] = (x & 127); + + int[] oct = {5,10,15,20,25,30,35,40,45,50,51,52}; + byte[] bmsg = new byte[msg.length]; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + tuning.load(bmsg); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) + assertTrue(Math.abs(tunings[i]-(i*100 + (oct[i%12]-64))) < 0.00001); + + // Check if tuning fails if checksum is wrong + msg[msg.length - 2] += 10; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + tuning = new SoftTuning(); + tuning.load(bmsg); + assertTrue(!tuning.getName().equals("Testing123 ")); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load6.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load6.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,91 @@ +/* + * 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 SoftTuning load method */ + +import java.io.UnsupportedEncodingException; + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Load6 { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + // http://www.midi.org/about-midi/tuning_extens.shtml + // 0x06 SCALE/OCTAVE TUNING DUMP, 2 byte format + SoftTuning tuning = new SoftTuning(); + + byte[] name; + name = "Testing123 ".getBytes("ascii"); + int[] msg = {0xf0,0x7e,0x7f,0x08,0x06,0,0, + name[0],name[1],name[2],name[3],name[4],name[5],name[6], + name[7],name[8],name[9],name[10],name[11],name[12],name[13], + name[14],name[15], + 5,10,15,20,25,30,35,40,45,50,51,52, + 5,10,15,20,25,30,35,40,45,50,51,52, + 0,0xf7}; + // Calc checksum + int x = msg[1] & 0xFF; + for (int i = 2; i < msg.length - 2; i++) + x = x ^ (msg[i] & 0xFF); + msg[msg.length-2] = (x & 127); + + int[] oct = {5,10,15,20,25,30,35,40,45,50,51,52,5,10,15,20,25,30,35,40,45,50,51,52}; + byte[] bmsg = new byte[msg.length]; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + tuning.load(bmsg); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) + { + double c = (oct[(i%12)*2]*128 + oct[(i%12)*2+1] -8192)*(100.0/8192.0); + assertTrue(Math.abs(tunings[i]-(i*100 + (c))) < 0.00001); + } + + // Check if tuning fails if checksum is wrong + msg[msg.length - 2] += 10; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + tuning = new SoftTuning(); + tuning.load(bmsg); + assertTrue(!tuning.getName().equals("Testing123 ")); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load7.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load7.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,72 @@ +/* + * 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 SoftTuning load method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Load7 { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + // http://www.midi.org/about-midi/tuning_extens.shtml + // 0x07 SINGLE NOTE TUNING CHANGE (NON REAL-TIME) (BANK) + SoftTuning tuning = new SoftTuning(); + int[] msg = {0xf0,0x7f,0x7f,0x08,0x07,0x00,0x00,0x02, + 36,36,64,0, + 40,70,0,0, + 0xf7}; + byte[] bmsg = new byte[msg.length]; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + tuning.load(bmsg); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) { + if(i == 36) + assertTrue(Math.abs(tunings[i]-3650)< 0.00001); + else if(i == 40) + assertTrue(Math.abs(tunings[i]-7000) < 0.00001); + else + assertTrue(Math.abs(tunings[i]-i*100) < 0.00001); + } + + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load8.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load8.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,65 @@ +/* + * 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 SoftTuning load method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Load8 { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + // http://www.midi.org/about-midi/tuning-scale.shtml + // 0x08 scale/octave tuning 1-byte form (Non Real-Time/REAL-TIME) + SoftTuning tuning = new SoftTuning(); + int[] msg = {0xf0,0x7f,0x7f,0x08,0x08,0x03,0x7f,0x7f, + 5,10,15,20,25,30,35,40,45,50,51,52, + 0xf7}; + int[] oct = {5,10,15,20,25,30,35,40,45,50,51,52}; + byte[] bmsg = new byte[msg.length]; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + tuning.load(bmsg); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) + assertTrue(Math.abs(tunings[i]-(i*100 + (oct[i%12]-64))) < 0.00001); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load9.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/Load9.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,69 @@ +/* + * 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 SoftTuning load method */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class Load9 { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + // http://www.midi.org/about-midi/tuning-scale.shtml + // 0x09 scale/octave tuning 2-byte form (Non Real-Time/REAL-TIME) + SoftTuning tuning = new SoftTuning(); + int[] msg = {0xf0,0x7f,0x7f,0x08,0x09,0x03,0x7f,0x7f, + 5,10,15,20,25,30,35,40,45,50,51,52, + 5,10,15,20,25,30,35,40,45,50,51,52, + 0xf7}; + int[] oct = {5,10,15,20,25,30,35,40,45,50,51,52,5,10,15,20,25,30,35,40,45,50,51,52}; + byte[] bmsg = new byte[msg.length]; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + tuning.load(bmsg); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) + { + double c = (oct[(i%12)*2]*128 + oct[(i%12)*2+1] -8192)*(100.0/8192.0); + assertTrue(Math.abs(tunings[i]-(i*100 + (c))) < 0.00001); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/NewSoftTuning.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/NewSoftTuning.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,56 @@ +/* + * 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 SoftTuning constructor */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewSoftTuning { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTuning tuning = new SoftTuning(); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) { + assertTrue(Math.abs(tunings[i]-i*100) < 0.00001); + } + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/NewSoftTuningByteArray.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/NewSoftTuningByteArray.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,63 @@ +/* + * 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 SoftTuning constructor */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewSoftTuningByteArray { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + // RealTime: Scale/Octave tuning in 1-byte format + int[] msg = {0xf0,0x7f,0x7f,0x08,0x08,0x03,0x7f,0x7f, + 5,10,15,20,25,30,35,40,45,50,51,52, + 0xf7}; + int[] oct = {5,10,15,20,25,30,35,40,45,50,51,52}; + byte[] bmsg = new byte[msg.length]; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + SoftTuning tuning = new SoftTuning(bmsg); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) + assertTrue(Math.abs(tunings[i]-(i*100 + (oct[i%12]-64))) < 0.00001); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/NewSoftTuningPatch.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/NewSoftTuningPatch.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,54 @@ +/* + * 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 SoftTuning constructor */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewSoftTuningPatch { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + SoftTuning tuning = new SoftTuning(new Patch(8,32)); + assertEquals(tuning.getPatch().getProgram(), 32); + assertEquals(tuning.getPatch().getBank(), 8); + } +} diff -r d72271b9d9ef -r a1832ea486e9 overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/NewSoftTuningPatchByteArray.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/overlays/openjdk/jdk/test/com/sun/media/sound/SoftTuning/NewSoftTuningPatchByteArray.java Sun May 25 21:21:11 2008 +0200 @@ -0,0 +1,65 @@ +/* + * 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 SoftTuning constructor */ + +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.Patch; +import javax.sound.sampled.*; + +import com.sun.media.sound.*; + +public class NewSoftTuningPatchByteArray { + + private static void assertEquals(Object a, Object b) throws Exception + { + if(!a.equals(b)) + throw new RuntimeException("assertEquals fails!"); + } + + private static void assertTrue(boolean value) throws Exception + { + if(!value) + throw new RuntimeException("assertTrue fails!"); + } + + public static void main(String[] args) throws Exception { + // RealTime: Scale/Octave tuning in 1-byte format + int[] msg = {0xf0,0x7f,0x7f,0x08,0x08,0x03,0x7f,0x7f, + 5,10,15,20,25,30,35,40,45,50,51,52, + 0xf7}; + int[] oct = {5,10,15,20,25,30,35,40,45,50,51,52}; + byte[] bmsg = new byte[msg.length]; + for (int i = 0; i < bmsg.length; i++) + bmsg[i] = (byte)msg[i]; + SoftTuning tuning = new SoftTuning(new Patch(8,32),bmsg); + double[] tunings = tuning.getTuning(); + for (int i = 0; i < tunings.length; i++) + assertTrue(Math.abs(tunings[i]-(i*100 + (oct[i%12]-64))) < 0.00001); + assertEquals(tuning.getPatch().getProgram(), 32); + assertEquals(tuning.getPatch().getBank(), 8); + } +}