Class LegacyGranularPathBuilder

java.lang.Object
net.paulhertz.pixelaudio.granular.LegacyGranularPathBuilder

@Deprecated(since="9.5", forRemoval=false) public final class LegacyGranularPathBuilder extends Object
Deprecated.
TODO Candidate for removal GranularPathBuilder Utility to convert a PACurveMaker path + PixelAudioMapper into a GranularPath. Uses the reduced point set (RDP). PACurveMaker can change the amount of reduction by varying PACurveMaker.epsilon and calling PACurveMaker.calculateDerivedPoints() to redraw curves. TODO Pitch and other parameters can be modulated based on gesture dynamics, for example from a pressure-sensitive tablet.
  • Constructor Details

    • LegacyGranularPathBuilder

      private LegacyGranularPathBuilder()
      Deprecated.
  • Method Details

    • fromRdpPoints

      public static GranularPath fromRdpPoints(PACurveMaker curve, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength)
      Deprecated.
      Build a GranularPath from the RDP points of a PACurveMaker. Use GranularSettings.TimingMode.FIXED_HOP when you play samples. If you use GESTURE_TIMED all samples will play at once.
      Parameters:
      curve - PACurveMaker holding gesture data
      mapper - PixelAudioMapper to convert (x,y) → sample index
      canvasWidth - for mapping x → pan
      canvasHeight - (not used yet; could map y → gain or pitch)
      grainLength - grain length in samples (per-grain)
      Returns:
      GranularPath suitable for PathGranularSource
    • fromBezierPoints

      public static GranularPath fromBezierPoints(PACurveMaker curve, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int curveSteps)
      Deprecated.
      Build a GranularPath from the polygonized Bezier points of a PACurveMaker. Use GranularSettings.TimingMode.FIXED_HOP when you play samples. If you use GESTURE_TIMED all samples will play at once.
      Parameters:
      curve - PACurveMaker holding gesture data
      mapper - PixelAudioMapper to convert (x,y) → sample index
      canvasWidth - for mapping x → pan
      canvasHeight - (not used yet; could map y → gain or pitch)
      grainLength - grain length in samples (per-grain)
      curveSteps - number of divisions in each Bezier segment
      Returns:
      GranularPath suitable for PathGranularSource
    • fromDragPoints

      public static GranularPath fromDragPoints(PACurveMaker curve, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength)
      Deprecated.
      Build a GranularPath from the drag points of a PACurveMaker, i.e., the unique points input by dragging the mouse. Use GranularSettings.TimingMode.FIXED_HOP when you play samples. If you use GESTURE_TIMED all samples will play at once.
      Parameters:
      curve - PACurveMaker holding gesture data
      mapper - PixelAudioMapper to convert (x,y) → sample index
      canvasWidth - for mapping x → pan
      canvasHeight - (not used yet; could map y → gain or pitch)
      grainLength - grain length in samples (per-grain)
      Returns:
      GranularPath suitable for PathGranularSource
    • getDragTimes

      public static int[] getDragTimes(PACurveMaker curve)
      Deprecated.
      Returns a list of time offsets in milliseconds for PACurveMaker curve, where each offset corresponds to a point in curve.dragPoints. Both arrays are created by a mouse gesture.
      Parameters:
      curve - a PACurveMaker object
      Returns:
    • fromTimedDragPoints

      public static GranularPath fromTimedDragPoints(PACurveMaker curve, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, float sampleRate)
      Deprecated.
      Build a GranularPath from the drag points of a PACurveMaker, i.e., the unique points input by dragging the mouse, with grain intervals determined by the time each point was drawn.
      Parameters:
      curve - PACurveMaker holding gesture data
      mapper - PixelAudioMapper to convert (x,y) → sample index
      canvasWidth - for mapping x → pan
      canvasHeight - (not used yet; could map y → gain or pitch)
      grainLength - grain length in samples (per-grain)
      Returns:
      GranularPath suitable for PathGranularSource
    • fromTimedDragPointsResampled

      public static GranularPath fromTimedDragPointsResampled(PACurveMaker curve, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int targetCount, float sampleRate)
      Deprecated.
      Build a timed GranularPath from the drag points, but first resample the gesture (time + location) to targetCount samples. This lets you: - reduce or increase the point count - preserve the original gesture duration and coarse timing structure
    • fromTimedDragPointsResampledToDuration

      public static GranularPath fromTimedDragPointsResampledToDuration(PACurveMaker curve, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int targetCount, int targetDurationMs, float sampleRate)
      Deprecated.
      Build a timed GranularPath from drag points, resampling the gesture to targetCount samples and scaling it to a total duration of targetDurationMs milliseconds. This lets you say: "Give me N grains over D ms, following the same gesture."
    • fromBezierParametric

      public static GranularPath fromBezierParametric(PACurveMaker curve, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int curveSteps, int targetCount, int totalDurationMs, float sampleRate)
      Deprecated.
      Build a timed GranularPath from the polygonized Bezier path, sampling it parametrically with u ∈ [0,1] over the path indices. Each grain k uses: u = k / (targetCount - 1) p = pathParam.sample(u) timeOffsetMs = u * totalDurationMs
      Parameters:
      curve - PACurveMaker holding Bezier data
      mapper - PixelAudioMapper to convert (x,y) → sample index
      canvasWidth - for x → pan and bounds
      canvasHeight - for y bounds
      grainLength - grain length in samples
      curveSteps - number of divisions per Bezier segment
      targetCount - number of grains along the path
      totalDurationMs - total duration of the path in ms
    • fromBezierParametricWarped

      public static GranularPath fromBezierParametricWarped(PACurveMaker curve, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int curveSteps, int targetCount, int totalDurationMs, float sampleRate, DoubleUnaryOperator warp)
      Deprecated.
      General Bezier-parametric builder with optional time warp. u ∈ [0,1] is: - the spatial parameter over the Bezier polyline (via PAPathParametric) - also the base for time mapping; timeOffsetMs = f(u) * totalDurationMs If warp is null, f(u) = u (linear time).
    • fromBezierWithGestureTiming

      public static GranularPath fromBezierWithGestureTiming(PACurveMaker curve, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int curveSteps, float sampleRate)
      Deprecated.
      Build a timed GranularPath that uses: - the Bezier path for spatial positions (via getEventPoints/PAPathParametric), - the drag gesture's timing (via getDragOffsetsAsInts) for timeOffsetMs. For each drag time t_i: u = t_i / totalGestureDuration p = BezierPath(u) timeOffsetMs = t_i This maps the *rhythm* of the original gesture onto the *shape* of the Bezier path.
    • fromBezierWithGestureTimingScaled

      public static GranularPath fromBezierWithGestureTimingScaled(PACurveMaker curve, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int curveSteps, int targetDurationMs, float sampleRate)
      Deprecated.
    • fromPointToLinearPath

      public static GranularPath fromPointToLinearPath(int x, int y, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int hopLength, int numGrains, float sampleRate)
      Deprecated.
      Build a linear path from a point, equivalent to "classic" granular synthesis.
      Parameters:
      x - x-coordinate on where user clicked display
      y - y-coordinate
      mapper - PixelAudioMapper for pixel to signal mapping
      canvasWidth - display image width
      canvasHeight - display image height
      grainLength - length of grains in samples
      hopLength - distance to advance from on grain to the next
      numGrains - total number of grains
      Returns:
      a GranularPath
    • fromPointToLinearPathDuration

      public static GranularPath fromPointToLinearPathDuration(int x, int y, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int hopLength, float durationMs, float sampleRate)
      Deprecated.
    • fromPointToLinearPathTimedAndPitched

      public static GranularPath fromPointToLinearPathTimedAndPitched(int x, int y, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int hopLength, int numGrains, float sampleRate, float timeStretch, float pitchRatio)
      Deprecated.
      Build a linear path from a point, classic granular synthesis with optional time-stretch and pitch-shift. All timing is in samples; no ms inside the builder.
      Parameters:
      x - x-coordinate where user clicked display
      y - y-coordinate
      mapper - PixelAudioMapper for pixel to signal mapping
      canvasWidth - display image width
      canvasHeight - display image height
      grainLength - length of grains in samples
      hopLength - base hop in samples (reference hop)
      numGrains - total number of grains
      sampleRate - playback sample rate (e.g. 44100) — only used to sanity-check, not required for math
      timeStretch - factor for overall duration (1.0 = original, 2.0 = twice as long, 0.5 = twice as fast)
      pitchRatio - factor for how fast we walk the buffer (1.0 = original, 2.0 = up an octave-ish, 0.5 = down)
    • fromTimedDragParametric

      public static GranularPath fromTimedDragParametric(PACurveMaker curve, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int targetCount, int targetDurationMs, float sampleRate, DoubleUnaryOperator warp)
      Deprecated.
    • fromTimedDragParametric

      public static GranularPath fromTimedDragParametric(ArrayList<processing.core.PVector> dragPoints, int[] dragTimes, PixelAudioMapper mapper, int canvasWidth, int canvasHeight, int grainLength, int targetCount, int targetDurationMs, float sampleRate, DoubleUnaryOperator warp)
      Deprecated.
    • msToSamples

      private static long msToSamples(int tMs, float sampleRate)
      Deprecated.
    • mapXToPan

      private static float mapXToPan(float x, int width)
      Deprecated.
    • clampToCanvas

      private static int clampToCanvas(int v, int max)
      Deprecated.
    • lerp

      private static float lerp(float a, float b, float u)
      Deprecated.