index of namespace default
 
 index of project tksampler
 
 index of module tksampler

Class tksampler.StSamplePlayer


SynopsisManages a finite number of StSampleVoice objects

  Base classes:
  Methods:
  Constants:

Method allNotesOff
Stop all currently playing voices (with fadeout but no release)
Signature
allNotesOff()

 
 top of page
Method allNotesOffRelease
Release all currently playing voices (like regular note offs)
Signature
allNotesOffRelease()

 
 top of page
Method allocVoices
Allocate internal voice pool
Signature
allocVoices(intmaxPolyphony)
 :boolean
Arguments
intmaxPolyphony
Returns
boolean1(true) if the allocation succeeded, 0(false) otherwise.

 
 top of page
Method findFirstActiveSampleVoice
Query voice object
Signature
findFirstActiveSampleVoice(StSamplesample)
 :StSampleVoice
Arguments
StSamplesample
Returns

 
 top of page
Method findLastStartedVoice
Query voice object
Signature
findLastStartedVoice(StSamplesample)
 :StSampleVoice
Arguments
StSamplesample
Returns

 
 top of page
Method findPreviousGlideNoteByKey
Return -1 or glide_prev_note for first gliding voice that is assigned the given voicekey.
Signature
findPreviousGlideNoteByKey(intkey)
 :int historyIdx:int
Arguments
intkeyvoice key
Returns
int historyIdx:int

 
 top of page
Method findVoicesByKey
Find all voices that are assigned the given key.
Signature
findVoicesByKey(intkey,
  PointerArrayret 
  )  
 :int
Arguments
intkey
PointerArrayret
Returns
intNumber of voices added to array.

 
 top of page
Method getDefaultFreqTable
Query default frequency table
Signature
getDefaultFreqTable():FloatArray
Returns

 
 top of page
Method getDefaultMixRate
Query default mixrate
Signature
getDefaultMixRate():float
Returns
float

 
 top of page
Method getNumActiveNotes
Query number of currently (pressed) notes
Signature
getNumActiveNotes():int
Returns
int

 
 top of page
Method getNumActiveVoices
Query number of currently used (allocated) voices
Signature
getNumActiveVoices():int
Returns
int

 
 top of page
Method getNumPlayingVoices
Query number of currently used (allocated+playing) voices
Signature
getNumPlayingVoices():int
Returns
int

 
 top of page
Method getNumUsedVoices
Query number of currently used voices
Signature
getNumUsedVoices():int
Returns
int

 
 top of page
Method getNumVoices
Query polyphony
Signature
getNumVoices():int
Returns
int

 
 top of page
Method getPolyMode
Query voice allocation strategy
Signature
getPolyMode():int
Returns
intCurrent poly mode (default = STSAMPLEPLAYER_POLYMODE_OLDEST)

 
 top of page
Method getVoice
Query voice object
Signature
getVoice(intidx)
 :StSampleVoice
Arguments
intidx
Returns

 
 top of page
Method getVolume
Signature
getVolume():float
Returns
float

 
 top of page
Method initStartedVoicesByKey
Really trigger note-on. Should be called after (initial) params have been set.
Signature
initStartedVoicesByKey(intkey)
Arguments
intkey

 
 top of page
Method noteOff
Begin release phase of all voices that were triggered on the given key
Signature
noteOff(intnote,
  floatvelocity 
  )  
 :int
Arguments
intnoteMIDI note (0..127)
floatvelocityNote-off velocity (0..1)
Returns
intNumber of voices affected (0..n)

 
 top of page
Method noteOffByKey
Begin release phase of all voices that share the given voice key
Signature
noteOffByKey(intvoiceKey,
  floatvelocity 
  )  
 :int
Arguments
intvoiceKeyVoice key
floatvelocityNote-off velocity (0..1)
Returns
intNumber of voices affected (0..n)

 
 top of page
Method removeFromGlideNoteHistory
Iterate voices and remove given note from glide note histories
Signature
removeFromGlideNoteHistory(intnote,
  booleanbLastOnly 
  )  
Arguments
intnote
booleanbLastOnlyOnly remove when note is latest in history

 
 top of page
Method render
Render currently playing voices to the given (stereo) buffer (add).
Signature
render(FloatArraybuf)
Arguments
FloatArraybufRender buffer. numElements/2 determines the number of samples to render.

 
 top of page
