Class PlaybackSettings

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

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

Property change events are fired when settings are modified.

  • Field Details

  • 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.
    • getChordSymbolsDisplayTransposition

      public int getChordSymbolsDisplayTransposition()
      Get the key transposition applied to chord symbols shown in the UI.
      Returns:
      [0, 12) Default is 0.
    • setChordSymbolsDisplayTransposition

      public void setChordSymbolsDisplayTransposition(int transposition)
      Set the key transposition applied to chord symbols shown in the UI.

      Ex: if transposition=2, chord=B7 will be shown as C#7.

      Parameters:
      transposition - int in range [0, 12)
    • 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)