Package net.paulhertz.pixelaudio.voices
Class PASamplerInstrumentPoolMulti
java.lang.Object
net.paulhertz.pixelaudio.voices.PASamplerInstrumentPoolMulti
- All Implemented Interfaces:
PAPlayable,PASamplerPlayable
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPASamplerInstrumentPoolMulti(ddf.minim.AudioOutput out) 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 Summary
Modifier and TypeMethodDescriptionvoidaddPool(String key, ddf.minim.MultiChannelBuffer buffer, float bufferSampleRate, int poolSize, int perInstrumentVoices, ddf.minim.AudioOutput out, ADSRParams env) voidclose()Close all sub-pools and release shared resources.private PASamplerInstrumentPoolcurrent()Returns the currently active sub-pool (may be null).voidgetPoolByTag(String tag) intgetPools()booleanbooleanisClosed()booleanintplay(float amplitude, float pitch, float pan) Plays the instrument's entire buffer, from PAPlayable interface.intplay(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.intplaySample(int samplePos, int sampleLen, float amplitude) Play subrange with amplitude only.intplaySample(int samplePos, int sampleLen, float amplitude, float pitch) Play subrange with amplitude and pitch (no envelope).intplaySample(int samplePos, int sampleLen, float amplitude, float pitch, float pan) intplaySample(int samplePos, int sampleLen, float amplitude, ADSRParams env) intplaySample(int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch) intplaySample(int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch, float pan) Play a subrange of the buffer with full parameters.intplaySample(ddf.minim.MultiChannelBuffer buffer, int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch) intplaySample(ddf.minim.MultiChannelBuffer buffer, int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch, float pan) intplaySample(String tag, int samplePos, int sampleLen, float amplitude, ADSRParams env, float pitch, float pan) voidremovePool(String key) Remove a pool by key and close it safely.voidresizeAllPools(int newPoolSize, int newVoicesPerInstrument) Adjust size or polyphony of all sub-pools gracefully.voidActivate the given pool key for subsequent play() calls.voidsetBuffer(float[] newBuffer, float newSampleRate) Propagate float[] buffer to all sub-pools (mono assumption).voidsetBuffer(ddf.minim.MultiChannelBuffer newBuffer) Propagate new buffer to all sub-pools, keeping sample rates intact.voidsetBuffer(ddf.minim.MultiChannelBuffer newBuffer, float newSampleRate) Propagate new buffer and sample rate to all sub-pools.voidstop()Stop playback immediately (implementation-defined).voidstopAll()voidUpdate sample rates of all sub-pools from AudioOutput.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.paulhertz.pixelaudio.voices.PAPlayable
play, play, play, play, playMethods inherited from interface net.paulhertz.pixelaudio.voices.PASamplerPlayable
playSample, playSample, playSample, playSample, playSample
-
Field Details
-
out
private final ddf.minim.AudioOutput out -
pools
-
activeKey
-
isClosed
private boolean isClosed
-
-
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
Remove a pool by key and close it safely. -
current
Returns the currently active sub-pool (may be null). -
setActive
Activate the given pool key for subsequent play() calls. -
getActiveKey
-
play
public int play(float amplitude, float pitch, float pan) Plays the instrument's entire buffer, from PAPlayable interface.- Specified by:
playin interfacePAPlayable- 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:PAPlayableStop playback immediately (implementation-defined).- Specified by:
stopin interfacePAPlayable
-
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:
playin interfacePASamplerPlayable
-
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:PASamplerPlayablePlay a subrange of the buffer with full parameters.- Specified by:
playSamplein interfacePASamplerPlayable
-
playSample
-
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:PASamplerPlayablePlay subrange with amplitude only.- Specified by:
playSamplein interfacePASamplerPlayable
-
playSample
public int playSample(int samplePos, int sampleLen, float amplitude, float pitch) Description copied from interface:PASamplerPlayablePlay subrange with amplitude and pitch (no envelope).- Specified by:
playSamplein interfacePASamplerPlayable
-
playSample
-
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
-
getPoolByTag
-
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
-
debugPrintState
public void debugPrintState()
-