Class SongMusicGenerationListener

java.lang.Object
org.jjazz.musiccontrol.api.SongMusicGenerationListener
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class SongMusicGenerationListener extends Object implements PropertyChangeListener
A helper class to be notified when a song and other elements have changed in a way that will impact music generation for that song.

The class fires a PROP_CHANGED change event when it receives a PROP_MUSIC_GENERATION property change from Song, MidiMix, and PlaybackSettings.

A black-list mechanism can be used to filter out some PROP_MUSIC_GENERATION source events. A delay can be set before firing the ChangeEvent, in order to automatically filter out rapid successive changes.

  • Field Details

    • PROP_CHANGED

      public static final String PROP_CHANGED
      oldValue = the name of the Song/MidiMix/PlaybackSettings source property change event (PROP_MUSIC_GENERATION).
      newValue = optional data associated to the source property change event (PROP_MUSIC_GENERATION).
      See Also:
  • Constructor Details

    • SongMusicGenerationListener

      public SongMusicGenerationListener(Song song, MidiMix midiMix, int preFireChangeEventDelayMs)
      Construct a SongMusicGenerationListener.
      Parameters:
      song -
      midiMix -
      preFireChangeEventDelayMs - The delay in ms before firing a PROP_CHANGED event.
      See Also:
  • Method Details

    • getSong

      public Song getSong()
    • getMidiMix

      public MidiMix getMidiMix()
    • cleanup

      public void cleanup()
    • getPreFireChangeEventDelayMs

      public int getPreFireChangeEventDelayMs()
      The delay to wait before firing a PROP_CHANGED event.

      Delay is activated when receiving a PROP_MUSIC_GENERATION event. When the delay expires a PROP_CHANGED event is fired using the last PROP_MUSIC_GENERATION received while the delay was running.

      Returns:
      A value in milliseconds.
    • getBlackList

      public Set<String> getBlackList()
    • setBlackList

      public void setBlackList(Set<String> blackList)
      Black list some source PROP_MUSIC_GENERATION events by their property name or actionId: those source events won't trigger a ChangeEvent from this instance.

      Property names or actionId of Song, ChordLeadSheet, SongStructure, MidiMix, or PlaybackSettings.

      Parameters:
      blackList - Can be null
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
      Add a listener to be notified when a music generation impacting change has occured.
      Parameters:
      listener -
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
    • propertyChange

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