package jmsltestsuite; import com.softsynth.jmsl.*; import com.softsynth.jmsl.jsyn.*; import com.softsynth.jsyn.*; import com.softsynth.jsyn.circuits.*; import com.softsynth.jsyn.util.*; import java.awt.*; import java.awt.event.*; public class TestEventSchedulerJSyn { /** Build an instrument and a shape and play it on a JSyn voice. */ public static void main(String args[]) { BussedVoiceAllocator allocator1; BussedVoiceAllocator allocator2; LineOut unitOut; MusicShape shape1; MusicShape shape2; /* Start synthesis engine. */ Synth.startEngine(0); SynthObject.enableTracking(true); JMSL.clock = new SynthClock(); JMSL.clock.setAdvance(0.5); allocator1 = new BussedVoiceAllocator(8) { public SynthCircuit makeVoice() throws SynthException { SynthNote circ = new RingModBell(); circ.amplitude.set(1.0 / getMaxVoices()); return addVoiceToMix(circ); } }; allocator2 = new BussedVoiceAllocator(8) { public SynthCircuit makeVoice() throws SynthException { SynthNote circ = new RingModBell(); circ.amplitude.set(1.0 / getMaxVoices()); return addVoiceToMix(circ); } }; unitOut = new LineOut(); unitOut.start(); SynthNoteInstrument ins1 = new SynthNoteInstrument(); ins1.setAllocator(allocator1); ((SynthOutput) ins1.getOutput()).connect(0, unitOut.input, 0); SynthNoteInstrument ins2 = new SynthNoteInstrument(); ins2.setAllocator(allocator2); ((SynthOutput) ins2.getOutput()).connect(0, unitOut.input, 1); shape1 = new MusicShape(4); shape1.add(0.125, 62, 30, 2.5); shape1.add(0.125, 64, 40, 2.5); shape1.add(0.125, 66, 50, 0.5); shape1.add(0.125, 68, 60, 2.5); shape1.add(0.125, 70, 70, 1.5); shape1.add(0.125, 72, 80, 0.5); shape1.setInstrument(ins1); shape2 = new MusicShape(4); shape2.add(0.125, 62, 30, 2.5); shape2.add(0.125, 64, 40, 2.5); shape2.add(0.125, 66, 50, 0.5); shape2.add(0.125, 68, 60, 2.5); shape2.add(0.125, 70, 70, 1.5); shape2.add(0.125, 72, 80, 0.5); shape2.setInstrument(ins2); shape2.transpose(4, 0, shape2.size() - 1, 1); jmsltestsuite.TestLurker lurk = new jmsltestsuite.TestLurker(); shape1.addPlayLurker(lurk); shape2.addPlayLurker(lurk); ParallelCollection p = new ParallelCollection(shape1, shape2); p.setRepeats(10000); p.launch(JMSL.now() + 2); Frame f = new Frame("MusicShapes with Lurker posting events to EventScheduler"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { Synth.stopEngine(); System.exit(0); } }); f.setSize(600, 200); f.setVisible(true); // EventScheduler scheduler = new EventScheduler(); // scheduler.testDebug(); } }