Mercurial > hg > release > icedtea-1.10
view overlays/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.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 | 5a126447fc2c |
children |
line wrap: on
line source
/* * 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. */ package com.sun.media.sound; /** * LFO control signal generator. * * @author Karl Helgason */ public class SoftLowFrequencyOscillator implements SoftProcess { private int max_count = 10; private int used_count = 0; private double[][] out = new double[max_count][1]; private double[][] delay = new double[max_count][1]; private double[][] delay2 = new double[max_count][1]; private double[][] freq = new double[max_count][1]; private int[] delay_counter = new int[max_count]; private double[] sin_phase = new double[max_count]; private double[] sin_stepfreq = new double[max_count]; private double[] sin_step = new double[max_count]; private double control_time = 0; private double sin_factor = 0; private static double PI2 = 2.0 * Math.PI; public SoftLowFrequencyOscillator() { // If sin_step is 0 then sin_stepfreq must be -INF for (int i = 0; i < sin_stepfreq.length; i++) { sin_stepfreq[i] = Double.NEGATIVE_INFINITY; } } public void reset() { for (int i = 0; i < used_count; i++) { out[i][0] = 0; delay[i][0] = 0; delay2[i][0] = 0; freq[i][0] = 0; delay_counter[i] = 0; sin_phase[i] = 0; // If sin_step is 0 then sin_stepfreq must be -INF sin_stepfreq[i] = Double.NEGATIVE_INFINITY; sin_step[i] = 0; } used_count = 0; } public void init(SoftSynthesizer synth) { control_time = 1.0 / synth.getControlRate(); sin_factor = control_time * 2 * Math.PI; for (int i = 0; i < used_count; i++) { delay_counter[i] = (int)(Math.pow(2, this.delay[i][0] / 1200.0) / control_time); delay_counter[i] += (int)(delay2[i][0] / (control_time * 1000)); } processControlLogic(); } public void processControlLogic() { for (int i = 0; i < used_count; i++) { if (delay_counter[i] > 0) { delay_counter[i]--; out[i][0] = 0.5; } else { double f = freq[i][0]; if (sin_stepfreq[i] != f) { sin_stepfreq[i] = f; double fr = 440.0 * Math.exp( (f - 6900.0) * (Math.log(2) / 1200.0)); sin_step[i] = fr * sin_factor; } /* double fr = 440.0 * Math.pow(2.0, (freq[i][0] - 6900.0) / 1200.0); sin_phase[i] += fr * sin_factor; */ /* sin_phase[i] += sin_step[i]; while (sin_phase[i] > PI2) sin_phase[i] -= PI2; out[i][0] = 0.5 + Math.sin(sin_phase[i]) * 0.5; */ double p = sin_phase[i]; p += sin_step[i]; while (p > PI2) p -= PI2; out[i][0] = 0.5 + Math.sin(p) * 0.5; sin_phase[i] = p; } } } public double[] get(int instance, String name) { if (instance >= used_count) used_count = instance + 1; if (name == null) return out[instance]; if (name.equals("delay")) return delay[instance]; if (name.equals("delay2")) return delay2[instance]; if (name.equals("freq")) return freq[instance]; return null; } }