Class MidiMixManager

java.lang.Object
org.jjazz.midimix.api.MidiMixManager
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class MidiMixManager extends Object implements PropertyChangeListener
Global instance to obtain MidiMixes for songs and rhythms.
  • Method Details

    • getInstance

      public static MidiMixManager getInstance()
    • findMix

      public MidiMix findMix(Song s) throws MidiUnavailableException
      Get a MidiMix for the specified song in the following order.

      1. If the mix for song s already exists, just return it
      2. Load mix from song mix file
      3. Create a new mix for s using findMix(Rhythm) for each song's rhythm

      Parameters:
      s -
      Returns:
      A valid MidiMix usable for the specified song.
      Throws:
      MidiUnavailableException
    • findExistingMix

      public MidiMix findExistingMix(Song s)
      Find a mix which must be existing.

      If you're not sure if a MidiMix was already created for the specified song, use findMix(Song) instead.

      Parameters:
      s -
      Returns:
      Can't be null
      Throws:
      IllegalStateException - If no mix found
    • findMix

      public MidiMix findMix(Rhythm r)
      Try to get a MidiMix for the specified Rhythm in the following order:

      1. Load mix from the default rhythm mix file
      2. Create a new mix for r

      Parameters:
      r -
      Returns:
      Can't be null
    • createMix

      public MidiMix createMix(Song sg) throws MidiUnavailableException
      Create a new MidiMix for the specified song.

      Use the default rhythm mix for each song's rhythm. Create UserRhythmVoices key if song as some user phrases.

      Parameters:
      sg -
      Returns:
      Throws:
      MidiUnavailableException - If there is not enough available channels to accomodate song's rhythms, or other errors.
    • createMix

      public MidiMix createMix(Rhythm r)
      Create a MidiMix for the specified rhythm.

      Create one InstrumentMix per rhythm voice, using rhythm voice's preferred instrument and settings, and preferred channel (except if several voices share the same preferred channel) .

      Parameters:
      r - If r is
      Returns:
      A MidiMix associated to this rhythm. Rhythm voices are used as keys for InstrumentMixes.
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Specified by:
      propertyChange in interface PropertyChangeListener