AddModelPerformerIntInt.java revision 829
4632N/A/*
4632N/A * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
4632N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4632N/A *
4632N/A * This code is free software; you can redistribute it and/or modify it
4632N/A * under the terms of the GNU General Public License version 2 only, as
4632N/A * published by the Free Software Foundation. Sun designates this
4632N/A * particular file as subject to the "Classpath" exception as provided
4632N/A * by Sun in the LICENSE file that accompanied this code.
4632N/A *
4632N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4632N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4632N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4632N/A * version 2 for more details (a copy is included in the LICENSE file that
4632N/A * accompanied this code).
4632N/A *
4632N/A * You should have received a copy of the GNU General Public License version
4632N/A * 2 along with this work; if not, write to the Free Software Foundation,
4632N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4632N/A *
4632N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
4632N/A * CA 95054 USA or visit www.sun.com if you need additional information or
4632N/A * have any questions.
4632N/A */
4632N/A
4632N/A/* @test
4632N/A @summary Test SimpleInstrument add(ModelPerformer,int,int) method */
4632N/A
4632N/Aimport javax.sound.sampled.*;
4632N/A
4632N/Aimport com.sun.media.sound.*;
4632N/A
4632N/Apublic class AddModelPerformerIntInt {
4632N/A
4632N/A private static void assertEquals(Object a, Object b) throws Exception
4632N/A {
4632N/A if(!a.equals(b))
4632N/A throw new RuntimeException("assertEquals fails!");
4632N/A }
4632N/A
4632N/A public static void main(String[] args) throws Exception {
4632N/A
4632N/A SimpleInstrument instrument = new SimpleInstrument();
4632N/A
4632N/A ModelPerformer[] performers = new ModelPerformer[2];
4632N/A
4632N/A performers[0] = new ModelPerformer();
4632N/A performers[0].setExclusiveClass(1);
4632N/A performers[0].setKeyFrom(36);
4632N/A performers[0].setKeyTo(48);
4632N/A performers[0].setVelFrom(16);
4632N/A performers[0].setVelTo(80);
4632N/A performers[0].setSelfNonExclusive(true);
4632N/A performers[0].setDefaultConnectionsEnabled(false);
4632N/A performers[0].getConnectionBlocks().add(new ModelConnectionBlock());
4632N/A performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3})));
4632N/A
4632N/A performers[1] = new ModelPerformer();
4632N/A performers[1].setExclusiveClass(0);
4632N/A performers[1].setKeyFrom(12);
4632N/A performers[1].setKeyTo(24);
4632N/A performers[1].setVelFrom(20);
4632N/A performers[1].setVelTo(90);
4632N/A performers[1].setSelfNonExclusive(false);
4632N/A performers[0].setDefaultConnectionsEnabled(true);
4632N/A performers[1].getConnectionBlocks().add(new ModelConnectionBlock());
4632N/A performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3})));
4632N/A
4632N/A instrument.add(performers[0],18,40);
4632N/A ModelPerformer[] performers2 = instrument.getPerformers();
4632N/A for (int i = 0; i < performers2.length; i++) {
4632N/A assertEquals(performers[i].getConnectionBlocks(), performers2[i].getConnectionBlocks());
4632N/A assertEquals(performers[i].getExclusiveClass(), performers2[i].getExclusiveClass());
4632N/A if(performers[i].getKeyFrom() < 18)
4632N/A assertEquals(18, performers2[i].getKeyFrom());
4632N/A else
4632N/A assertEquals(performers[i].getKeyFrom(), performers2[i].getKeyFrom());
4632N/A if(performers[i].getKeyTo() > 40)
4632N/A assertEquals(40, performers2[i].getKeyTo());
4632N/A else
4632N/A assertEquals(performers[i].getKeyTo(), performers2[i].getKeyTo());
4632N/A assertEquals(performers[i].getVelFrom(), performers2[i].getVelFrom());
4632N/A assertEquals(performers[i].getVelTo(), performers2[i].getVelTo());
4632N/A assertEquals(performers[i].getOscillators(), performers2[i].getOscillators());
4632N/A assertEquals(performers[i].isSelfNonExclusive(), performers2[i].isSelfNonExclusive());
4632N/A assertEquals(performers[i].isDefaultConnectionsEnabled(), performers2[i].isDefaultConnectionsEnabled());
4632N/A }
4632N/A }
4632N/A}
4632N/A