Method renderWithInputs
Render currently playing voices to the given (stereo) buffer (add).
Signature
renderWithInputs(FloatArraybuf,
  PointerArraypaInputs,
  booleanbRender 
  )  
Arguments
FloatArraybufRender buffer. numElements/2 determines the number of samples to render.
PointerArraypaInputsPointerArray of FloatArrays (mono inputs, up to STSAMPLE_MAX_INPUTS (4) FloatArrays)
booleanbRender1=generate outputs, 0=process inputs only

 
 top of page
Method reset
Immediately reset / stop all voices (no fadeout)
Signature
reset()

 
 top of page
Method resetLFOAuxPhase
Reset aux LFO phase
Signature
resetLFOAuxPhase()

 
 top of page
Method resetLFOFreqPhase
Reset frequency LFO phase
Signature
resetLFOFreqPhase()

 
 top of page
Method resetLFOPanPhase
Reset panning LFO phase
Signature
resetLFOPanPhase()

 
 top of page
Method resetLFOVolPhase
Reset volume LFO phase
Signature
resetLFOVolPhase()

 
 top of page
Method resetModulator
Reset all modulators
Signature
resetModulator()

 
 top of page
Method restartVoicesByKey
Reset playing voices.
Signature
restartVoicesByKey(intkey)
Arguments
intkey

 
 top of page
Method setDefaultFreqTable
Set default frequency table for new sample voices
Signature
setDefaultFreqTable(FloatArrayfreqTable)
Arguments
FloatArrayfreqTable
Description

This table is used when the freqTable argument in calls to startSample() or startSampleBank() is null and the sample bank's default_tuning_table_idx / forced_tuning_table_idx does ot map to a valid table.

 
 top of page
Method setDefaultMixRate
Set default mixrate for new sample voices
Signature
setDefaultMixRate(floatmixRate)
Arguments
floatmixRate
Description

(initial value is 48000Hz)

 
 top of page
Method setPolyMode
Select voice allocation strategy
Signature
setPolyMode(intmode)
Arguments
intmode
Description

@mode See STSAMPLEPLAYER_POLYMODE_xxx constants, e.g. STSAMPLEPLAYER_POLYMODE_OLDEST

 
 top of page
Method setSoftPedal
Update soft pedal state (0..1) (for zone mod matrix)
Signature
setSoftPedal(floatval)
Arguments
floatval

 
 top of page
Method setSustainPedal
Update sustain pedal state (0..1) (for zone mod matrix)
Signature
setSustainPedal(floatval)
Arguments
floatval

 
 top of page
Method setVolume
Signature
setVolume(floatvolume)
Arguments
floatvolume

 
 top of page
Method startSample
Allocate voice and prepare to play the given sample.
Signature
startSample(StSamplesample,
  FloatArrayfreqTableOrNull,
  intnote,
  floatvelocity,
  floatmod 
  )  
 :int
Arguments
StSamplesampleWhich sample to play
FloatArrayfreqTableOrNull
intnoteWhich note to play (0..127)
floatvelocityNote-on velocity (0..1)
floatmodModulation
Returns
intVoice key (incremental)
Description

Any voice that plays a sample belonging to the same mutex group will be canceled.
initStartedVoicesByKey() must be called to actually initialize the voice.

See also:  


 
 top of page
Method startSampleBank
Allocate voice(s) and play the samplebank samples that match the given note/velo/mod zones.
Signature
startSampleBank(StSampleBanksampleBank,
  FloatArrayfreqTableOrNull,
  intnote,
  floatvelocity,
  floatmod 
  )  
 :int
Arguments
StSampleBanksampleBank
FloatArrayfreqTableOrNullFrequency table override (scale)
intnoteWhich note to play (0..127)
floatvelocityNote-on velocity (0..1)
floatmodModulation
Returns
intVoice key (incremental)
Description

Any voice that plays a sample belonging to the same mutex group(s) will be canceled.
initStartedVoicesByKey() must be called to actually initialize the voice.

See also:  


 
 top of page
Method stopADSRFreqBySample
Immediately stop all frequency ADSRs that belong to voices that play the given sample.
Signature
stopADSRFreqBySample(StSamplesample)
Arguments
StSamplesample
Description
This is called when deleting an ADSR in the UI while the voice is playing.

 
 top of page
Method stopADSRPanBySample
Immediately stop all pan ADSRs that belong to voices that play the given sample.
Signature
stopADSRPanBySample(StSamplesample)
Arguments
StSamplesample
Description
This is called when deleting an LFO in the UI while the voice is playing.

 
 top of page
