Class AudioBrush

java.lang.Object
net.paulhertz.pixelaudio.curves.AudioBrush
Direct Known Subclasses:
GranularBrush, SamplerBrush

public abstract class AudioBrush extends Object
Abstract class for combining gesture data from PACurveMaker with audio synthesis parameters from GestureGranularConfig.Builder.

In the PixelAudio library examples, a "brush" uses gesture to control sound, and can draw the gesture to the display as an interactive UI element. In other words, brushes advance the core design theme of PixelAudio: combining image and audio through structural correspondences. See the GesturePlayground sketch in the example code for a GUI-driven tour of features.

Two included subclasses, SamplerBrush and GranularBrush, model brushes for the PASamplerInstrument and PAGranularInstrument classes. Subclasses may add fields or behavior, but should preserve:

  • a stable PACurveMaker reference
  • a mutable or snapshot-based config for rendering both image and audio
Audio is typically generated either with the Sampler or Granular synthesis engine in PixelAudio.
TODO links to relevant classes
  • Field Details

    • curve

      private final PACurveMaker curve
      The PACurveMaker instance for curve data and rendering for this brush
    • cfg

      private final GestureGranularConfig.Builder cfg
      The configuration builder for audio synthesis for this brush
    • transformState

      private GestureTransformState transformState
      Optional transform state for applying geometric transformations to the curve data
  • Constructor Details

    • AudioBrush

      protected AudioBrush(PACurveMaker curve, GestureGranularConfig.Builder cfg)
      Constructs an AudioBrush with the given curve and configuration builder.
      Parameters:
      curve - a PACurveMaker instance
      cfg - a GestureGranularConfig
  • Method Details

    • curve

      public PACurveMaker curve()
      Returns the PACurveMaker instance associated with this brush.
      Returns:
      the PACurveMaker instance for this brush
    • cfg

      Returns the configuration builder associated with this brush. Mutating the builder affects subsequent rendering unless a snapshot is taken via cfg().build() or snapshot().
    • snapshot

      public GestureGranularConfig snapshot()
      Returns an immutable snapshot of the current configuration state.
    • transform

      public GestureTransformState transform()
      Returns the current transform state, or null if no transform is set.
      Returns:
      the current GestureTransformState, or null if none is set
    • setTransform

      public void setTransform(GestureTransformState state)
      Sets the transform state for this brush.
      Parameters:
      state - the GestureTransformState to set
    • hasTransform

      public boolean hasTransform()
      Checks if a transform is currently set.
      Returns:
      true if a transform is set, false otherwise
    • ensureTransform

      public GestureTransformState ensureTransform()
      Ensures that a transform state is available for this brush.
      Returns:
      the GestureTransformState for this brush
    • captureRestPoints

      public void captureRestPoints()
      Captures the untransformed rest points for the current transform state.
    • applyTransform

      public void applyTransform()
      Applies the current transform to the curve.
    • restoreTransform

      public void restoreTransform()
      Restores the original transform for the curve.