/* * Created by Nick on Nov 15, 2004 * */ package jmslexamples.jsyn; import com.softsynth.jmsl.*; import com.softsynth.jmsl.jsyn.JSynMusicDevice; import com.softsynth.jmsl.jsyn.SynthNoteAllPortsInstrument; /** * Demonstrates JMSL support for SynthNotes with more than one SynthOutput * defined. See SquareSineSawSynthNote for an example on how to massage your * SynthNotes to fit into this scheme. Note that this is different that a * SynthNote with a single "output" with one or more parts. Those already fit * into SynthNoteAllPortsInstrument without the need for any changes to the * SynthNote source code. This example however, covers SynthNotes that literally * have multiple outputs defined (output, output2, output3, etc) and how to * support that. When JSyn supports an output unit that can have multiple inputs * assigned to indexed parts, this will become obsolete * * @author Nick Didkovsky, (c) 2004 All rights reserved, Email: * didkovn@mail.rockefeller.edu * */ public class ThreeOutputSynthNoteApplet extends java.applet.Applet { JMSLMixerContainer mixer; SynthNoteAllPortsInstrument ins; MusicShape musicShape; public void init() { JMSL.setIsApplet(true); JMSLRandom.randomize(); } public void start() { JMSL.clock.setAdvance(0.1); MusicDevice dev = JSynMusicDevice.instance(); dev.edit(new java.awt.Frame()); dev.open(); mixer = new JMSLMixerContainer(); mixer.start(); ins = new SynthNoteAllPortsInstrument(8, SquareSineSawSynthNote.class.getName()); ins.setName("Ins w/3 outputs"); mixer.addInstrument(ins); // we know this is a three part instrument so we can set the pan and amp values here mixer.panAmpChange(0, 0.5, 0.6); mixer.panAmpChange(1, 0.1, 0.1); mixer.panAmpChange(2, 0.9, 0.1); add(mixer.getPanAmpControlPanel()); musicShape = new MusicShape(ins.getDimensionNameSpace()); musicShape.prefab(); musicShape.setInstrument(ins); musicShape.setRepeats(100); musicShape.launch(JMSL.now()); musicShape.addRepeatPlayable(new Playable() { /** occasionally scramble durations, occasionally scramble pitches */ public double play(double time, Composable parent) throws InterruptedException { MusicShape s = (MusicShape) parent; if (JMSLRandom.choose() < 0.3) { s.scramble(0, s.size() - 1, 0); } if (JMSLRandom.choose() < 0.3) { s.scramble(0, s.size() - 1, 1); } return time; } }); } public void stop() { musicShape.finishAll(); JMSL.closeMusicDevices(); } }