Method stopADSRVolBySample
Immediately stop all volume ADSRs that belong to voices that play the given sample.
Signature
stopADSRVolBySample(StSamplesample)
Arguments
StSamplesample
Description
This is called when deleting an ADSR in the UI while the voice is playing.

 
 top of page
Method stopLFOFreqBySample
Immediately stop all frequency LFOs that belong to voices that play the given sample.
Signature
stopLFOFreqBySample(StSamplesample)
Arguments
StSamplesample
Description
This is called when deleting an LFO in the UI while the voice is playing.

 
 top of page
Method stopLFOPanBySample
Immediately stop all pan LFOs that belong to voices that play the given sample.
Signature
stopLFOPanBySample(StSamplesample)
Arguments
StSamplesample
Description
This is called when deleting an LFO in the UI while the voice is playing.

 
 top of page
Method stopLFOVolBySample
Immediately stop all volume LFOs that belong to voices that play the given sample.
Signature
stopLFOVolBySample(StSamplesample)
Arguments
StSamplesample
Description
This is called when deleting an LFO in the UI while the voice is playing.

 
 top of page
Method stopVoicesByKey
Immediately stop all voices that are assigned the given key (no fadeout)
Signature
stopVoicesByKey(intvoiceKey)
Arguments
intvoiceKey
Description
This is called when muting a track.

 
 top of page
Method stopVoicesBySample
Immediately stop all voices that play the given sample (no fadeout)
Signature
stopVoicesBySample(StSamplesample)
Arguments
StSamplesample
Description
This is called when modifying the sample's waveform.

 
 top of page
Method stopVoicesBySample
Stop all voices that play the given sample (with fadeout)
Signature
stopVoicesBySample(StSamplesample)
Arguments
StSamplesample

 
 top of page
Method updateAAuxSpd
Update aux attack speed of all active voices
Signature
updateAAuxSpd(floatint)
Arguments
floatint

 
 top of page
Method updateADSFreqInt
Update frequency ADSR intensity of all active voices
Signature
updateADSFreqInt(floatint)
Arguments
floatint

 
 top of page
Method updateADSRAuxInt
Update aux ADSR intensity of all active voices
Signature
updateADSRAuxInt(floatint)
Arguments
floatint

 
 top of page
Method updateADSRAuxLvl
Update aux ADSR level of all active voices
Signature
updateADSRAuxLvl(floatlvl)
Arguments
floatlvl

 
 top of page
Method updateADSRAuxSpd
Update aux ADSR speed of all active voices
Signature
updateADSRAuxSpd(floatspd)
Arguments
floatspd

 
 top of page
Method updateADSRFreqLvl
Update frequency ADSR level of all active voices
Signature
updateADSRFreqLvl(floatlvl)
Arguments
floatlvl

 
 top of page
Method updateADSRFreqSpd
Update frequency ADSR speed of all active voices
Signature
updateADSRFreqSpd(floatspd)
Arguments
floatspd

 
 top of page
Method updateADSRPanInt
Update pan ADSR intensity of all active voices
Signature
updateADSRPanInt(floatint)
Arguments
floatint

 
 top of page
Method updateADSRPanLvl
Update pan ADSR level of all active voices
Signature
updateADSRPanLvl(floatlvl)
Arguments
floatlvl

 
 top of page
Method updateADSRPanSpd
Update pan ADSR speed of all active voices
Signature
updateADSRPanSpd(floatspd)
Arguments
floatspd

 
 top of page
Method updateADSRVolInt
Update volume ADSR intensity of all active voices
Signature
updateADSRVolInt(floatint)
Arguments
floatint

 
 top of page
Method updateADSRVolLvl
Update volume ADSR level of all active voices
Signature
updateADSRVolLvl(floatlvl)
Arguments
floatlvl

 
 top of page
Method updateADSRVolSpd
Update volume ADSR speed of all active voices
Signature
updateADSRVolSpd(floatspd)
Arguments
floatspd

 
 top of page
Method updateAFreqSpd
Update freq attack speed of all active voices
Signature
updateAFreqSpd(floatint)
Arguments
floatint

 
 top of page
Method updateAltVolume
Update alternative volume modulation of all active voices
Signature
updateAltVolume(floatv)
Arguments
floatv

 
 top of page
Method updateAPanSpd
Update pan attack speed of all active voices
Signature
updateAPanSpd(floatint)
Arguments
floatint

 
 top of page
