Skip to content

Commit

Permalink
feat(ember): load mixer snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-dewit committed Nov 25, 2020
1 parent 80bc452 commit 14c4d71
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
8 changes: 6 additions & 2 deletions server/constants/mixerProtocols/LawoMC2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import { IMixerProtocol, emptyMixerMessage } from '../MixerProtocolInterface'
export const LawoMC2: IMixerProtocol = {
protocol: 'EMBER',
label: 'Lawo MC2',
presetFileExtension: '',
loadPresetCommand: [emptyMixerMessage()],
presetFileExtension: 'MC2',
loadPresetCommand: [
{
mixerMessage: 'Production.Load Snapshot',
},
],
FADE_DISPATCH_RESOLUTION: 5,
leadingZeros: false, //some OSC protocols needs channels to be 01, 02 etc.
pingCommand: [emptyMixerMessage()],
Expand Down
22 changes: 21 additions & 1 deletion server/utils/mixerConnections/EmberMixerConnection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { EmberClient, Model, Types } from 'emberplus-connection'
import { store, state } from '../../reducers/store'
import { remoteConnections } from '../../mainClasses'
import path from 'path'
import fs from 'fs'

//Utils:
import {
Expand Down Expand Up @@ -890,7 +892,25 @@ export class EmberMixerConnection {
)
}

loadMixerPreset(presetName: string) {}
async loadMixerPreset(presetName: string) {
logger.info('Loading preset : ' + presetName)
if (this.mixerProtocol.presetFileExtension === 'MC2') {
let data = JSON.parse(
fs.readFileSync(path.resolve('storage', presetName)).toString()
)

const loadFunction = await this.emberConnection.getElementByPath(
this.mixerProtocol.loadPresetCommand[0].mixerMessage
)

if (loadFunction.contents.type === Model.ElementType.Function) {
this.emberConnection.invoke(
loadFunction as any,
data.sceneAddress
)
}
}
}

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

0 comments on commit 14c4d71

Please sign in to comment.