SetPatch.java revision 829:b06c29386f63
1212904Sdim/* 2193326Sed * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 3193326Sed * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4193326Sed * 5193326Sed * This code is free software; you can redistribute it and/or modify it 6193326Sed * under the terms of the GNU General Public License version 2 only, as 7193326Sed * published by the Free Software Foundation. Sun designates this 8193326Sed * particular file as subject to the "Classpath" exception as provided 9193326Sed * by Sun in the LICENSE file that accompanied this code. 10193326Sed * 11193326Sed * This code is distributed in the hope that it will be useful, but WITHOUT 12193326Sed * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13193326Sed * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14199482Srdivacky * version 2 for more details (a copy is included in the LICENSE file that 15193326Sed * accompanied this code). 16193326Sed * 17208961Srdivacky * You should have received a copy of the GNU General Public License version 18249423Sdim * 2 along with this work; if not, write to the Free Software Foundation, 19249423Sdim * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20243830Sdim * 21249423Sdim * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 22193326Sed * CA 95054 USA or visit www.sun.com if you need additional information or 23199482Srdivacky * have any questions. 24199482Srdivacky */ 25199482Srdivacky 26200583Srdivacky/* @test 27228379Sdim @summary Test SimpleInstrument setPatch(Patch) method */ 28251662Sdim 29218893Sdimimport javax.sound.midi.Patch; 30249423Sdimimport javax.sound.sampled.*; 31234353Sdim 32193326Sedimport com.sun.media.sound.*; 33199482Srdivacky 34193326Sedpublic class SetPatch { 35199482Srdivacky 36199482Srdivacky private static void assertEquals(Object a, Object b) throws Exception 37199482Srdivacky { 38199482Srdivacky if(!a.equals(b)) 39199482Srdivacky throw new RuntimeException("assertEquals fails!"); 40199482Srdivacky } 41219077Sdim 42219077Sdim public static void main(String[] args) throws Exception { 43219077Sdim 44239462Sdim SimpleInstrument instrument = new SimpleInstrument(); 45224145Sdim 46199482Srdivacky ModelPerformer[] performers = new ModelPerformer[2]; 47218893Sdim 48249423Sdim performers[0] = new ModelPerformer(); 49199482Srdivacky performers[0].setExclusiveClass(1); 50199482Srdivacky performers[0].setKeyFrom(36); 51199482Srdivacky performers[0].setKeyTo(48); 52226633Sdim performers[0].setVelFrom(16); 53218893Sdim performers[0].setVelTo(80); 54249423Sdim performers[0].setSelfNonExclusive(true); 55218893Sdim performers[0].setDefaultConnectionsEnabled(false); 56199482Srdivacky performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); 57249423Sdim performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); 58249423Sdim 59249423Sdim performers[1] = new ModelPerformer(); 60199482Srdivacky performers[1].setExclusiveClass(0); 61249423Sdim performers[1].setKeyFrom(12); 62249423Sdim performers[1].setKeyTo(24); 63249423Sdim performers[1].setVelFrom(20); 64249423Sdim performers[1].setVelTo(90); 65249423Sdim performers[1].setSelfNonExclusive(false); 66239462Sdim performers[0].setDefaultConnectionsEnabled(true); 67239462Sdim performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); 68239462Sdim performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); 69239462Sdim 70239462Sdim Patch patch = new Patch(0,36); 71239462Sdim instrument.setPatch(patch); 72208600Srdivacky assertEquals(instrument.getPatch().getProgram(), patch.getProgram()); 73199482Srdivacky assertEquals(instrument.getPatch().getBank(), patch.getBank()); 74226633Sdim } 75226633Sdim} 76226633Sdim