Method updateAVolSpd
Update volume attack speed of all active voices
Signature
updateAVolSpd(floatint)
Arguments
floatint

 
 top of page
Method updateCycleLen
Update timestretch granularity modulation of all active voices
Signature
updateCycleLen(floatv)
Arguments
floatv

 
 top of page
Method updateFltCutOff
Update filter cutoff of all active voices
Signature
updateFltCutOff(floatf)
Arguments
floatf

 
 top of page
Method updateFltOffset
Update filter offset of all active voices
Signature
updateFltOffset(floatf)
Arguments
floatf

 
 top of page
Method updateFltPan
Update filter panning of all active voices
Signature
updateFltPan(floatf)
Arguments
floatf

 
 top of page
Method updateFltRes
Update filter resonance of all active voices
Signature
updateFltRes(floatf)
Arguments
floatf

 
 top of page
Method updateFreq
Update frequency modulation of all active voices
Signature
updateFreq(floatv)
Arguments
floatv

 
 top of page
Method updateFreq2
Update frequency modulation #2 of all active voices
Signature
updateFreq2(floatv)
Arguments
floatv

 
 top of page
Method updateGlideSpeed
Update glide speed of all active voices
Signature
updateGlideSpeed(floatspeed)
Arguments
floatspeed

 
 top of page
Method updateGlideSwitch
Update glide switch of all active voices
Signature
updateGlideSwitch(booleanbEnable)
Arguments
booleanbEnable

 
 top of page
Method updateJumpToLoop
Make all playing voices jump to the given loop
Signature
updateJumpToLoop(intidx)
Arguments
intidx

 
 top of page
Method updateJumpToLoopRel
Make all playing voices jump to the given loop (0..1 => 0..num_loops-1)
Signature
updateJumpToLoopRel(intidx)
Arguments
intidx

 
 top of page
Method updateLFOAuxFltAmt
Update aux LFO => filter cutoff amount modifier
Signature
updateLFOAuxFltAmt(floatamt)
Arguments
floatamt

 
 top of page
Method updateLFOAuxLvl
Update aux LFO level of all active voices
Signature
updateLFOAuxLvl(floatlvl)
Arguments
floatlvl

 
 top of page
Method updateLFOAuxSpd
Update aux LFO speed of all active voices
Signature
updateLFOAuxSpd(floatspd)
Arguments
floatspd

 
 top of page
Method updateLFOFreqAmt
Update frequency LFO => frequency amount modifier
Signature
updateLFOFreqAmt(floatamt)
Arguments
floatamt

 
 top of page
Method updateLFOFreqLvl
Update frequency LFO level of all active voices
Signature
updateLFOFreqLvl(floatlvl)
Arguments
floatlvl

 
 top of page
Method updateLFOFreqSpd
Update frequency LFO speed of all active voices
Signature
updateLFOFreqSpd(floatspd)
Arguments
floatspd

 
 top of page
Method updateLFOPanAmt
Update pan LFO => pan amount modifier
Signature
updateLFOPanAmt(floatamt)
Arguments
floatamt

 
 top of page
Method updateLFOPanLvl
Update pan LFO level of all active voices
Signature
updateLFOPanLvl(floatlvl)
Arguments
floatlvl

 
 top of page
Method updateLFOPanSpd
Update pan LFO speed of all active voices
Signature
updateLFOPanSpd(floatspd)
Arguments
floatspd

 
 top of page
Method updateLFOVolAmt
Update volume LFO => volume amount modifier
Signature
updateLFOVolAmt(floatamt)
Arguments
floatamt

 
 top of page
Method updateLFOVolLvl
Update volume LFO level of all active voices
Signature
updateLFOVolLvl(floatlvl)
Arguments
floatlvl

 
 top of page
Method updateLFOVolSpd
Update volume LFO speed of all active voices
Signature
updateLFOVolSpd(floatspd)
Arguments
floatspd

 
 top of page
Method updateMod
Update modulation of all active voices
Signature
updateMod(floatv)
Arguments
floatv

 
 top of page
Method updatePan
Update panning modulation of all active voices
Signature
updatePan(floatv)
Arguments
floatv

 
 top of page
Method updatePerfCtl
Update performance controller (original MIDI range, 0..127 or 0..16383)
Signature
updatePerfCtl(intidx,
  floatval 
  )  
Arguments
intidx
floatval

 
 top of page
