Skip to content

Commit

Permalink
wip: intermediate checkin (lawo ruby)
Browse files Browse the repository at this point in the history
  • Loading branch information
Balte de Wit committed Jun 12, 2020
1 parent d5b552c commit 6a39cdc
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"asn1": "github:evs-broadcast/node-asn1",
"casparcg-connection": "^4.9.0",
"classnames": "^2.2.6",
"emberplus-connection": "^0.0.2-nightly-next-20200604-105628-46d0ba3.0",
"emberplus-connection": "^0.0.3-nightly-20200611-095712-4e2267a.0",
"express": "^4.17.1",
"express-csp-header": "^3.0.0",
"http": "^0.0.0",
Expand Down
17 changes: 13 additions & 4 deletions server/constants/mixerProtocols/LawoRuby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,23 @@ export const LawoRuby: IMixerProtocol = {
},
],
CHANNEL_OUT_GAIN: [
// {
// mixerMessage:
// 'Ruby.Sources.{channel}.Fader.Motor Position',
// value: 0,
// type: 'int',
// min: 0,
// max: 255,
// zero: 204,
// },
{
mixerMessage:
'Ruby.Sources.{channel}.Fader.Motor Position',
'Ruby.Sources.{channel}.Fader.Motor dB Value',
value: 0,
type: 'int',
min: 0,
max: 255,
zero: 204,
min: -191,
max: 9,
zero: 0,
},
],
CHANNEL_NAME: [
Expand Down
57 changes: 52 additions & 5 deletions server/utils/mixerConnections/LawoRubyConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class LawoRubyMixerConnection {
emberConnection: EmberClient
deviceRoot: any
emberNodeObject: Array<any>
faders: { [index: number]: string } = {}

constructor(mixerProtocol: IMixerProtocol) {
this.sendOutMessage = this.sendOutMessage.bind(this)
Expand Down Expand Up @@ -63,13 +64,49 @@ export class LawoRubyMixerConnection {
})
}

setupMixerConnection() {
async setupMixerConnection() {
logger.info(
'Ember connection established - setting up subscription of channels'
)

// get the node that contains the sources
const sourceNode = await this.emberConnection.getElementByPath(
'Ruby.Sources'
)
// get the sources
const req = await this.emberConnection.getDirectory(sourceNode)
const sources = await req.response

// map sourceNames to their fader number
if ('children' in sources) {
for (const i of Object.keys(sources.children)) {
const child = sources.children[(i as unknown) as number]
if (
child.contents.type === Model.ElementType.Node &&
child.contents.identifier
) {
const name = child.contents.identifier
const fader = await this.emberConnection.getElementByPath(
`Ruby.Sources.${name}.Fader.Number`
)
this.faders[
(fader.contents as Model.Parameter).value as number
] = name
}
}
}

// Set channel labels
Object.entries(this.faders).forEach(([ch, name]) => {
store.dispatch({
type: SET_CHANNEL_LABEL,
channel: Number(ch) - 1, // - 1 ??
label: name,
})
})

let ch: number = 1
state.settings[0].numberOfChannelsInType.forEach(
state.settings[0].numberOfChannelsInchType.forEach(
async (numberOfChannels, typeIndex) => {
for (
let channelTypeIndex = 0;
Expand Down Expand Up @@ -257,10 +294,20 @@ export class LawoRubyMixerConnection {
state.channels[0].channel[channelIndex].channelTypeIndex
let protocol = this.mixerProtocol.channelTypes[channelType].toMixer
.CHANNEL_OUT_GAIN[0]
let level = outputLevel * (protocol.max - protocol.min) + protocol.min
// console.log(protocol, outputLevel, level)

this.sendOutLevelMessage(channelTypeIndex + 1, level)
// let level = outputLevel < 0.5 ?
// outputLevel * 2 * (-9 - protocol.min) + protocol.min :
// (outputLevel - .5) * 2 * (protocol.max - -9) + -9

let level =
170.67 * Math.pow(outputLevel, 4) +
-234.67 * Math.pow(outputLevel, 3) +
-202.67 * Math.pow(outputLevel, 2) +
466.67 * outputLevel +
-191
console.log(outputLevel, level)

// this.sendOutLevelMessage(channelTypeIndex + 1, level)
}

async updatePflState(channelIndex: number) {
Expand Down
9 changes: 4 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3732,18 +3732,17 @@ elliptic@^6.0.0:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.0"

emberplus-connection@^0.0.2-nightly-next-20200604-105628-46d0ba3.0:
version "0.0.2-nightly-next-20200604-105628-46d0ba3.0"
resolved "https://registry.yarnpkg.com/emberplus-connection/-/emberplus-connection-0.0.2-nightly-next-20200604-105628-46d0ba3.0.tgz#a2f6044a959283240972d76e22a9cc126b8fc9c4"
integrity sha512-NIB3w3F48i+st4LoBlXJh7b6OH8QwhL1GU3ECZfO+X8KgscOy6YcqLMqRt4KIfO/sXeMrX4fmaeTFus2T9TjgQ==
emberplus-connection@^0.0.3-nightly-20200611-095712-4e2267a.0:
version "0.0.3-nightly-20200611-095712-4e2267a.0"
resolved "https://registry.yarnpkg.com/emberplus-connection/-/emberplus-connection-0.0.3-nightly-20200611-095712-4e2267a.0.tgz#a3bc8e0dee846ef9ab5697aee29a0146f78c5198"
integrity sha512-2Jk/KwqfRm8UmtzUE+v2NAN3oL3ZoUvaUv3trER3XTGVxoexfEvGkfioKWCF49JyH2rue+AKh7523kaSethntg==
dependencies:
asn1 evs-broadcast/node-asn1
enum "^2.4.0"
long "^3.2.0"
smart-buffer "^3.0.3"
winston "^2.1.1"
winston-color "^1.0.0"
yargs "^15.1.0"

emoji-regex@^7.0.1:
version "7.0.3"
Expand Down

0 comments on commit 6a39cdc

Please sign in to comment.