Class PASamplerInstrumentPoolMulti

java.lang.Object
net.paulhertz.pixelaudio.voices.PASamplerInstrumentPoolMulti
All Implemented Interfaces:
PAPlayable, PASamplerPlayable

public class PASamplerInstrumentPoolMulti extends Object implements PASamplerPlayable, PAPlayable
PASamplerInstrumentPoolMulti Manages multiple PASamplerInstrumentPool instances, each keyed by name. Each sub-pool may represent a distinct sample source or timbral layer. Features: - Dynamic add/remove of sub-pools - Shared AudioOutput - Optional active-key routing (only one pool plays at a time) - Global stop, buffer, and sample-rate propagation - Graceful resizing using PASamplerInstrumentPool’s gentle reinit Thread-safe and compatible with both PAPlayable and PASamplerPlayable.
  • Field Details

  • Constructor Details

    • PASamplerInstrumentPoolMulti

      public PASamplerInstrumentPoolMulti(ddf.minim.AudioOutput out)
    • PASamplerInstrumentPoolMulti

      public PASamplerInstrumentPoolMulti(String key, ddf.minim.MultiChannelBuffer buffer, float sampleRate, int poolSize, int perInstrumentVoices, ddf.minim.AudioOutput out, ADSRParams adsr)
      Convenience constructor for single-pool initialization.
  • Method Details

    • addPool

      public void addPool(String key, ddf.minim.MultiChannelBuffer buffer, float bufferSampleRate, int poolSize, int perInstrumentVoices, ddf.minim.AudioOutput out, ADSRParams env)
    • removePool

      public void removePool(String key)
      Remove a pool by key and close it safely.
    • current

      private PASamplerInstrumentPool current()
      Returns the currently active sub-pool (may be null).
    • setActive

      public void setActive(String key)
      Activate the given pool key for subsequent play() calls.
    • getActiveKey

      public String getActiveKey()
    • play

      public int play(float amplitude, float pitch, float pan)
      Plays the instrument's entire buffer, from PAPlayable interface.
      Specified by:
      play in interface PAPlayable
      Parameters:
      amplitude - gain multiplier (0..1+)
      pitch - playback rate or pitch factor (implementation-defined)
      pan - stereo pan (-1 left .. +1 right)
      Returns:
      non-zero if a voice/event was triggered
    • stop

      public void stop()
      Description copied from interface: PAPlayable
      Stop playback immediately (implementation-defined).
      Specified by:
      stop in interface PAPlayable
    • play

      public int play(int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch, float pan)
      PASamplerPlayable's play method, all six standard parameters in standard order, called by other methods.
      Specified by:
      play in interface PASamplerPlayable
    • isLooping

      public boolean isLooping()
    • stopAll

      public void stopAll()
    • playSample

      public int playSample(int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch, float pan)
      Description copied from interface: PASamplerPlayable
      Play a subrange of the buffer with full parameters.
      Specified by:
      playSample in interface PASamplerPlayable
    • playSample

      public int playSample(int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch)
    • playSample

      public int playSample(int samplePos, int sampleLen, float amplitude, float pitch, float pan)
    • playSample

      public int playSample(int samplePos, int sampleLen, float amplitude)
      Description copied from interface: PASamplerPlayable
      Play subrange with amplitude only.
      Specified by:
      playSample in interface PASamplerPlayable
    • playSample

      public int playSample(int samplePos, int sampleLen, float amplitude, float pitch)
      Description copied from interface: PASamplerPlayable
      Play subrange with amplitude and pitch (no envelope).
      Specified by:
      playSample in interface PASamplerPlayable
    • playSample

      public int playSample(int samplePos, int sampleLen, float amplitude, ADSRParams env)
    • playSample

      public int playSample(ddf.minim.MultiChannelBuffer buffer, int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch, float pan)
    • playSample

      public int playSample(ddf.minim.MultiChannelBuffer buffer, int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch)
    • playSample

      public int playSample(String tag, int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch, float pan)
    • hasPool

      public boolean hasPool(String tag)
    • getPoolByTag

      public PASamplerInstrumentPool getPoolByTag(String tag)
    • setBuffer

      public void setBuffer(ddf.minim.MultiChannelBuffer newBuffer)
      Propagate new buffer to all sub-pools, keeping sample rates intact.
    • setBuffer

      public void setBuffer(ddf.minim.MultiChannelBuffer newBuffer, float newSampleRate)
      Propagate new buffer and sample rate to all sub-pools.
    • setBuffer

      public void setBuffer(float[] newBuffer, float newSampleRate)
      Propagate float[] buffer to all sub-pools (mono assumption).
    • updateRateFromOutput

      public void updateRateFromOutput()
      Update sample rates of all sub-pools from AudioOutput.
    • resizeAllPools

      public void resizeAllPools(int newPoolSize, int newVoicesPerInstrument)
      Adjust size or polyphony of all sub-pools gracefully.
    • close

      public void close()
      Close all sub-pools and release shared resources.
    • isClosed

      public boolean isClosed()
    • getPoolCount

      public int getPoolCount()
    • getPools

      public Map<String,PASamplerInstrumentPool> getPools()
    • debugPrintState

      public void debugPrintState()