mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
attach _last node
This commit is contained in:
parent
0252bd6439
commit
1206d1793a
@ -21,6 +21,10 @@ export default class ProcessorNode {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof this.processor._last === "undefined") {
|
||||||
|
this.processor._last = this.processor
|
||||||
|
}
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,13 +63,13 @@ export default class ProcessorNode {
|
|||||||
// first check if has prevNode and if is connected to something
|
// first check if has prevNode and if is connected to something
|
||||||
// if has, disconnect it
|
// if has, disconnect it
|
||||||
// if it not has, its means that is the first node, so connect to the media source
|
// if it not has, its means that is the first node, so connect to the media source
|
||||||
if (prevNode && prevNode.processor.numberOfOutputs > 0) {
|
if (prevNode && prevNode.processor._last.numberOfOutputs > 0) {
|
||||||
//console.log(`[${this.constructor.refName ?? this.constructor.name}] node is already attached to the previous node, disconnecting...`)
|
//console.log(`[${this.constructor.refName ?? this.constructor.name}] node is already attached to the previous node, disconnecting...`)
|
||||||
// if has outputs, disconnect from the next node
|
// if has outputs, disconnect from the next node
|
||||||
prevNode.processor.disconnect()
|
prevNode.processor._last.disconnect()
|
||||||
|
|
||||||
// now, connect to the processor
|
// now, connect to the processor
|
||||||
prevNode.processor.connect(this.processor)
|
prevNode.processor._last.connect(this.processor)
|
||||||
} else {
|
} else {
|
||||||
//console.log(`[${this.constructor.refName ?? this.constructor.name}] node is the first node, connecting to the media source...`)
|
//console.log(`[${this.constructor.refName ?? this.constructor.name}] node is the first node, connecting to the media source...`)
|
||||||
instance.media.connect(this.processor)
|
instance.media.connect(this.processor)
|
||||||
@ -106,9 +110,9 @@ export default class ProcessorNode {
|
|||||||
const nextNode = instance.attachedProcessors[index + 1]
|
const nextNode = instance.attachedProcessors[index + 1]
|
||||||
|
|
||||||
// check if has previous node and if has outputs
|
// check if has previous node and if has outputs
|
||||||
if (prevNode && prevNode.processor.numberOfOutputs > 0) {
|
if (prevNode && prevNode.processor._last.numberOfOutputs > 0) {
|
||||||
// if has outputs, disconnect from the previous node
|
// if has outputs, disconnect from the previous node
|
||||||
prevNode.processor.disconnect()
|
prevNode.processor._last.disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// disconnect
|
// disconnect
|
||||||
@ -116,10 +120,10 @@ export default class ProcessorNode {
|
|||||||
|
|
||||||
// now, connect the previous node to the next node
|
// now, connect the previous node to the next node
|
||||||
if (prevNode && nextNode) {
|
if (prevNode && nextNode) {
|
||||||
prevNode.processor.connect(nextNode.processor)
|
prevNode.processor._last.connect(nextNode.processor)
|
||||||
} else {
|
} else {
|
||||||
// it means that this is the last node, so connect to the destination
|
// it means that this is the last node, so connect to the destination
|
||||||
prevNode.processor.connect(this.audioContext.destination)
|
prevNode.processor._last.connect(this.audioContext.destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
Loading…
x
Reference in New Issue
Block a user