Skip to content
This repository was archived by the owner on Dec 17, 2022. It is now read-only.

Commit 511bb3f

Browse files
committed
Update to fix #1 so the project can be run on M1 Apple Silicone.
1 parent d76c4df commit 511bb3f

File tree

5 files changed

+2092
-1430
lines changed

5 files changed

+2092
-1430
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ npm install -g pnpm
2020

2121
### Installation
2222

23-
1. Download thie Repository ([ZIP](https://github.com/chrisspiegl/midi2atem/archive/refs/heads/main.zip))
23+
1. Download this Repository ([ZIP](https://github.com/chrisspiegl/midi2atem/archive/refs/heads/main.zip))
2424
2. Unzip and open Terminal into that folder
2525
3. run `pnpm install`
2626
4. start the app with `pnpm start`

config.default.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ atem:
1313
enabled: false
1414
address: 192.168.10.240
1515

16+
hotkeys:
17+
enabled: false
18+
1619
msPerFrame: 33.33333333 # 30fps = 33.33333333 | 24fps = 41.66666667
1720

1821
inputMapping:
@@ -67,7 +70,7 @@ dve:
6770
sizeY: 360
6871
positionX: 9700
6972
positionY: -5100
70-
maskEnabled: false
73+
maskEnabled: true
7174
maskTop: 0
7275
maskBottom: 0
7376
maskRight: 0
@@ -163,14 +166,30 @@ macros:
163166
actions:
164167
- action: KeyboardFire
165168
combination:
166-
- LeftSuper
169+
- LeftControl
170+
- LeftAlt
171+
- Left
172+
- action: Delay
173+
duration: 1000
174+
- action: KeyboardFire
175+
combination:
176+
- LeftControl
177+
- LeftAlt
167178
- Left
168179
- action: Delay
169180
duration: 1000
170181
- action: KeyboardFire
171182
combination:
172-
- LeftSuper
183+
- LeftControl
184+
- LeftAlt
173185
- Right
186+
- action: Delay
187+
duration: 1000
188+
- action: KeyboardFire
189+
combination:
190+
- LeftControl
191+
- LeftAlt
192+
- Num2
174193

175194
- name: TestMacro
176195
actions:

index.js

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import _ from 'lodash'
1+
import { find, isEmpty, difference, flatten } from 'lodash-es'
22
import got from 'got'
33
import merge from 'deepmerge'
44
import { Enums } from 'atem-connection'
5-
import { EventEmitter } from 'inf-ee'
5+
// import { EventEmitter } from 'inf-ee'
66

77
import { ControllerWebServer } from './ControllerWebServer.js'
88
import { ControllerAtem } from './ControllerAtem.js'
@@ -118,32 +118,32 @@ export class ControlThemAll {
118118
midiOnNoteOn(msg) {
119119
console.log(`NOTE ON:`, msg)
120120
const { note, velocity: value, channel } = msg
121-
const buttonConfig = _.find(this.config.buttons, { note })
121+
const buttonConfig = find(this.config.buttons, { note })
122122
console.log(`buttonConfig:`, buttonConfig)
123-
if (_.isEmpty(buttonConfig)) return
123+
if (isEmpty(buttonConfig)) return
124124
const actionConfig = buttonConfig.noteOn
125125
console.log(`buttonConfig:`, actionConfig)
126-
if (_.isEmpty(actionConfig)) return
126+
if (isEmpty(actionConfig)) return
127127
const buttonActionFunction = this.getButtonAction(actionConfig.action)
128128
if (buttonActionFunction) buttonActionFunction(actionConfig, value)
129129
}
130130

131131
midiOnNoteOff(msg) {
132132
console.log(`NOTE OFF:`, msg)
133133
const { note, velocity: value, channel } = msg
134-
const buttonConfig = _.find(this.config.buttons, { note })
134+
const buttonConfig = find(this.config.buttons, { note })
135135
console.log(`buttonConfig:`, buttonConfig)
136-
if (_.isEmpty(buttonConfig)) return
136+
if (isEmpty(buttonConfig)) return
137137
const actionConfig = buttonConfig.noteOff || buttonConfig
138-
if (_.isEmpty(actionConfig)) return
138+
if (isEmpty(actionConfig)) return
139139
const buttonActionFunction = this.getButtonAction(actionConfig.action)
140140
if (buttonActionFunction) buttonActionFunction(actionConfig, value)
141141
}
142142

143143
midiOnControllerChange(msg) {
144144
console.log(`CONTROLLER CHANGE:`, msg)
145145
const { controller: note, value, channel } = msg
146-
const controllerConfig = _.find(this.config.controllers, { note })
146+
const controllerConfig = find(this.config.controllers, { note })
147147
console.log(`controllerConfig:`, controllerConfig)
148148
const controlAction = this.getControllerAction(controllerConfig.action)
149149
if (controlAction) controlAction(controllerConfig, value)
@@ -315,10 +315,10 @@ export class ControlThemAll {
315315
RunMacro: async (options, value) => {
316316
// console.log(`options:`, options)
317317
const { name } = options
318-
const macroConfig = _.find(this.config.macros, { name })
318+
const macroConfig = find(this.config.macros, { name })
319319
const { actions } = macroConfig
320320
for (const actionConfig of actions) {
321-
if (_.isEmpty(actionConfig) || _.isEmpty(actionConfig.action)) return
321+
if (isEmpty(actionConfig) || isEmpty(actionConfig.action)) return
322322
const buttonActionFunction = this.getButtonAction(actionConfig.action)
323323
// console.log(`before ${actionConfig.action}`)
324324
if (buttonActionFunction) await buttonActionFunction(actionConfig, value)
@@ -361,10 +361,10 @@ export class ControlThemAll {
361361
console.log('url must be present')
362362
return
363363
}
364-
type = (!_.isEmpty(type)) ? type.toLowerCase() : 'get'
364+
type = (!isEmpty(type)) ? type.toLowerCase() : 'get'
365365
type = ['get', 'post', 'path', 'delete', 'put', 'head'].includes(type) ? type : 'get'
366-
body = (type !== 'get' && !_.isEmpty(body)) ? body : undefined
367-
headers = (!_.isEmpty(headers)) ? headers : { 'Content-Type': 'application/json' }
366+
body = (type !== 'get' && !isEmpty(body)) ? body : undefined
367+
headers = (!isEmpty(headers)) ? headers : { 'Content-Type': 'application/json' }
368368
try {
369369
const response = await got[type](options.url, { body, headers })
370370
console.log('HTTP Request Response: ', response.body)
@@ -607,23 +607,39 @@ export class ControlThemAll {
607607
}
608608

609609
getButtonsByAction(action) {
610-
return _.map(_.filter(this.config.buttons, (el) => el.action === action || el.noteOn?.action == action || el.noteOff?.action == action), (el) => el.note)
610+
return this.config.buttons
611+
.filter(
612+
(el) =>
613+
el.action === action ||
614+
el.noteOn?.action == action ||
615+
el.noteOff?.action == action
616+
)
617+
.map((el) => el.note);
618+
// return map(filter(this.config.buttons, (el) => el.action === action || el.noteOn?.action == action || el.noteOff?.action == action), (el) => el.note)
611619
}
612620

613621
getButtonsByNoteOffAction(action) {
614-
return _.map(_.filter(this.config.buttons, (el) => el.noteOff?.action == action), (el) => el.note)
622+
this.config.buttons
623+
.filter((el) => el.noteOff?.action == action)
624+
.map((el) => el.note);
625+
// return map(filter(this.config.buttons, (el) => el.noteOff?.action == action), (el) => el.note)
615626
}
616627

617628
getButtonsByNoteOnAction(action) {
618-
return _.map(_.filter(this.config.buttons, (el) => el.noteOn?.action == action), (el) => el.note)
629+
return this.config.buttons
630+
.filter((el) => el.noteOn?.action == action)
631+
.map((el) => el.note);
632+
// return map(filter(this.config.buttons, (el) => el.noteOn?.action == action), (el) => el.note)
619633
}
620634

621635
getControllersByAction(action) {
622-
return _.filter(this.config.controllers, (el) => el.action === action)
636+
return this.config.controllers.filter((el) => el.action === action);
637+
// return filter(this.config.controllers, (el) => el.action === action)
623638
}
624639

625640
getControllersByName(name) {
626-
return _.filter(this.config.controllers, (el) => el.name === name)
641+
return this.config.controllers.filter((el) => el.name === name);
642+
// return filter(this.config.controllers, (el) => el.name === name)
627643
}
628644

629645
updateButtonState(buttonStates, overwrite = {}, via = 'action') {
@@ -632,7 +648,7 @@ export class ControlThemAll {
632648
return { state: 'noteoff', value: buttonState.defaultValue || 0, ...buttonState, ...overwrite}
633649
})
634650
this.config.buttons = this.config.buttons.map((button) => {
635-
let updatedButtonState = _.find(buttonStates, (el) => el[via] === button[via])
651+
let updatedButtonState = find(buttonStates, (el) => el[via] === button[via])
636652
if (updatedButtonState) {
637653
button.value = updatedButtonState.value
638654
button.state = updatedButtonState.state
@@ -645,7 +661,7 @@ export class ControlThemAll {
645661
const buttonsForDveSelection = this.config.feedback.buttonsForActiveUpstreamKeyerFillSource
646662
const nameOfInput = Object.keys(this.config.inputMapping).find(key => this.config.inputMapping[key] === this.config.dve.fillSource)
647663
const buttonActiveDveFillSource = buttonsForDveSelection[nameOfInput]
648-
this.switchButtonLightOff(_.difference(_.flatten(Object.values(buttonsForDveSelection)), buttonActiveDveFillSource))
664+
this.switchButtonLightOff(difference(flatten(Object.values(buttonsForDveSelection)), buttonActiveDveFillSource))
649665
this.switchButtonLightOn(buttonActiveDveFillSource)
650666
}
651667

@@ -655,7 +671,7 @@ export class ControlThemAll {
655671
return { state: 'cc', value: controllerState.defaultValue || 0, ...controllerState, ...overwrite}
656672
})
657673
this.config.controllers = this.config.controllers.map((controller) => {
658-
let updatedControllerState = _.find(controllerStates, (el) => el[via] === controller[via])
674+
let updatedControllerState = find(controllerStates, (el) => el[via] === controller[via])
659675
if (updatedControllerState) {
660676
controller.value = updatedControllerState.value
661677
}
@@ -669,7 +685,7 @@ export class ControlThemAll {
669685
const { controllers } = this.config
670686
controllerStates = controllerStates.map((controllerState) => merge(controllerState, { state: 'cc', value: controllerState.defaultValue || 0 }))
671687
controllers.map((controller) => {
672-
let updatedControllerState = _.find(controllerStates, (el) => el.action === controller.action)
688+
let updatedControllerState = find(controllerStates, (el) => el.action === controller.action)
673689
if (updatedControllerState) controller.value = updatedControllerState.value
674690
return controller
675691
})
@@ -732,8 +748,8 @@ export class ControlThemAll {
732748
const buttonsForProgramInputWithDve = this.config.feedback.buttonsForProgramInputWithDve
733749
const nameOfInput = Object.keys(this.config.inputMapping).find(key => this.config.inputMapping[key] === programInput)
734750
const buttonsForProgramInput = (hasDve) ? buttonsForProgramInputWithDve[nameOfInput] : buttonsForProgramInputWithoutDve[nameOfInput]
735-
const buttonsForProgramInputAll = [..._.flatten(Object.values(buttonsForProgramInputWithoutDve)), ..._.flatten(Object.values(buttonsForProgramInputWithDve))]
736-
this.switchButtonLightOff(_.difference(buttonsForProgramInputAll, buttonsForProgramInput))
751+
const buttonsForProgramInputAll = [...flatten(Object.values(buttonsForProgramInputWithoutDve)), ...flatten(Object.values(buttonsForProgramInputWithDve))]
752+
this.switchButtonLightOff(difference(buttonsForProgramInputAll, buttonsForProgramInput))
737753
this.switchButtonLightOn(buttonsForProgramInput)
738754

739755
this.updateDveButtons()
@@ -763,7 +779,7 @@ export class ControlThemAll {
763779
console.log('Server closing: Doing the cleanup.')
764780

765781
if (this.controllerMidi.isConnected()) {
766-
this.switchButtonLightOff(_.flatten(this.config.buttons.map((el) => [el.note])))
782+
this.switchButtonLightOff(flatten(this.config.buttons.map((el) => [el.note])))
767783
this.controllerMidi.updateButtonsViaState(this.config.buttons)
768784
this.updatecontrollerState(this.config.controllers.map((el) => merge(el, { state: 'cc', value: 0 })))
769785
this.controllerMidi.updateControllersViaState(this.config.controllers)

package.json

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,41 @@
22
"type": "module",
33
"private": true,
44
"name": "controlthemall",
5-
"version": "0.0.1",
5+
"version": "0.0.2",
66
"scripts": {
7-
"preinstall": "npx only-allow pnpm",
8-
"dev": "pnpm run start:dev",
9-
"start": "node .",
10-
"start:dev": "nodemon ./index.js",
11-
"build": "pnpm run build:ncc && pnpm run build:caxa",
12-
"build:app": "pnpm run build:ncc && pnpm run build:caxa:app",
13-
"build:ncc": "ncc build index.js -o dist/ncc",
14-
"build:caxa": "caxa --input \"dist/ncc\" --output \"dist/bin/ControlThemAll\" -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/index.js\"",
15-
"build:caxa:app": "caxa --input \"dist/ncc\" --output \"dist/bin/ControlThemAll.app\" -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/index.js\""
7+
"dev": "run-s start:dev",
8+
"start": "run-s start:dev",
9+
"start:dev": "nodemon .",
10+
"cu": "ncu",
11+
"cu:fix": "ncu -u"
1612
},
1713
"main": "index.js",
1814
"bin": "index.js",
1915
"dependencies": {
20-
"@nut-tree/nut-js": "^1.6.1-next.20210603163242",
21-
"atem-connection": "3.0.0-nightly-latest-20210530-132658-16c3cdd.0",
22-
"atem-state": "^0.10.1",
23-
"debug": "^4.3.1",
24-
"deep-object-diff": "^1.1.0",
16+
"@nut-tree/nut-js": "^2.0.0-RC1",
17+
"atem-connection": "3.0.0-nightly-latest-20211125-222857-2b30eea.0",
18+
"atem-state": "^0.12.2",
19+
"debug": "^4.3.3",
2520
"deepmerge": "^4.2.2",
2621
"detect-port": "^1.3.0",
27-
"easymidi": "^2.0.5",
28-
"express": "^4.17.1",
29-
"got": "^11.8.2",
22+
"easymidi": "^2.1.0",
23+
"express": "^4.17.2",
24+
"got": "^12.0.0",
3025
"inf-ee": "^1.0.4",
31-
"lodash": "^4.17.21",
26+
"lodash-es": "^4.17.21",
3227
"throttle-debounce": "^3.0.1",
3328
"yaml": "^1.10.2"
3429
},
3530
"devDependencies": {
36-
"caxa": "^2.0.0",
37-
"nodemon": "^2.0.7"
31+
"nodemon": "^2.0.15",
32+
"npm-check-updates": "^12.0.5",
33+
"npm-run-all": "^4.1.5"
3834
},
3935
"author": {
4036
"name": "Chris Spiegl",
4137
"email": "chris@chrisspiegl.com",
4238
"url": "https://chrisspiegl.com/"
4339
},
44-
"homepage": "https://github.com/chrisspiegl/midi2atem",
40+
"homepage": "https://github.com/chrisspiegl/ControlThemAll",
4541
"license": "UNLICENSED"
4642
}

0 commit comments

Comments
 (0)