public void noteOn(MidiChannel channel, VoiceStatus voice, int noteNumber, int velocity) { this.channel = channel; this.voice = voice; this.noteNumber = noteNumber; this.velocity = velocity; on = true; }
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); AudioFormat format = new AudioFormat(44100, 16, 2, true, false); AudioInputStream stream = synth.openStream(format, null); // Make all voices busy, e.g. // send midi on and midi off on all available voices MidiChannel ch1 = synth.getChannels()[0]; ch1.programChange(48); // Use contionus instrument like string ensemble for (int i = 0; i < synth.getMaxPolyphony(); i++) { ch1.noteOn(64, 64); ch1.noteOff(64); } // Now send single midi on, and midi off message ch1.noteOn(64, 64); ch1.noteOff(64); // Read 10 sec from stream, by this time all voices should be inactvie stream.skip(format.getFrameSize() * ((int)(format.getFrameRate() * 20))); // If no voice are active, then this test will pass VoiceStatus[] v = synth.getVoiceStatus(); for (int i = 0; i < v.length; i++) { if(v[i].active) { throw new RuntimeException("Not all voices are inactive!"); } } // Close the synthesizer after use synth.close(); }
public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); synth.openStream(null, null); VoiceStatus[] v = synth.getVoiceStatus(); assertTrue(v != null); assertTrue(synth.getChannels().length != synth.getMaxPolyphony()); synth.close(); }
@Override public void noteOn(MidiChannel channel, VoiceStatus voice, int noteNumber, int velocity) { this.channel = channel; this.voice = voice; this.noteNumber = noteNumber; this.velocity = velocity; on = true; }