ToneBufferSource
class Source ↳ extends OneShotSource<ToneBufferSourceOptions>
Wrapper around the native BufferSourceNode.
Constructor
Section titled “Constructor”new ToneBufferSource(url?: string | ToneAudioBuffer | AudioBuffer, onload?: () => void)Parameters
-
url
string | ToneAudioBuffer | AudioBufferoptionalThe buffer to play or url to load
-
onload
() => voidoptionalThe callback to invoke when the buffer is done playing.
new ToneBufferSource(options?: Partial<ToneBufferSourceOptions>)Parameters
- options
Partial<ToneBufferSourceOptions>optional
Properties
Section titled “Properties”getStateAtTime
Section titled “getStateAtTime”↳ inherited from OneShotSource
getStateAtTime: (time: Time) => BasicPlaybackStateGet the playback state at the given time
onended
Section titled “onended”↳ inherited from OneShotSource
onended: onEndedCallbackThe callback to invoke after the source is done playing.
Default: noOp
playbackRate
Section titled “playbackRate”read-only
playbackRate: Param<"positive">The frequency of the oscillator
curve: OneShotSourceCurveThe curve applied to the fades, either “linear” or “exponential”
loopStart
Section titled “loopStart”loopStart: TimeIf loop is true, the loop will start at this position.
read-only ↳ inherited from OneShotSource
state: BasicPlaybackStateGet the playback state at the current time
Methods
Section titled “Methods”cancelStop()
Section titled “cancelStop()”↳ inherited from OneShotSource
cancelStop(): thisCancel a scheduled stop event
Returns this
start()
Section titled “start()”Start the buffer
Parameters
-
time
TimeoptionalWhen the player should start.
-
offset
TimeoptionalThe offset from the beginning of the sample to start at.
-
duration
TimeoptionalHow long the sample should play. If no duration is given, it will default to the full length of the sample (minus any offset)
-
gain
numberoptional default1The gain to play the buffer back at.
Returns this
stop()
Section titled “stop()”↳ inherited from OneShotSource
stop(time?: Time): thisStop the source node at the given time.
Parameters
-
time
TimeoptionalWhen to stop the source
Returns this
getDefaults()
Section titled “getDefaults()”static
getDefaults(): ToneBufferSourceOptionsReturns all of the default options belonging to the class.
Returns ToneBufferSourceOptions
Inherited members
Section titled “Inherited members”- From
ToneWithContext: context, blockTime, sampleTime, get(), immediate(), now(), set(), toFrequency(), toSeconds(), toTicks() - From
Tone: debug, version, disposed, toString() - From
ToneAudioNode: channelCount, channelCountMode, channelInterpretation, numberOfInputs, numberOfOutputs, chain(), connect(), disconnect(), fan(), toDestination(), toMaster()