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
/**
* 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 {
@ -129,7 +129,7 @@ export interface ISequence {
attachAudio(args: IAttachAudioArgs): Promise<{
decodedBuffer: AudioBuffer
audioContext: AudioContext
destinationNode: AudioDestinationNode
destinationNode: AudioNode
}>
}
@ -190,7 +190,7 @@ export default class TheatreSequence implements ISequence {
async attachAudio(args: IAttachAudioArgs): Promise<{
decodedBuffer: AudioBuffer
audioContext: AudioContext
destinationNode: AudioDestinationNode
destinationNode: AudioNode
}> {
const {audioContext, destinationNode, decodedBuffer} =
await resolveAudioBuffer(args)
@ -211,7 +211,7 @@ export default class TheatreSequence implements ISequence {
async function resolveAudioBuffer(args: IAttachAudioArgs): Promise<{
decodedBuffer: AudioBuffer
audioContext: AudioContext
destinationNode: AudioDestinationNode
destinationNode: AudioNode
}> {
function getAudioContext(): Promise<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 _decodedBuffer: AudioBuffer,
private readonly _audioContext: AudioContext,
private readonly _nodeDestination: AudioDestinationNode,
private readonly _nodeDestination: AudioNode,
) {
this.statePointer = this._state.pointer