Class LXClip

All Implemented Interfaces:
LXComponent.Renamable, LXLoopTask, LXPath, LXSerializable, LXBus.Listener, LXOscComponent, LXParameterListener
Direct Known Subclasses:
LXAbstractChannelClip, LXMasterClip

public abstract class LXClip extends LXRunnableComponent implements LXOscComponent, LXComponent.Renamable, LXBus.Listener
  • Field Details

  • Constructor Details

    • LXClip

      public LXClip(LX lx, LXBus bus, int index)
    • LXClip

      protected LXClip(LX lx, LXBus bus, int index, boolean registerListener)
  • Method Details

    • CursorOp

      public final Cursor.Operator CursorOp()
    • getTimeBase

      public Cursor.TimeBase getTimeBase()
    • isPending

      public boolean isPending()
    • launch

      public LXClip launch()
      Launches the clip, subject to global launch quantization, which will also trigger recall of a snapshot if enabled
      Returns:
      this
    • launchAutomation

      public LXClip launchAutomation()
      Launches clip automation playback, subject to global launch quantization
      Returns:
      this
    • launchAutomationFrom

      public LXClip launchAutomationFrom(Cursor cursor)
      Launches the clip from a specified start position, subject to global launch quantization.
      Parameters:
      cursor - Position to launch from
      Returns:
      this
    • launchAutomationFromCursor

      public LXClip launchAutomationFromCursor()
      Launches the clip from the current cursor position
      Returns:
      this
    • playFrom

      public LXClip playFrom(Cursor cursor)
      Play clip from cursor position without quantization delay. Does nothing if the clip is already running or if it has not been initialized.
      Parameters:
      cursor -
      Returns:
      this
    • playFromCursor

      public LXClip playFromCursor()
      Play clip from cursor position without quantization delay. Does nothing unless clip is not running.
      Returns:
      this
    • triggerAction

      public LXClip triggerAction(boolean focus)
      Trigger the clip, whether from control surface or UI
      Parameters:
      focus - Whether to focus the clip
      Returns:
      this
    • triggerAction

      public LXClip triggerAction(boolean focus, boolean fromGrid)
      Trigger the clip, whether from control surface or UI
      Parameters:
      focus - Whether to focus the clip
      fromGrid - Whether this is a quantized grid launch
      Returns:
      this
    • getPath

      public String getPath()
      Description copied from class: LXComponent
      Accessor for the path of this object. Returns the path this component was registered with. Some subclasses may override this if path structure is dynamic.
      Specified by:
      getPath in interface LXPath
      Overrides:
      getPath in class LXComponent
      Returns:
      path of this component relative to its parent
    • onTrigger

      protected final void onTrigger()
      Description copied from class: LXRunnableComponent
      Optional subclass method when trigger is fired, called before onReset and onStart
      Overrides:
      onTrigger in class LXRunnableComponent
    • dispose

      public void dispose()
      Description copied from class: LXComponent
      Invoked when a component is being removed from the system and will no longer be used at all. This unregisters the component and should free up any resources and parameter listeners. Ideally after this method is called the object should be eligible for garbage collection. Subclasses are generally expected to override this method to handle their particular cleanup work. They should also generally call super.dispose() at the appropriate time to perform the basic cleanup, which may need to happen either before or after cleaning up other objects.
      Overrides:
      dispose in class LXComponent
    • getLength

      public double getLength()
    • removeParameterLane

      public LXClip removeParameterLane(ParameterClipLane lane)
    • moveClipLane

      public LXClip moveClipLane(LXClipLane<?> lane, int index)
    • addListener

      public LXClip addListener(LXClip.Listener listener)
    • removeListener

      public LXClip removeListener(LXClip.Listener listener)
    • setCursor

      protected void setCursor(LXClip.CursorParameter timestamp)
    • setCursor

      protected void setCursor(Cursor cursor)
      Move the cursor and notify listeners
    • getCursor

      public Cursor getCursor()
    • isArmed

      public boolean isArmed()
      Whether the clip is armed for recording
    • isRecording

      public boolean isRecording()
      Whether the clip is actively recording.
    • isOverdub

      public boolean isOverdub()
    • setLoopStart

      public LXClip setLoopStart(Cursor loopStart)
      Safely set the loop start marker to a specific value (in time units)
      Parameters:
      loopStart - Cursor position on the timeline
    • setLoopBrace

      public LXClip setLoopBrace(Cursor loopBrace)
      Safely set the loop brace to a position on the timeline (in time units)
      Parameters:
      loopBrace - Cursor position on the timeline
    • setLoopEnd

      public LXClip setLoopEnd(Cursor loopEnd)
      Safely set the loop end marker to a specific value (in time units)
      Parameters:
      loopEnd - Cursor position on the timeline
      Returns:
      this
    • setLoopLength

      public LXClip setLoopLength(Cursor loopLength)
      Set the loop length
      Parameters:
      loopLength - Loop length
      Returns:
      this
    • setPlayStart

      public LXClip setPlayStart(Cursor playStart)
      Safely set the play start marker to a specific value (in time units)
      Parameters:
      playStart - Cursor position on the timeline
    • setPlayEnd

      public LXClip setPlayEnd(Cursor playEnd)
      Safely set the play end marker to a specific value (in time units)
      Parameters:
      playEnd - Cursor position on the timeline
    • onParameterChanged

      public void onParameterChanged(LXParameter p)
      Description copied from class: LXComponent
      Subclasses are free to override this if desired. It will automatically fire for any listenable parameter that is registered with this component.
      Specified by:
      onParameterChanged in interface LXParameterListener
      Overrides:
      onParameterChanged in class LXRunnableComponent
      Parameters:
      p - Parameter that has a value change
    • onStart

      protected final void onStart()
      Start from a stopped state, e.g. this.running has transitioned false -> true
      Overrides:
      onStart in class LXRunnableComponent
    • onStop

      protected final void onStop()
      Stop from a rec/play state, fires when this.running has transitioned true -> false
      Overrides:
      onStop in class LXRunnableComponent
    • onStartRecording

      protected void onStartRecording(boolean isOverdub)
      Subclasses may override
      Parameters:
      isOverdub - Whether this was overdub recording
    • onStopRecording

      protected void onStopRecording()
      Subclasses may override
    • onStopPlayback

      protected void onStopPlayback()
      Subclasses may override
    • registerParameter

      protected void registerParameter(LXListenableNormalizedParameter p)
    • unregisterParameter

      protected void unregisterParameter(LXListenableNormalizedParameter p)
    • registerComponent

      protected void registerComponent(LXComponent component)
    • findClipLanes

      public List<ParameterClipLane> findClipLanes(LXComponent component)
    • unregisterComponent

      protected void unregisterComponent(LXComponent component)
    • getIndex

      public int getIndex()
    • setIndex

      public LXClip setIndex(int index)
    • run

      protected void run(double deltaMs)
      Specified by:
      run in class LXRunnableComponent
    • effectAdded

      public void effectAdded(LXBus channel, LXEffect effect)
      Specified by:
      effectAdded in interface LXBus.Listener
    • effectRemoved

      public void effectRemoved(LXBus channel, LXEffect effect)
      Specified by:
      effectRemoved in interface LXBus.Listener
    • effectMoved

      public void effectMoved(LXBus channel, LXEffect effect)
      Specified by:
      effectMoved in interface LXBus.Listener
    • constructTransportCursor

      public Cursor constructTransportCursor()
      Constructs a cursor from the global transport playback position, with millis computed using this clip's reference BPM
      Returns:
      Cursor for given time division using clip's reference BPM
    • constructTempoCursor

      public Cursor constructTempoCursor(Tempo.Division division)
      Constructs a cursor using a tempo-division reference, with millisecond value computed using this clip's reference BPM
      Parameters:
      division - Tempo division
      Returns:
      Cursor for given time division using clip's reference BPM
    • constructTempoCursor

      public Cursor constructTempoCursor(int beatCount, double beatBasis)
      Constructs a cursor using tempo-based timing with the millisecond value computed using the clip's reference BPM
      Parameters:
      beatCount - Beat count
      beatBasis - Beat basis
      Returns:
      Cursor for given time using clip's reference BPM
    • constructAbsoluteCursor

      public Cursor constructAbsoluteCursor(double millis)
      Constructs a cursor using absolute-timing, with the beat fields computed using the clip's reference BPM
      Parameters:
      millis - Absolute cursor time
      Returns:
      Cursor for given time using clip's reference BPM
    • snapLaunchQuantization

      public Cursor snapLaunchQuantization(Cursor cursor)
      Snap a value to the global quantization setting
      Parameters:
      cursor - Cursor to snap
      Returns:
      Cursor with snapping applied
    • snapTempo

      public Cursor snapTempo(Cursor cursor, Tempo.Division division)
      Snap a value to a tempo division
      Parameters:
      cursor - Value to snap
      division - Value will be rounded to the nearest multiple of this tempo division
      Returns:
      Cursor with snapping applied
    • load

      public void load(LX lx, JsonObject obj)
      Description copied from class: LXComponent
      Loads the LX component. Restores the ID of the component, as well as its internal and user-facing parameters. Any explicitly registered children will be automatically loaded, so long as they are direct descendants. Dynamic arrays will not be automatically loaded, this is left to subclasses to implement.
      Specified by:
      load in interface LXSerializable
      Overrides:
      load in class LXComponent
      Parameters:
      lx - LX instance
      obj - Object to deserialize
    • addParameterLane

      public ParameterClipLane addParameterLane(LX lx, JsonObject laneObj, int index)
    • loadLane

      protected void loadLane(LX lx, String laneType, JsonObject laneObj)
    • save

      public void save(LX lx, JsonObject obj)
      Description copied from class: LXComponent
      Serializes the LX component. By default, all internal and user-facing parameters are serialized, as well as any explicitly registered child components. Note that child arrays are not serialized, or any other dynamic components. Subclasses may override to perform more saving, and are expected to call super.save(lx, obj) at the appropriate time.
      Specified by:
      save in interface LXSerializable
      Overrides:
      save in class LXComponent
      Parameters:
      lx - LX instance
      obj - Object to serialize into