[Audio-engine-dev] SoftSynthesizer exceptions

Alex Menkov alex.menkov at sun.com
Thu Feb 14 09:45:06 PST 2008


Hi,

This is some notes about exception in SoftSynthesizer class.

1) SoftSynthesizer throws IllegalStateException from a number of methods when it 
is not open.
Old synthesizer implementation does not throw such exception, so the behavior 
may cause compatibility problems in some applications (for example JSInfo from 
jsresources.org - it calls getChannels() to discover how many channels a 
synthesizer supports).
Although IllegalStateException is not required to be declared in "throws" list 
of a method, it should be explicitly described in spec (see Receiver.send for 
example).

The methods which throw IllegalStateException:
getChannels();
getVoiceStatus();
loadInstrument(Instrument instrument);
unloadInstrument(Instrument instrument);
remapInstrument(Instrument from, Instrument to);
getAvailableInstruments();
getLoadedInstruments();
loadAllInstruments(Soundbank soundbank);
unloadAllInstruments(Soundbank soundbank);
loadInstruments(Soundbank soundbank, Patch[] patchList);
unloadInstruments(Soundbank soundbank, Patch[] patchList);
getMicrosecondPosition();
getReceivers();

also the exception can be thrown by loadSamples (called from 
loadAllInstruments(Soundbank soundbank) and loadInstrument(Instrument 
instrument); this are the cases when loadAllInstruments/loadInstrument should 
return "false" - see 2) ), from ModelByteBuffer class methods and from 
SoftMidiAudioFileReader.getAudioInputStream(Sequence seq) (called from other 
SoftMidiAudioFileReader methods)


2) a number of methods (instrument loading/unloading) should throw 
IllegalArgumentException if the instrument (or sounbank) is unsupported (in our 
case instrument is not instance of ModelInstrument). "false" (for methods which 
returns boolean) means that instrument is supported, but could not be loaded by 
some reason.
The methods are:
loadInstrument(Instrument instrument);
unloadInstrument(Instrument instrument);
remapInstrument(Instrument from, Instrument to);
loadAllInstruments(Soundbank soundbank);
unloadAllInstruments(Soundbank soundbank);
loadInstruments(Soundbank soundbank, Patch[] patchList);
unloadInstruments(Soundbank soundbank, Patch[] patchList);



Regards
Alex



More information about the audio-engine-dev mailing list