Send_Mono.java revision 8729:0242fce0f717
1250003Sadrian/* 2250003Sadrian * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. 3250003Sadrian * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4250003Sadrian * 5250003Sadrian * This code is free software; you can redistribute it and/or modify it 6250003Sadrian * under the terms of the GNU General Public License version 2 only, as 7250003Sadrian * published by the Free Software Foundation. 8250003Sadrian * 9250003Sadrian * This code is distributed in the hope that it will be useful, but WITHOUT 10250003Sadrian * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11250003Sadrian * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12250003Sadrian * version 2 for more details (a copy is included in the LICENSE file that 13250003Sadrian * accompanied this code). 14250003Sadrian * 15250003Sadrian * You should have received a copy of the GNU General Public License version 16250003Sadrian * 2 along with this work; if not, write to the Free Software Foundation, 17250003Sadrian * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18250003Sadrian * 19250003Sadrian * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20250003Sadrian * or visit www.oracle.com if you need additional information or have any 21250003Sadrian * questions. 22250003Sadrian */ 23250003Sadrian 24250003Sadrian/* @test 25250003Sadrian @summary Test SoftReceiver send method */ 26250003Sadrian 27250003Sadrianimport javax.sound.midi.*; 28250003Sadrianimport javax.sound.sampled.*; 29250003Sadrian 30250003Sadrianimport com.sun.media.sound.*; 31250003Sadrian 32250003Sadrianpublic class Send_Mono { 33250003Sadrian 34250003Sadrian private static void assertEquals(Object a, Object b) throws Exception 35250003Sadrian { 36250003Sadrian if(!a.equals(b)) 37250003Sadrian throw new RuntimeException("assertEquals fails!"); 38250003Sadrian } 39250003Sadrian 40250003Sadrian private static void assertTrue(boolean value) throws Exception 41250003Sadrian { 42250003Sadrian if(!value) 43250003Sadrian throw new RuntimeException("assertTrue fails!"); 44250003Sadrian } 45250003Sadrian 46250003Sadrian public static void main(String[] args) throws Exception { 47250003Sadrian SoftTestUtils soft = new SoftTestUtils(); 48250003Sadrian MidiChannel channel = soft.synth.getChannels()[0]; 49250003Sadrian Receiver receiver = soft.synth.getReceiver(); 50250003Sadrian 51250003Sadrian ShortMessage smsg = new ShortMessage(); 52250003Sadrian smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 126,100); 53250003Sadrian receiver.send(smsg, -1); 54250003Sadrian assertEquals(channel.getMono(), false); 55250003Sadrian smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 126,1); 56250003Sadrian receiver.send(smsg, -1); 57250003Sadrian assertEquals(channel.getMono(), true); 58250003Sadrian smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 127,0); 59250003Sadrian receiver.send(smsg, -1); 60250003Sadrian assertEquals(channel.getMono(), false); 61250003Sadrian 62250003Sadrian // Check if send mono triggers AllNotesOff 63250003Sadrian channel.noteOn(60, 64); 64250003Sadrian soft.read(1); 65250003Sadrian assertTrue(soft.findVoice(0,60) != null); 66250003Sadrian smsg.setMessage(ShortMessage.CONTROL_CHANGE,0, 127,0); 67250003Sadrian receiver.send(smsg, -1); 68250003Sadrian soft.read(1); 69250003Sadrian assertTrue(soft.findVoice(0,60) == null); 70250003Sadrian 71250003Sadrian soft.close(); 72250003Sadrian } 73250003Sadrian} 74250003Sadrian