Skip to content

Commit

Permalink
fix: OSC buffer added to avoid overloading of Midas mixers
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon committed Jul 26, 2021
1 parent 283cad0 commit 0e4607b
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions server/utils/mixerConnections/OscMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ import { storeSetMixerOnline } from '../../reducers/settingsActions'
import { logger } from '../logger'
import { sendVuLevel, VuType } from '../vuServer'

interface IOscCommand {
address: string
args?: any[]
}

export class OscMixerConnection {
mixerProtocol: IMixerProtocol
mixerIndex: number
cmdChannelIndex: number
oscConnection: any
mixerOnlineTimer: any
commandBuffer: IOscCommand[] = []

constructor(mixerProtocol: IMixerProtocol, mixerIndex: number) {
this.sendOutMessage = this.sendOutMessage.bind(this)
Expand Down Expand Up @@ -340,8 +346,16 @@ export class OscMixerConnection {
if (this.mixerProtocol.pingTime > 0) {
let oscTimer = setInterval(() => {
this.pingMixerCommand()
logger.debug(`Send buffer Size : ${this.commandBuffer.length}`)
}, this.mixerProtocol.pingTime)
}

//Setup Buffer Timer:
setInterval(() => {
if (this.commandBuffer.length > 0) {
this.oscConnection.send(this.commandBuffer.shift())
}
}, 2)
}

initialCommands() {
Expand Down Expand Up @@ -481,7 +495,7 @@ export class OscMixerConnection {
let message = oscMessage.replace('{channel}', channelString)
if (message != 'none') {
logger.verbose('Sending OSC command :' + message, {})
this.oscConnection.send({
this.sendBuffered({
address: message,
args: [
{
Expand All @@ -499,7 +513,7 @@ export class OscMixerConnection {
: channel.toString()
let message = oscMessage.replace('{channel}', channelString)
if (message != 'none') {
this.oscConnection.send({
this.sendBuffered({
address: message,
})
}
Expand All @@ -516,7 +530,7 @@ export class OscMixerConnection {
message = message.replace('{argument}', auxSendNumber)
logger.verbose('Initial Aux Message : ' + message)
if (message != 'none') {
this.oscConnection.send({
this.sendBuffered({
address: message,
})
}
Expand Down Expand Up @@ -700,7 +714,7 @@ export class OscMixerConnection {
fs.readFileSync(path.resolve('storage', presetName))
)

this.oscConnection.send({
this.sendBuffered({
address: this.mixerProtocol.loadPresetCommand[0].mixerMessage,
args: [
{
Expand All @@ -716,6 +730,10 @@ export class OscMixerConnection {
}
}

sendBuffered(command: IOscCommand) {
this.commandBuffer.push(JSON.parse(JSON.stringify(command)))
}

injectCommand(command: string[]) {
return true
}
Expand Down

0 comments on commit 0e4607b

Please sign in to comment.