JMSL FAQ

Q: How can I learn how to use JMSL?
A: First visit the JMSL Tutorial. 
Then look at the Demos (links to source are included in every page).  
Then drag the source folders jmslexamples, jmslexamples/simple, and jmslexamples/jsyn into a project in your Java IDE. 
Pay attention to the ones in the "simple" package first! Compile and run each one and study the source code. 
Then compile and run the examples in jmsltestsuite, and study the source code.
Post questions to the JMSL Mailing List!

Q: Musical rhythms sound ragged or uneven.
A: Increase JMSL clock advance.  In your software, do JMSL.clock.setAdvance(0.1)
In JScore, this is under the Edit menu.  A typical value is 0.1  
Advance Time is how far in the future JMSL posts musical events when it plays back.  The advance time
needs to be big enough to absorb jitter in Java's scheduling of Threads.  This varies from
OS to OS, and even from version to version of Java


Q: How do you play a specific measure in JScore?
A: You can play a specific measure or range of measures by defining a section:
Click anywhere in a measure
From menu, choose Measure - Section - start
Click on another measure (or don't click anywhere if you want to use the same measure).
Measure - Section - end

You will see << >> appear over at the start and end of the section you have defined.
Check "Play section" checkbox.
Click Play

Note that CTRL F11 and CTRL F12 are shortcuts for this feature.

Q: I see a bunch of "Sleep until Tick () interrupted"  messages.
A: This is a debugging message which will disappear in the 1.4.2 release of JSyn (not JMSL).  


Q Are there shortcuts to play a section, stop playback, play the piece?
A: Yes. CTRL-spacebar plays section. spacebar stops playback. CTRL-SHIFT-spacebar plays from beginning of piece.  
For these to be active, the cursor must be clicked somewhere, anywhere, in the score itself (as opposed to having last clicked a button).


Q: I get a java.security.AccessControlException when I visit some JMSL applets with a web browser.
A: This can happen when jmsl.jar is installed as a Java extension (on OSX, if it is located in ~/Library/Java/Extensions 
or under Windows (java.home)\lib\ext ). Extensions are loaded instead of the jmsl.jar from the codebase of
the applet on the website.  This can invoke security problems, such as the one seen here since you are
mixing classes loaded from extensions with those loaded from the applet.
Thread.interrupt() used by JMSL's EventScheduler for example, can trigger a security exception in this scenario

At least two solutions exist.
Either:
1) Remove jmsl.jar from your extensions directory ((java.home)\lib\ext in Windows or ~/Library/Java/Home in OS X). 
This is the preferred solution. JMSL is not designed to be run as an extension.
2) Or give explicit permission to applets to interrupt extension Threads
OSX users, create a file named .java.policy in your user home directory (note that the name must be "dot java dot policy"
The contents should be as follows,
grant codeBase "file:${user.home}/-" {
	permission java.lang.RuntimePermission "modifyThread";
};

Q: I get an EventScheduler NullPointerException when I refresh a web page with my JMSL applet in it.
A: Timed events in Applet.stop() can overlap with timed events in Applet.start() when a page is refreshed.
You might need to synchronize your applet's stop() and start() methods to prevent the stopping of the EventScheduler
from colliding with the instantiation of a new one. This protects other termination code from colliding with startup code as well.

For example:
 public void start() {
        synchronized (JMSL.class) {
            // IMPORTANT! Start with a new scheduler!
            JMSL.scheduler = new EventScheduler();
            JMSL.scheduler.start();
			// other startup code
        }
    }
    
     public void stop() {
        synchronized (JMSL.class) {
            myComposable.finishAll();
            try {
                myComposable.waitForDone();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            JMSL.scheduler.stop();
            JMSL.closeMusicDevices();
        }
    }
    
Thanks to Kimo Johnson for suggesting this technique

Q: How do I deploy a JMSL Score on the WWW?
A: See developersNotes.html

JMSL Home