1) Type in the classname: Assuming patches/SimpleUnitVoice.class is in the CLASSPATH that launched JMSL Score, you can import the SimpleUnitVoice by name as we did earlier with SubtractiveSynthVoice (see Building your own JScore instrument, part 3).
2) Plugin approach (shows up in menu): You can alternatively put the class file in the jmsl_plugins folder (you must put it in a "patches" subdirectory as is Java package convention). Recall that our class implements JMSLPlugin, so the plug in scanner will pick it up. When ScoreFrame launches, it scans jmsl_plugins for UnitVoices and generates hierarchical menus for those it finds.
The advantage to the Plugin approach is that once this UnitVoice
class is in jmsl_plugins, it will be available as a menu item everytime
you run ScoreFrame.
3) Hard coding your instruments into a JMSL Score application
Recall that JScore has a straightforward API that lets you code instruments directly into an application. We'll instantiate one of our new instruments and one SubtractiveSynthVoice instrument, and build a JSyn Orchestra directly in Java code.
The essential code fragment is excerpted below.
JSynOrchestra orch = new JSynOrchestra(); orch.addInstrument(new JSynUnitVoiceInstrument(8, patches.SimpleUnitVoice.class.getName()), "Simple Unit Voice"); orch.addInstrument(new JSynUnitVoiceInstrument(8, SubtractiveSynthVoice.class.getName()), "Subtractive Synth Voice"); orch.buildMixerPanel(); ... score.setOrchestra(orch);Note that Orchestra's addInstrument() method takes a JMSLScoreInstrument and a friendly name as arguments. We create a JMSLScoreInstrument on the fly by using JScore's JSynUnitVoiceInstrument class, whose constructor takes the name of a UnitVoice and its max polyphony. So with one line of code, you can import any UnitVoice class directly into JScore, at the API level. Nice!
(C) Nick Didkovsky and Phil Burk, All Rights Reserved JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.