Class PlaybackSettings

java.lang.Object
org.jjazz.musiccontrol.api.PlaybackSettings

public class PlaybackSettings extends Object
Playback settings (click, precount, looping, playback transposition, auto-update mode) and related helper methods.

Property change events are fired when settings are modified.

  • Field Details

    • CLICK_TRACK_NAME

      public static String CLICK_TRACK_NAME
    • PRECOUNT_CLICK_TRACK_NAME

      public static String PRECOUNT_CLICK_TRACK_NAME
    • PROP_VETO_PRE_PLAYBACK

      public static final String PROP_VETO_PRE_PLAYBACK
      This vetoable property change can be fired by playback actions (eg Play, Pause) just before playing a song and can be vetoed by vetoables listeners to cancel playback start.

      NewValue=If non null it contains the SongContext object.

      See Also:
    • PROP_LOOPCOUNT

      public static final String PROP_LOOPCOUNT
      See Also:
    • PROP_PLAYBACK_KEY_TRANSPOSITION

      public static final String PROP_PLAYBACK_KEY_TRANSPOSITION
      See Also:
    • PROP_CLICK_PITCH_HIGH

      public static final String PROP_CLICK_PITCH_HIGH
      See Also:
    • PROP_CLICK_PITCH_LOW

      public static final String PROP_CLICK_PITCH_LOW
      See Also:
    • PROP_CLICK_VELOCITY_HIGH

      public static final String PROP_CLICK_VELOCITY_HIGH
      See Also:
    • PROP_CLICK_VELOCITY_LOW

      public static final String PROP_CLICK_VELOCITY_LOW
      See Also:
    • PROP_CLICK_PREFERRED_CHANNEL

      public static final String PROP_CLICK_PREFERRED_CHANNEL
      See Also:
    • PROP_CLICK_PRECOUNT_ENABLED

      public static final String PROP_CLICK_PRECOUNT_ENABLED
      See Also:
    • PROP_CLICK_PRECOUNT_MODE

      public static final String PROP_CLICK_PRECOUNT_MODE
      See Also:
    • PROP_PLAYBACK_CLICK_ENABLED

      public static final String PROP_PLAYBACK_CLICK_ENABLED
      See Also:
    • PROP_AUTO_UPDATE_ENABLED

      public static final String PROP_AUTO_UPDATE_ENABLED
      See Also:
    • PROP_MUSIC_GENERATION

      public static final String PROP_MUSIC_GENERATION
      Fired each time a parameter whic can impact music generation is modified .

      OldValue=the property name that triggered the musical change, newValue=optional data

      See Also:
  • Method Details

    • getInstance

      public static PlaybackSettings getInstance()
    • getLoopCount

      public int getLoopCount()
    • setLoopCount

      public void setLoopCount(int loopCount)
      Set the loop count of the playback.

      Parameters:
      loopCount - If 0, play the song once (no loop). Use Sequencer.LOOP_CONTINUOUSLY for endless loop.
    • getPlaybackKeyTransposition

      public int getPlaybackKeyTransposition()
      Get the key transposition applied to chord symbols when playing a song.

      Returns:
      [0;-11] Default is 0.
    • setPlaybackKeyTransposition

      public void setPlaybackKeyTransposition(int t)
      Set the key transposition applied to chord symbols when playing a song.

      Ex: if transposition=-2, chord=C#7 will be replaced by B7.

      Note that to have some effect the current PlaybackSession must take into account this parameter.

      Parameters:
      t - [0;-11]
    • setAutoUpdateEnabled

      public void setAutoUpdateEnabled(boolean b)
      Set if playing backing track should be automatically updated in real-time when song changes.
      Parameters:
      b -
    • isAutoUpdateEnabled

      public boolean isAutoUpdateEnabled()
      True if playing backing track should be automatically updated in real-time when song changes.
      Returns:
    • setPlaybackClickEnabled

      public void setPlaybackClickEnabled(boolean b)
      Enable the click during playback.

      Parameters:
      b -
    • isPlaybackClickEnabled

      public boolean isPlaybackClickEnabled()
    • setClickPrecountEnabled

      public void setClickPrecountEnabled(boolean b)
      Parameters:
      b - If true a click precount is used before playing the song.
    • isClickPrecountEnabled

      public boolean isClickPrecountEnabled()
    • setClickPrecountMode

      public void setClickPrecountMode(PlaybackSettings.PrecountMode mode)
      Set the precount mode.
      Parameters:
      mode -
    • getClickPrecountMode

      public PlaybackSettings.PrecountMode getClickPrecountMode()
      Get the precount mode.

      Returns:
    • getClickPrecountNbBars

      public int getClickPrecountNbBars(TimeSignature ts, int tempo)
      Get the number of precount bars.

      The parameters are only used if precount mode is set to AUTO.
      Example in AUTO mode: a very fast tempo song will use 2 bars, a 4/4 will use 1 bar up to mid-range tempo etc.

      Parameters:
      ts - Ignored if precount mode is not AUTO.
      tempo - Ignored if precount mode is not AUTO.
      Returns:
      Can be 1 or 2 bars.
    • setPreferredClickChannel

      public void setPreferredClickChannel(int channel)
      Parameters:
      channel -
    • getPreferredClickChannel

      public int getPreferredClickChannel()
      The preferred click channel.
      Returns:
    • getClickChannel

      public int getClickChannel(MidiMix midiMix)
      The actual Midi channel to be used with he specified MidiMix.

      If in the midiMix channel=getPreferredClickChannel() is used and is not a drums/percussion instrument, return the Midi channel MidiConst.CHANNEL_DRUMS. Otherwise return getPreferredClickChannel().

      Parameters:
      midiMix -
      Returns:
    • setClickPitchHigh

      public void setClickPitchHigh(int pitch)
      Parameters:
      pitch - value must be [35-81] (GM1 drum map)
    • getClickPitchHigh

      public int getClickPitchHigh()
    • setClickPitchLow

      public void setClickPitchLow(int pitch)
      Parameters:
      pitch - value must be [35-81] (GM1 drum map)
    • getClickPitchLow

      public int getClickPitchLow()
    • setClickVelocityHigh

      public void setClickVelocityHigh(int v)
    • getClickVelocityHigh

      public int getClickVelocityHigh()
    • setClickVelocityLow

      public void setClickVelocityLow(int v)
    • getClickVelocityLow

      public int getClickVelocityLow()
    • addClickTrack

      public int addClickTrack(Sequence sequence, SongContext context)
      Add a click track using the current settings.

      Parameters:
      sequence - The sequence for which we add the control track.
      context -
      Returns:
      the index of the track in the sequence.
    • addPrecountClickTrack

      public long addPrecountClickTrack(Sequence sequence, SongContext context)
      Add a precount click track to the sequence for the specified song.

      Except for the cases below, all existing sequence MidiEvents are shifted 1 or 2 bars later in order to leave room for the precount bars.

      The following initial events (at tick 0) are not moved:
      - Meta track name
      - Meta time signature
      - Meta tempo
      - Meta copyright

      Parameters:
      sequence - The sequence for which we add the precount click track. Resolution must be MidiConst.PPQ.
      context -
      Returns:
      The tick position of the start of the song.
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener l)
    • addPropertyChangeListener

      public void addPropertyChangeListener(String propName, PropertyChangeListener l)
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener l)
    • removePropertyChangeListener

      public void removePropertyChangeListener(String propName, PropertyChangeListener l)
    • addPlaybackStartVetoableListener

      public void addPlaybackStartVetoableListener(VetoableChangeListener listener)
      Listeners will be notified via the PROP_VETO_PRE_PLAYBACK property change before a playback is started.

      The NewValue is a SongContext object. A listener who has already notified the end-user via its own UI must throw a PropertyVetoException with a null message to avoid another notification by the framework.

      Parameters:
      listener -
    • removePlaybackStartVetoableListener

      public void removePlaybackStartVetoableListener(VetoableChangeListener listener)
    • firePlaybackStartVetoableChange

      public void firePlaybackStartVetoableChange(SongContext sgContext) throws PropertyVetoException
      Notify all playback start VetoableChangeListeners with a PROP_VETO_PRE_PLAYBACK property vetoable change event.
      Parameters:
      sgContext - Used as the new value of the Vetoable change
      Throws:
      PropertyVetoException