Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.fluidsynth.api
Class ConfigManager  view ConfigManager download ConfigManager.java

java.lang.Object
  extended byorg.fluidsynth.api.ConfigManager
All Implemented Interfaces:
java.util.EventListener, org.fluidsynth.api.event.ExecutiveListener

public class ConfigManager
extends java.lang.Object
implements org.fluidsynth.api.event.ExecutiveListener

Class to manage config files. Config files contain the aggragate details of user modified settings, loaded sound font, channel assignments, etc. The in-memory, run-time representation of a config file is a Configuration object. The Configuration object is serialized to XML for storage on disk and deserialized when loaded into memory. Serialization to/from XML is performed with the Castor XML Framework.


Nested Class Summary
(package private) static class ConfigManager.ConfigFileFilter
           
(package private)  class ConfigManager.LoaderPhase2
           
(package private) static class ConfigManager.Sf2FileFilter
           
(package private) static class ConfigManager.TestListener
          Test harness.
 
Field Summary
(package private) static java.util.ResourceBundle bundle
           
private  java.util.ArrayList channelEventListenerList
          Utility field holding list of ChannelEventListeners.
private  org.fluidsynth.api.sf2.Channel[] channelRegister
           
static java.lang.String CONFIG_FILE_EXT
          file extension for config files.
private static javax.swing.filechooser.FileFilter configFileFilter
           
private  Configuration currentConfiguration
           
(package private) static java.util.regex.Pattern idPattern
           
(package private) static java.util.regex.Pattern infoPattern
           
(package private) static java.util.regex.Pattern instPattern
           
private static ConfigManager me
           
private static Mapping metaMapping
           
private  Configuration newConfig
           
static java.lang.String PROP_CONFIGURATION
          Property name for the "configuration changed" property change event.
(package private) static java.util.regex.Pattern settingPattern
           
private  java.util.ArrayList settingsEventListenerList
          Utility field holding list of SettingsEventListeners.
private static javax.swing.filechooser.FileFilter sf2FileFilter
           
private  java.util.ArrayList soundFontEventListenerList
          Utility field holding list of SoundFontEventListeners.
private  java.beans.PropertyChangeSupport support
           
private  boolean supressEvents
           
private static Mapping userMapping
           
 
Constructor Summary
private ConfigManager()
          Private constructor enforces the singleton pattern.
 
Method Summary
 void addChannelEventListener(org.fluidsynth.api.event.ChannelEventListener listener)
          Registers ChannelEventListener to receive events.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a property change listener.
 void addSettingsEventListener(org.fluidsynth.api.event.SettingsEventListener listener)
          Registers SettingsEventListener to receive events.
 void addSoundFontEventListener(org.fluidsynth.api.event.SoundFontEventListener listener)
          Registers SoundFontEventListener to receive events.
(package private)  void assignChannel(org.fluidsynth.api.sf2.Channel channel)
           
 void assignNewChannel(org.fluidsynth.api.sf2.Channel channel)
           
private  void fireChannelChanged(org.fluidsynth.api.event.ChannelEvent event)
          Notifies all registered listeners about the event.
private  void fireSettingsChanged(org.fluidsynth.api.event.SettingsEvent event)
          Notifies all registered listeners about the event.
private  void fireSoundFontAdded(org.fluidsynth.api.event.SoundFontEvent event)
          Notifies all registered listeners about the event.
private  void fireSoundFontRemoved(org.fluidsynth.api.event.SoundFontEvent event)
          Notifies all registered listeners about the event.
private  void fireSoundFontUpdated(org.fluidsynth.api.event.SoundFontEvent event)
          Notifies all registered listeners about the event.
private  void fireSoundFontWillBeRemoved(org.fluidsynth.api.event.SoundFontEvent event)
          Notifies all registered listeners about the event.
static javax.swing.filechooser.FileFilter getConfigFileFilter()
          Get the file filter that filters out all but config files.
 Configuration getCurrentConfiguration()
          Get the currently loaded configuration.
static javax.swing.filechooser.FileFilter getSf2FileFilter()
          Get the file filter that filters out all but sound font files.
