/** * simplePlayer.java * * Implementation of abstract player class. * Plays unbent pitches * * This module is part of Karl Brown's MIDI programming project. * */ package MidiApps; import java.io.*; import java.util.*; import javax.sound.midi.*; /** * * @author Karl Brown * @version 1.0 * last updated 2/16/2003 */ public class simplePlayer extends player { /** * * Implemented class method to play one or more notes * by generating note on and note off events. * There are no pitch bend events. * */ public void play() { long tickOn = tickCount; incTickCount(getDuration()); long tickOff = tickCount; try { for (int i = 0; i < pitchCount; i ++) { // note on; ShortMessage mm = new ShortMessage(); mm.setMessage((byte)(0x90 + (byte)channel[i]),(byte)midiPitch[i],(byte)velOn); MidiEvent me = new MidiEvent(mm,(long)tickOn); t.add(me); // note off; mm = new ShortMessage(); mm.setMessage((byte)(0x80 + (byte)channel[i]),(byte)midiPitch[i],(byte)velOff); me = new MidiEvent(mm,(long)tickOff); t.add(me); } } //try catch(Exception e) { tr.trace("simplePlayer::play: Exception caught:"); tr.trace(e.toString()); } //catch } }