Method updatePerfCtls
Update performance controllers. Skip when value is <0.
Signature
updatePerfCtls(FloatArrayinitialPerfCtl)
Arguments
FloatArrayinitialPerfCtl

 
 top of page
Method updateRAuxSpd
Update aux release speed of all active voices
Signature
updateRAuxSpd(floatint)
Arguments
floatint

 
 top of page
Method updateRetrigMask
Retrigger envelope/LFO of all active voices
Signature
updateRetrigMask(intv)
Arguments
intv
Description
0x01: reset freq envelope 0x02: reset volume envelope 0x04: reset pan envelope 0x08: reset aux envelope 0x10: reset freq LFO 0x20: reset volume LFO 0x40: reset pan LFO 0x80: reset aux LFO

 
 top of page
Method updateRFreqSpd
Update freq release speed of all active voices
Signature
updateRFreqSpd(floatint)
Arguments
floatint

 
 top of page
Method updateRPanSpd
Update pan release speed of all active voices
Signature
updateRPanSpd(floatint)
Arguments
floatint

 
 top of page
Method updateRVolSpd
Update volume release speed of all active voices
Signature
updateRVolSpd(floatint)
Arguments
floatint

 
 top of page
Method updateSampleOff
Update sample offset modulation of all active voices
Signature
updateSampleOff(floatv)
Arguments
floatv

 
 top of page
Method updateSampleShift
Update sample shift modulation of all active voices
Signature
updateSampleShift(floatv)
Arguments
floatv

 
 top of page
Method updateSampleShiftEndOfLoop
Update sample shift modulation of all active voices (queue until end of loop)
Signature
updateSampleShiftEndOfLoop(floatv)
Arguments
floatv

 
 top of page
Method updateSAuxSpd
Update aux sustain speed of all active voices
Signature
updateSAuxSpd(floatint)
Arguments
floatint

 
 top of page
Method updateSFreqSpd
Update freq sustain speed of all active voices
Signature
updateSFreqSpd(floatint)
Arguments
floatint

 
 top of page
Method updateSPanSpd
Update pan sustain speed of all active voices
Signature
updateSPanSpd(floatint)
Arguments
floatint

 
 top of page
Method updateSVolSpd
Update volume sustain speed of all active voices
Signature
updateSVolSpd(floatint)
Arguments
floatint

 
 top of page
Method updateTimestretch
Update timestretch modulation of all active voices
Signature
updateTimestretch(floatv)
Arguments
floatv

 
 top of page
Method updateTimestretchBend
Update timestretch phase bend modulation of all active voices
Signature
updateTimestretchBend(floatv)
Arguments
floatv

 
 top of page
Method updateVol
Update volume modulation of all active voices
Signature
updateVol(floatv)
Arguments
floatv

 
 top of page
Method updateWavepathIndex
Make all playing voices jump to the given cycle index (granular mode)
Signature
updateWavepathIndex(intidx)
Arguments
intidx

 
 top of page
Constant STSAMPLEPLAYER_MAXVOICES (int)
Constant STSAMPLEPLAYER_NUM_POLYMODES (int)
Constant STSAMPLEPLAYER_POLYMODE_HIGHEST (int)
Constant STSAMPLEPLAYER_POLYMODE_LOWEST (int)
Constant STSAMPLEPLAYER_POLYMODE_OLDEST (int)

 

Project Modules:tksampler 
Project Classes:StADSR , StEnvelope , StFFT , StLFO , StModSeq , StPluginInfo , StPluginLibrary , StPluginShared , StPluginSharedMissing , StPluginVoice , StRange , StSample , StSampleBank , StSampleMutexGroup , StSamplePlayer , StSampleVoice , StWaveform 
Project Functions:
All Namespaces:default , graph , ui 
All Projects:core , eqxmms , ShaderVG , ShaderVG_Text , tkanalogrytm , tkchipmunk , tkclap , tkfileutils , tkfreeglut , tkfreetype2 , tkfreeverb , tkmath , tkmidi , tkmidipipe , tkminnie , tkoldmath , tkopengl , tkportaudio , tkradiastools , tksamplechain , tksampleedit , tksampler , tksdl , tksdl_net , tksidplay2 , tkspeexdsp , tksqlite , tktriangulate , tkui , tkvst2 , tkzip , ui , yingtest 


auto-generated by "DOG", the TkScript document generator. Thu, 11/Dec/2025 13:42:00