May 2005
Intermediate to advanced
998 pages
26h
English
The constructor for LoadersTests creates the images canvas (a SoundsPanel object) and the rest of the GUI, and it initializes the loaders:
// the clip and midi sound information files, located in Sounds/
private final static String SNDS_FILE = "clipsInfo.txt";
private final static String MIDIS_FILE = "midisInfo.txt";
// global variables
private ClipsLoader clipsLoader;
private MidisLoader midisLoader;
public LoadersTests()
{ super( "Sounds Tests" );
Container c = getContentPane();
c.setLayout( new BorderLayout() );
SoundsPanel sp = new SoundsPanel(this); // the images canvas
c.add( sp, BorderLayout.CENTER);
initGUI(c); // the rest of the controls
// initialise the loaders
clipsLoader = new ClipsLoader(SNDS_FILE);
clipsLoader.setWatcher("dog", this); // watch the dog clip
midisLoader = new MidisLoader(MIDIS_FILE);
midisLoader.setWatcher(this); // watch the midi sequence
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent ev) {
midisLoader.close(); // shut down the sequencer
System.exit(0);
}
});
pack();
setResizable(false); // fixed size display
centerFrame(); // placed in the center of the screen
setVisible(true);
}As part of the loaders setup, setWatcher() is called in the ClipsLoader and MidisLoader objects:
clipsLoader.setWatcher("dog", this); // watch the dog clip
midisLoader.setWatcher(this); // watch midi playingA call to setWatcher() tells the loader that this object (LoadersTest) should be notified whenever ...
Read now
Unlock full access