static ConfigManager init()
          Initialize the ConfigManager.
 Configuration loadConfiguration(java.lang.String configPathName)
          Load a new configuration from the given pathname.
 void loadNewSoundFont(java.lang.String path)
          Load a new sound font specifed by the given filesystem path.
(package private)  void loadSoundFont(org.fluidsynth.api.sf2.SoundFont soundFont)
           
 org.fluidsynth.api.sf2.Channel lookupChannel(int channelNumber)
           
static void main(java.lang.String[] args)
           
(package private) static void marshall(Mapping mapping, Configuration configuration, java.io.File file)
           
private  org.fluidsynth.api.settings.Settings mergeSynthSettings(org.fluidsynth.api.settings.Settings settings)
          Merges the content of the Settings object passed as an argument into the info from a queries to fluidsynth for settings meta data.
static ConfigManager onlyInstance()
          Return the singleton instance of the class.
 void removeChannelEventListener(org.fluidsynth.api.event.ChannelEventListener listener)
          Removes ChannelEventListener from the list of listeners.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a property change listener.
 void removeSettingsEventListener(org.fluidsynth.api.event.SettingsEventListener listener)
          Removes SettingsEventListener from the list of listeners.
 void removeSoundFontEventListener(org.fluidsynth.api.event.SoundFontEventListener listener)
          Removes SoundFontEventListener from the list of listeners.
static void saveConfiguration(Configuration configuration, java.lang.String pathname)
          Save the specified configuration to the given pathname.
 void started()
          Called when the synth starts
 void stopped()
          Called when the synth stops for any reason.
(package private)  void synchChannels()
           
 void unloadSoundFont(org.fluidsynth.api.sf2.SoundFont sf2)
           
 org.fluidsynth.api.sf2.SoundFont validateChannel(org.fluidsynth.api.sf2.Channel channel)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bundle

static java.util.ResourceBundle bundle

CONFIG_FILE_EXT

public static final java.lang.String CONFIG_FILE_EXT
file extension for config files.

See Also:
Constant Field Values

PROP_CONFIGURATION

public static final java.lang.String PROP_CONFIGURATION
Property name for the "configuration changed" property change event.

See Also:
Constant Field Values

metaMapping

private static Mapping metaMapping

userMapping

private static Mapping userMapping

me

private static ConfigManager me

configFileFilter

private static javax.swing.filechooser.FileFilter configFileFilter

sf2FileFilter

private static javax.swing.filechooser.FileFilter sf2FileFilter

currentConfiguration

private Configuration currentConfiguration

newConfig

private Configuration newConfig

support

private java.beans.PropertyChangeSupport support

channelRegister

private org.fluidsynth.api.sf2.Channel[] channelRegister

supressEvents

private boolean supressEvents

settingPattern

static java.util.regex.Pattern settingPattern

infoPattern

static java.util.regex.Pattern infoPattern

idPattern

static java.util.regex.Pattern idPattern

instPattern

static java.util.regex.Pattern instPattern

settingsEventListenerList

private transient java.util.ArrayList settingsEventListenerList
Utility field holding list of SettingsEventListeners.


soundFontEventListenerList

private transient java.util.ArrayList soundFontEventListenerList
Utility field holding list of SoundFontEventListeners.


channelEventListenerList

private transient java.util.ArrayList channelEventListenerList
Utility field holding list of ChannelEventListeners.

Constructor Detail

ConfigManager

private ConfigManager()
               throws java.lang.Exception
Private constructor enforces the singleton pattern.

Method Detail

init

public static ConfigManager init()
                          throws java.lang.Exception
Initialize the ConfigManager. This method must be called prior to onlyInstance() 55 .


onlyInstance

public static ConfigManager onlyInstance()
Return the singleton instance of the class.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener.


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener.


getCurrentConfiguration

public Configuration getCurrentConfiguration()
Get the currently loaded configuration.


loadConfiguration

public Configuration loadConfiguration(java.lang.String configPathName)
                                throws java.lang.Exception
Load a new configuration from the given pathname. The newly loaded configuration becomes the current configuration. Property change events are fired to notify listeners of the change.


started

public void started()
Called when the synth starts

Specified by:
started in interface org.fluidsynth.api.event.ExecutiveListener

stopped

public void stopped()
Called when the synth stops for any reason.

