sequence.attachAudio() now accepts any AudioNode as destination

This commit is contained in:
Aria Minaei 2021-09-27 16:36:06 +02:00
parent 91a65752a9
commit 3f0556b9eb
2 changed files with 6 additions and 6 deletions

View file

@ -16,9 +16,9 @@ interface IAttachAudioArgs {
*/ */
audioContext?: AudioContext audioContext?: AudioContext
/** /**
* An AudioDestinationNode to feed the audio into. One will be created if not provided. * An AudioNode to feed the audio into. Will use audioContext.destination if not provided.
*/ */
destinationNode?: AudioDestinationNode destinationNode?: AudioNode
} }
export interface ISequence { export interface ISequence {
@ -129,7 +129,7 @@ export interface ISequence {
attachAudio(args: IAttachAudioArgs): Promise<{ attachAudio(args: IAttachAudioArgs): Promise<{
decodedBuffer: AudioBuffer decodedBuffer: AudioBuffer
audioContext: AudioContext audioContext: AudioContext
destinationNode: AudioDestinationNode destinationNode: AudioNode
}> }>
} }
@ -190,7 +190,7 @@ export default class TheatreSequence implements ISequence {
async attachAudio(args: IAttachAudioArgs): Promise<{ async attachAudio(args: IAttachAudioArgs): Promise<{
decodedBuffer: AudioBuffer decodedBuffer: AudioBuffer
audioContext: AudioContext audioContext: AudioContext
destinationNode: AudioDestinationNode destinationNode: AudioNode
}> { }> {
const {audioContext, destinationNode, decodedBuffer} = const {audioContext, destinationNode, decodedBuffer} =
await resolveAudioBuffer(args) await resolveAudioBuffer(args)
@ -211,7 +211,7 @@ export default class TheatreSequence implements ISequence {
async function resolveAudioBuffer(args: IAttachAudioArgs): Promise<{ async function resolveAudioBuffer(args: IAttachAudioArgs): Promise<{
decodedBuffer: AudioBuffer decodedBuffer: AudioBuffer
audioContext: AudioContext audioContext: AudioContext
destinationNode: AudioDestinationNode destinationNode: AudioNode
}> { }> {
function getAudioContext(): Promise<AudioContext> { function getAudioContext(): Promise<AudioContext> {
if (args.audioContext) return Promise.resolve(args.audioContext) if (args.audioContext) return Promise.resolve(args.audioContext)

View file

@ -23,7 +23,7 @@ export default class AudioPlaybackController implements IPlaybackController {
private readonly _ticker: Ticker, private readonly _ticker: Ticker,
private readonly _decodedBuffer: AudioBuffer, private readonly _decodedBuffer: AudioBuffer,
private readonly _audioContext: AudioContext, private readonly _audioContext: AudioContext,
private readonly _nodeDestination: AudioDestinationNode, private readonly _nodeDestination: AudioNode,
) { ) {
this.statePointer = this._state.pointer this.statePointer = this._state.pointer