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

Commit 9202f65

Browse files
committed
Ability to have MIDI Controller Buttons Flashing between noteon and noteoff state.
This adds a third signification between being off and on for example for states like `FadeToBlack` and in the future `AudioFollowVideo` states.
1 parent 2af2da9 commit 9202f65

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

ControllerMidi.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,12 @@ export class ControllerMidi extends EventEmitter {
223223

224224
updateButtonsViaStateInstant(buttonStates) {
225225
buttonStates.forEach((btn) => {
226-
this.send(btn.state || 'noteoff', {
226+
let state = (btn.state || 'noteoff').toLowerCase()
227+
if (['flashingon', 'flashingoff'].includes(state)) {
228+
btn.state = (state === 'flashingon') ? 'flashingoff' : 'flashingon'
229+
state = (state === 'flashingon') ? 'noteoff' : 'noteon'
230+
}
231+
this.send(state, {
227232
note: btn.note,
228233
velocity: btn.value || btn.defaultValue || 0,
229234
channel: btn.channel || this.config?.midi?.outputChannel || 10,

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ControllerKeyboard } from './ControllerKeyboard.js'
1313

1414
import { asArray, map, getEnumByValue } from './utils.js'
1515

16-
const MIDI_RESEND_INTERVAL = 1000 // ms
16+
const MIDI_RESEND_INTERVAL = 500 // ms
1717

1818
export class ControlThemAll {
1919
constructor() {
@@ -590,6 +590,13 @@ export class ControlThemAll {
590590
this.updateButtonState(btns, { state: 'noteon', value: 127 }, 'note')
591591
}
592592

593+
switchButtonLightFlashing(btns) {
594+
btns = asArray(btns)
595+
// console.log(`switchButtonLightFlashing:`, btns)
596+
btns = btns.map((btn) => { return { note: btn }})
597+
this.updateButtonState(btns, { state: 'flashingon', value: 127 }, 'note')
598+
}
599+
593600
switchButtonLightOff(btns) {
594601
btns = asArray(btns)
595602
// console.log(`switchButtonLightOff:`, btns)
@@ -730,7 +737,7 @@ export class ControlThemAll {
730737
this.updateDveButtons()
731738

732739
if (state.video.mixEffects[me].fadeToBlack.isFullyBlack) {
733-
this.switchButtonLightOn(this.getButtonsByAction('FadeToBlack'))
740+
this.switchButtonLightFlashing(this.getButtonsByAction('FadeToBlack'))
734741
} else {
735742
this.switchButtonLightOff(this.getButtonsByAction('FadeToBlack'))
736743
}

0 commit comments

Comments
 (0)