Specified by:
stopped in interface org.fluidsynth.api.event.ExecutiveListener

mergeSynthSettings

private org.fluidsynth.api.settings.Settings mergeSynthSettings(org.fluidsynth.api.settings.Settings settings)
                                                         throws java.io.IOException,
                                                                java.lang.IllegalStateException
Merges the content of the Settings object passed as an argument into the info from a queries to fluidsynth for settings meta data. The merge is performed in such a way that the input values take precedence over values queried from the synth.


saveConfiguration

public static void saveConfiguration(Configuration configuration,
                                     java.lang.String pathname)
                              throws java.lang.Exception
Save the specified configuration to the given pathname. The saved configuration becomes the current configuration. Property change events are fired to notify listeners of the change.


marshall

static void marshall(Mapping mapping,
                     Configuration configuration,
                     java.io.File file)
              throws java.lang.Exception

getConfigFileFilter

public static javax.swing.filechooser.FileFilter getConfigFileFilter()
Get the file filter that filters out all but config files.


getSf2FileFilter

public static javax.swing.filechooser.FileFilter getSf2FileFilter()
Get the file filter that filters out all but sound font files.


main

public static void main(java.lang.String[] args)

loadNewSoundFont

public void loadNewSoundFont(java.lang.String path)
                      throws OperationFailedException
Load a new sound font specifed by the given filesystem path.


loadSoundFont

void loadSoundFont(org.fluidsynth.api.sf2.SoundFont soundFont)
             throws OperationFailedException

unloadSoundFont

public void unloadSoundFont(org.fluidsynth.api.sf2.SoundFont sf2)
                     throws OperationFailedException

synchChannels

void synchChannels()

validateChannel

public org.fluidsynth.api.sf2.SoundFont validateChannel(org.fluidsynth.api.sf2.Channel channel)
                                                 throws OperationFailedException

assignNewChannel

public void assignNewChannel(org.fluidsynth.api.sf2.Channel channel)
                      throws OperationFailedException

assignChannel

void assignChannel(org.fluidsynth.api.sf2.Channel channel)
             throws OperationFailedException

lookupChannel

public org.fluidsynth.api.sf2.Channel lookupChannel(int channelNumber)

addSettingsEventListener

public void addSettingsEventListener(org.fluidsynth.api.event.SettingsEventListener listener)
Registers SettingsEventListener to receive events.


removeSettingsEventListener

public void removeSettingsEventListener(org.fluidsynth.api.event.SettingsEventListener listener)
Removes SettingsEventListener from the list of listeners.


fireSettingsChanged

private void fireSettingsChanged(org.fluidsynth.api.event.SettingsEvent event)
Notifies all registered listeners about the event.


addSoundFontEventListener

public void addSoundFontEventListener(org.fluidsynth.api.event.SoundFontEventListener listener)
Registers SoundFontEventListener to receive events.


removeSoundFontEventListener

public void removeSoundFontEventListener(org.fluidsynth.api.event.SoundFontEventListener listener)
Removes SoundFontEventListener from the list of listeners.


fireSoundFontAdded

private void fireSoundFontAdded(org.fluidsynth.api.event.SoundFontEvent event)
Notifies all registered listeners about the event.


fireSoundFontWillBeRemoved

private void fireSoundFontWillBeRemoved(org.fluidsynth.api.event.SoundFontEvent event)
Notifies all registered listeners about the event.


fireSoundFontRemoved

private void fireSoundFontRemoved(org.fluidsynth.api.event.SoundFontEvent event)
Notifies all registered listeners about the event.


fireSoundFontUpdated

private void fireSoundFontUpdated(org.fluidsynth.api.event.SoundFontEvent event)
Notifies all registered listeners about the event.


addChannelEventListener

public void addChannelEventListener(org.fluidsynth.api.event.ChannelEventListener listener)
Registers ChannelEventListener to receive events.


removeChannelEventListener

public void removeChannelEventListener(org.fluidsynth.api.event.ChannelEventListener listener)
Removes ChannelEventListener from the list of listeners.


fireChannelChanged

private void fireChannelChanged(org.fluidsynth.api.event.ChannelEvent event)
Notifies all registered listeners about the event.