Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/sound/midi/Gervill/SimpleInstrument/SetPatch.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 SimpleInstrument setPatch(Patch) method */2526import javax.sound.midi.Patch;27import javax.sound.sampled.*;2829import com.sun.media.sound.*;3031public class SetPatch {3233private static void assertEquals(Object a, Object b) throws Exception34{35if(!a.equals(b))36throw new RuntimeException("assertEquals fails!");37}3839public static void main(String[] args) throws Exception {4041SimpleInstrument instrument = new SimpleInstrument();4243ModelPerformer[] performers = new ModelPerformer[2];4445performers[0] = new ModelPerformer();46performers[0].setExclusiveClass(1);47performers[0].setKeyFrom(36);48performers[0].setKeyTo(48);49performers[0].setVelFrom(16);50performers[0].setVelTo(80);51performers[0].setSelfNonExclusive(true);52performers[0].setDefaultConnectionsEnabled(false);53performers[0].getConnectionBlocks().add(new ModelConnectionBlock());54performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3})));5556performers[1] = new ModelPerformer();57performers[1].setExclusiveClass(0);58performers[1].setKeyFrom(12);59performers[1].setKeyTo(24);60performers[1].setVelFrom(20);61performers[1].setVelTo(90);62performers[1].setSelfNonExclusive(false);63performers[0].setDefaultConnectionsEnabled(true);64performers[1].getConnectionBlocks().add(new ModelConnectionBlock());65performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3})));6667Patch patch = new Patch(0,36);68instrument.setPatch(patch);69assertEquals(instrument.getPatch().getProgram(), patch.getProgram());70assertEquals(instrument.getPatch().getBank(), patch.getBank());71}72}737475