public static void main(String[] args) throws Exception { AudioSynthesizer synth = new SoftSynthesizer(); Receiver recv = synth.getReceiver(); assertTrue(recv != null); ShortMessage sm = new ShortMessage(); sm.setMessage(ShortMessage.NOTE_OFF, 0, 64, 64); synth.open(new DummySourceDataLine(), null); recv.send(sm, -1); synth.close(); try { recv.send(sm, -1); throw new RuntimeException("Exception not thrown!"); } catch(Exception e) { // Just checking if exception is thrown } }
public void init(SoftSynthesizer synth) { control_time = 1.0 / synth.getControlRate(); sin_factor = control_time * 2 * Math.PI; for (int i = 0; i < used_count; i++) { delay_counter[i] = (int)(Math.pow(2, this.delay[i][0] / 1200.0) / control_time); delay_counter[i] += (int)(delay2[i][0] / (control_time * 1000)); } processControlLogic(); }
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); Receiver recv = synth.getReceiver(); if (((SoftReceiver) recv).getMidiDevice() != synth) { throw new Exception("SoftReceiver.getMidiDevice() doesn't return " + "instance of the synthesizer"); } synth.close(); }
public SoftReceiver(SoftSynthesizer synth) { this.control_mutex = synth.control_mutex; this.synth = synth; this.mainmixer = synth.getMainMixer(); if (mainmixer != null) this.midimessages = mainmixer.midimessages; }
public SoftChannel(SoftSynthesizer synth, int channel) { this.channel = channel; this.voices = synth.getVoices(); this.synthesizer = synth; this.mainmixer = synth.getMainMixer(); control_mutex = synth.control_mutex; resetAllControllers(true); }