Class MCBufferSource

java.lang.Object
net.paulhertz.pixelaudio.granular.MCBufferSource
All Implemented Interfaces:
PAFloatSource, PASource

public class MCBufferSource extends Object implements PASource
MCBufferSource A simple PASource that wraps a Minim MultiChannelBuffer for linear playback. This is a natural building block for PASamplerInstrument when you want to work directly with buffer-backed sample sources. NOTE: - This class does not manage playback position on its own; typically a PASamplerVoice will determine which segment to read and call renderBlock(...) accordingly. - For mono buffers, MultiChannelBuffer should have 1 channel. - For stereo or multi-channel, the mixing logic belongs in renderBlock().
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final ddf.minim.MultiChannelBuffer
     
    private int
     
    private ddf.minim.analysis.WindowFunction
     
    private final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    MCBufferSource(ddf.minim.MultiChannelBuffer buffer)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    ddf.minim.MultiChannelBuffer
    Optional access to an underlying MultiChannelBuffer, if this source is fundamentally buffer-backed (e.g., plain sample playback or a rendered granular "tape").
    long
    Duration in samples, or Long.MAX_VALUE if effectively infinite/streaming.
    Pitch policy hint for the instrument: should the instrument apply its pitch (playback rate) on top of this source?
    void
    renderBlock(long blockStart, int blockSize, float[] outL, float[] outR)
    Render audio into the given block buffers.
    void
    setGrainWindow(ddf.minim.analysis.WindowFunction wf, int grainLenSamples)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.paulhertz.pixelaudio.granular.PASource

    seekTo
  • Field Details

    • buffer

      private final ddf.minim.MultiChannelBuffer buffer
    • lengthSamples

      private final long lengthSamples
    • grainWindow

      private ddf.minim.analysis.WindowFunction grainWindow
    • grainLenSamples

      private int grainLenSamples
  • Constructor Details

    • MCBufferSource

      public MCBufferSource(ddf.minim.MultiChannelBuffer buffer)
  • Method Details

    • renderBlock

      public void renderBlock(long blockStart, int blockSize, float[] outL, float[] outR)
      Description copied from interface: PAFloatSource
      Render audio into the given block buffers. Implementations should: - Assume outL/outR length >= blockSize. - Mix into outL/outR (add), not clear them. - Avoid allocation on the audio thread.
      Specified by:
      renderBlock in interface PAFloatSource
      Parameters:
      blockStart - the absolute sample index in the source’s own sample domain (e.g., buffer index space).
      blockSize - number of samples in this block.
      outL - left channel buffer to mix into.
      outR - right channel buffer to mix into (may be same as outL for mono).
    • lengthSamples

      public long lengthSamples()
      Description copied from interface: PAFloatSource
      Duration in samples, or Long.MAX_VALUE if effectively infinite/streaming.
      Specified by:
      lengthSamples in interface PAFloatSource
    • getMultiChannelBuffer

      public ddf.minim.MultiChannelBuffer getMultiChannelBuffer()
      Description copied from interface: PASource
      Optional access to an underlying MultiChannelBuffer, if this source is fundamentally buffer-backed (e.g., plain sample playback or a rendered granular "tape"). Implementations that are not backed by a fixed buffer (true streams, procedural sources, etc.) should simply return null.
      Specified by:
      getMultiChannelBuffer in interface PASource
    • pitchPolicy

      public PitchPolicy pitchPolicy()
      Description copied from interface: PASource
      Pitch policy hint for the instrument: should the instrument apply its pitch (playback rate) on top of this source?
      Specified by:
      pitchPolicy in interface PASource
    • setGrainWindow

      public void setGrainWindow(ddf.minim.analysis.WindowFunction wf, int grainLenSamples)
      Specified by:
      setGrainWindow in interface PASource