Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/sound/midi/Gervill/SoftChannel/ResetAllControllers.java
38861 views
/*1* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* @test24@summary Test SoftChannel resetAllControllers method */2526import javax.sound.midi.*;27import javax.sound.sampled.*;2829import com.sun.media.sound.*;3031public class ResetAllControllers {3233public static boolean[] dontResetControls = new boolean[128];34static {35for (int i = 0; i < dontResetControls.length; i++)36dontResetControls[i] = false;3738dontResetControls[0] = true; // Bank Select (MSB)39dontResetControls[32] = true; // Bank Select (LSB)40dontResetControls[7] = true; // Channel Volume (MSB)41dontResetControls[8] = true; // Balance (MSB)42dontResetControls[10] = true; // Pan (MSB)43dontResetControls[11] = true; // Expression (MSB)44dontResetControls[91] = true; // Effects 1 Depth (default: Reverb Send)45dontResetControls[92] = true; // Effects 2 Depth (default: Tremolo Depth)46dontResetControls[93] = true; // Effects 3 Depth (default: Chorus Send)47dontResetControls[94] = true; // Effects 4 Depth (default: Celeste [Detune] Depth)48dontResetControls[95] = true; // Effects 5 Depth (default: Phaser Depth)49dontResetControls[70] = true; // Sound Controller 1 (default: Sound Variation)50dontResetControls[71] = true; // Sound Controller 2 (default: Timbre / Harmonic Quality)51dontResetControls[72] = true; // Sound Controller 3 (default: Release Time)52dontResetControls[73] = true; // Sound Controller 4 (default: Attack Time)53dontResetControls[74] = true; // Sound Controller 5 (default: Brightness)54dontResetControls[75] = true; // Sound Controller 6 (GM2 default: Decay Time)55dontResetControls[76] = true; // Sound Controller 7 (GM2 default: Vibrato Rate)56dontResetControls[77] = true; // Sound Controller 8 (GM2 default: Vibrato Depth)57dontResetControls[78] = true; // Sound Controller 9 (GM2 default: Vibrato Delay)58dontResetControls[79] = true; // Sound Controller 10 (GM2 default: Undefined)59dontResetControls[120] = true; // All Sound Off60dontResetControls[121] = true; // Reset All Controllers61dontResetControls[122] = true; // Local Control On/Off62dontResetControls[123] = true; // All Notes Off63dontResetControls[124] = true; // Omni Mode Off64dontResetControls[125] = true; // Omni Mode On65dontResetControls[126] = true; // Poly Mode Off66dontResetControls[127] = true; // Poly Mode On6768dontResetControls[6] = true; // Data Entry (MSB)69dontResetControls[38] = true; // Data Entry (LSB)70dontResetControls[96] = true; // Data Increment71dontResetControls[97] = true; // Data Decrement72dontResetControls[98] = true; // Non-Registered Parameter Number (LSB)73dontResetControls[99] = true; // Non-Registered Parameter Number(MSB)74dontResetControls[100] = true; // RPN = Null75dontResetControls[101] = true; // RPN = Null76}7778private static void assertEquals(Object a, Object b) throws Exception79{80if(!a.equals(b))81throw new RuntimeException("assertEquals fails!");82}8384private static void assertTrue(boolean value) throws Exception85{86if(!value)87throw new RuntimeException("assertTrue fails!");88}8990public static void main(String[] args) throws Exception {91SoftTestUtils soft = new SoftTestUtils();92MidiChannel channel = soft.synth.getChannels()[0];9394// First let all controls contain non-default values95for (int i = 0; i < 128; i++)96channel.setPolyPressure(i, 10);97channel.setChannelPressure(10);98channel.setPitchBend(2192);99for (int i = 0; i < 120; i++)100channel.controlChange(i, 1);101channel.resetAllControllers();102103// Now check if resetAllControllers did what it was suppose to do104105for (int i = 0; i < 128; i++)106assertEquals(channel.getPolyPressure(i), 0);107assertEquals(channel.getChannelPressure(), 0);108assertEquals(channel.getPitchBend(),8192);109for (int i = 0; i < 120; i++)110if(!dontResetControls[i])111assertEquals(channel.getController(i), 0);112assertEquals(channel.getController(71), 64); // Filter Resonance113assertEquals(channel.getController(72), 64); // Release Time114assertEquals(channel.getController(73), 64); // Attack Time115assertEquals(channel.getController(74), 64); // Brightness116assertEquals(channel.getController(75), 64); // Decay Time117assertEquals(channel.getController(76), 64); // Vibrato Rate118assertEquals(channel.getController(77), 64); // Vibrato Depth119assertEquals(channel.getController(78), 64); // Vibrato Delay120assertEquals(channel.getController(8), 64); // Balance121assertEquals(channel.getController(11), 127); // Expression122assertEquals(channel.getController(98), 127); // NRPN Null123assertEquals(channel.getController(99), 127); // NRPN Null124assertEquals(channel.getController(100), 127); // RPN = Null125assertEquals(channel.getController(101), 127); // RPN = Null126127soft.close();128}129}130131132