package jmslexamples.jsyn;
import com.softsynth.jmsl.PlayLurker;
import com.softsynth.jmsl.jsyn.SynthNoteAllPortsInstrument;
import com.softsynth.jsyn.Synth;
/**
* This behaves just like a SynthNoteAllPortsInstrument playing a
* com.softsynth.jsyn.circuits.FilteredSawtoothBL, adding the PlayLurker
* interface so that it can be notified of elements being played by other
* objects. This could be used to create an arpeggiating instrument, for
* example, that listens to notes being played by a MusicShape or a MusicList or
* a JMSL Score Track.
*
*
* COMPLETE SOURCE:
*
*
*
* package jmslexamples.jsyn;
*
* import com.softsynth.jmsl.*;
* import com.softsynth.jmsl.score.jsyn.SynthNoteAllPortsInstrument;
* import com.softsynth.jsyn.*;
*
* public class PlayLurkingFSBLInstrument extends SynthNoteAllPortsInstrument implements PlayLurker {
*
* public PlayLurkingFSBLInstrument() {
* super(8, com.softsynth.jsyn.circuits.FilteredSawtoothBL.class.getName());
* }
*
* public void notify(double playTime, com.softsynth.jmsl.MusicJob job, int index) {
* System.out.println("PlayLurkingFSBLInstrument being notified of index " + index + " being played");
* }
*
* public static void main(String args[]) {
* try {
* Synth.startEngine(0);
* String filename = "PlayLurkingFSBLInstrument.xml";
* PlayLurkingFSBLInstrument ins = new PlayLurkingFSBLInstrument();
* ins.setName("Play Lurking FilteredSawtoothBL ins");
* java.io.PrintWriter pout = new java.io.PrintWriter(new java.io.FileOutputStream(filename));
* (new com.softsynth.jmsl.score.util.SimpleXMLSaver(ins, "jmslscoreinstrument")).writeXML(pout);
* pout.close();
* System.out.println("Wrote " + filename);
* Synth.stopEngine();
* } catch (java.io.IOException e) {
* System.out.println("ERROR in main: " + e);
* }
* }
*
* }
*
*
*
*
* @author Nick Didkovsky, July 23, 2002, (c) 2002 Nick Didkovsky all rights
* reserved
*/
public class PlayLurkingJSynInstrument extends SynthNoteAllPortsInstrument implements PlayLurker {
/**
* Hard coded to call super(8,
* com.softsynth.jsyn.circuits.FilteredSawtoothBL.class.getName());
*/
public PlayLurkingJSynInstrument() {
super(8, com.softsynth.jsyn.circuits.FilteredSawtoothBL.class.getName());
}
/**
* PlayLurker interface. notify() is called by any MusicShape or MusicList
* which has this object in its list of PlayLurkers
*/
public void notifyPlayLurker(double playTime, com.softsynth.jmsl.MusicJob job, int index) {
System.out.println("PlayLurkingFSBLInstrument being notified of index " + index + " being played");
}
/**
* Just instantiate an instrument and write out an XML file so it can be
* loaded into JMSL Score
*/
public static void main(String args[]) {
try {
Synth.startEngine(0);
String filename = "PlayLurkingFSBLInstrument.xml";
PlayLurkingJSynInstrument ins = new PlayLurkingJSynInstrument();
ins.setName("Play Lurking FilteredSawtoothBL ins");
java.io.PrintWriter pout = new java.io.PrintWriter(new java.io.FileOutputStream(filename));
(new com.softsynth.jmsl.util.SimpleXMLSaver(ins, "jmslscoreinstrument")).writeXML(pout);
pout.close();
System.out.println("Wrote " + filename);
Synth.stopEngine();
} catch (java.io.IOException e) {
System.out.println("ERROR in main: " + e);
}
}
}