Mercurial > hg > release > icedtea-1.10
view overlays/openjdk/jdk/test/com/sun/media/sound/SoftLowFrequencyOscillator/TestProcessControlLogic.java @ 1822:b443c3bc7e25
Import Gervill fixes from CVS. See CHANGES.txt:
6823446: Gervill SoftLowFrequencyOscillator fails when freq is
set to 0 cent or 8.1758 Hz.
6823445: Gervill SoftChannel/ResetAllControllers jtreg test
fails after portamento fix from last merge.
6821030: Merge OpenJDK Gervill with upstream sources, Q1CY2009
- Fix: Notes get stuck on when we overflow the synthesizer
with rapid note on /off messages.
JTreg test has been created:
test/com/sun/media/sound/SoftChannel/NoteOverFlowTest
- Fix: Portamento controller reset to wrong value in
SoftChannel.resetAllControllers.
This caused incorrect glider effect in some midi files.
For example in TuningApplet1 in TET-7 keyboard,
when note was pressed for first time a glider effect could be
heard.
- Fix: Delay modulation calculation in SoftChorus.LFODelay where
incorrect.
- Fix: Removed unnecessary volatile keywords in SoftChorus.
* fsg.sh: Don't remove (non-existing) com/sun/media/sound services.
* overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/services:
removed.
author | Mark Wielaard <mark@klomp.org> |
---|---|
date | Fri, 22 May 2009 16:55:42 +0200 |
parents | |
children |
line wrap: on
line source
/* * Copyright 2009 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 SoftLowFrequencyOscillator processControlLogic method */ import com.sun.media.sound.AudioSynthesizerPropertyInfo; import com.sun.media.sound.SoftLowFrequencyOscillator; import com.sun.media.sound.SoftSynthesizer; public class TestProcessControlLogic { private static float control_rate = 147f; private static SoftSynthesizer synth = new SoftSynthesizer(); private static SoftLowFrequencyOscillator lfo = new SoftLowFrequencyOscillator(); private static void testLFO(boolean shared, int instance, float freq, float delay, float delay2) throws Exception { SoftLowFrequencyOscillator lfo = shared?TestProcessControlLogic.lfo:new SoftLowFrequencyOscillator(); lfo.reset(); double[] lfo_freq = lfo.get(instance, "freq"); double[] lfo_delay = lfo.get(instance, "delay"); double[] lfo_delay2 = lfo.get(instance, "delay2"); double[] lfo_output = lfo.get(instance, null); lfo_freq[0] = freq; lfo_delay[0] = delay; lfo_delay2[0] = delay2; lfo.init(synth); // For delayCount amount time, the output LFO should be 0.5 int delayCount = (int) ((Math.pow(2, delay / 1200.0) * control_rate)); delayCount += (int) ((delay2 * control_rate) / 1000.0); for (int i = 0; i < delayCount; i++) { if (Math.abs(0.5 - lfo_output[0]) > 0.000001) throw new Exception("Incorrect LFO output (" +"0.5 != "+lfo_output[0]+")!"); lfo.processControlLogic(); } // After the delay the LFO should start oscillate // Let make sure output is accurate enough double p_step = (440.0 / control_rate) * Math.exp((freq - 6900.0) * (Math.log(2) / 1200.0)); double p = 0; for (int i = 0; i < 30; i++) { p += p_step; double predicted_output = 0.5 + Math.sin(p * 2 * Math.PI) * 0.5; if (Math.abs(predicted_output - lfo_output[0]) > 0.001) throw new Exception("Incorrect LFO output (" +predicted_output+" != "+lfo_output[0]+")!"); lfo.processControlLogic(); } } public static void main(String[] args) throws Exception { // Get default control rate from synthesizer AudioSynthesizerPropertyInfo[] p = synth.getPropertyInfo(null); for (int i = 0; i < p.length; i++) { if (p[i].name.equals("control rate")) { control_rate = ((Float) p[i].value).floatValue(); break; } } // Test LFO under various configurations for (int instance = 0; instance < 3; instance++) for (int d1 = -3000; d1 < 0; d1 += 1000) for (int d2 = 0; d2 < 5000; d2 += 1000) for (int fr = -1000; fr < 1000; fr += 100) { testLFO(true, instance, (fr == -1000) ? Float.NEGATIVE_INFINITY : fr, (d1 == -3000) ? Float.NEGATIVE_INFINITY : d1, d2); testLFO(false, instance, (fr == -1000) ? Float.NEGATIVE_INFINITY : fr, (d1 == -3000) ? Float.NEGATIVE_INFINITY : d1, d2); } } }