diff --git a/server/constants/RemoteFaderPresets.ts b/server/constants/remoteProtocols/HuiRemoteFaderPresets.ts similarity index 92% rename from server/constants/RemoteFaderPresets.ts rename to server/constants/remoteProtocols/HuiRemoteFaderPresets.ts index 0ba2b59c..01c83e2e 100644 --- a/server/constants/RemoteFaderPresets.ts +++ b/server/constants/remoteProtocols/HuiRemoteFaderPresets.ts @@ -1,7 +1,3 @@ -//While developing mixer specific settings will be in one file. -//At first release these will be in seperate files -//So it´s easy to add new equipment. - export interface IMidiSendMessage { message: string value: any diff --git a/server/constants/remoteProtocols/SkaarhojProtocol.ts b/server/constants/remoteProtocols/SkaarhojProtocol.ts new file mode 100644 index 00000000..275c38db --- /dev/null +++ b/server/constants/remoteProtocols/SkaarhojProtocol.ts @@ -0,0 +1,164 @@ +export interface IRawSendMessage { + message: string + value: any + type: RawSendTypes +} + +export enum RawSendTypes { + disabled, + playNote, + stopNote, + sendControlChange, + sendPitchBend, +} + +export interface IRawReceiveMessage { + message: string + value: any + type: RawReceiveTypes +} +export enum RawReceiveTypes { + disabled, + noteon, + noteoff, + controlchange, + pitchbend, +} + +export interface IRemoteProtocol { + protocol: string + label: string + mode: string + leadingZeros: boolean + initializeCommands: [IRawSendMessage] + fromRemote: { + CHANNEL_PGM_ON_OFF: IRawReceiveMessage + CHANNEL_PST_ON_OFF: IRawReceiveMessage + CHANNEL_PFL_ON_OFF: IRawReceiveMessage + CHANNEL_FADER_LEVEL: IRawReceiveMessage + X_MIX: IRawReceiveMessage + FADE_TO_BLACK: IRawReceiveMessage + SNAP_RECALL: IRawReceiveMessage + } + toRemote: { + STATE_CHANNEL_PGM: IRawSendMessage + STATE_CHANNEL_PST: IRawSendMessage + STATE_CHANNEL_PFL: IRawSendMessage + STATE_CHANNEL_FADER_LEVEL: Array + } + fader: { + min: number + max: number + zero: number + step: number + } + meter: { + min: number + max: number + zero: number + test: number + } +} + +export const RemoteFaderPresets: { [key: string]: IRemoteProtocol } = { + rawPanel: { + protocol: 'RAW', + label: 'Generic Skaarhoj Protocol', + mode: 'client', + leadingZeros: false, + initializeCommands: [ + { + message: '', + value: '', + type: RawSendTypes.disabled, + }, + ], + fromRemote: { + CHANNEL_PGM_ON_OFF: { + message: '', + value: '', + type: RawReceiveTypes.disabled, + }, + CHANNEL_PST_ON_OFF: { + message: '', + value: '', + type: RawReceiveTypes.disabled, + }, + CHANNEL_PFL_ON_OFF: { + message: '', + value: '', + type: RawReceiveTypes.disabled, + }, + CHANNEL_FADER_LEVEL: { + message: '0', + value: '', + type: RawReceiveTypes.controlchange, + }, + X_MIX: { + message: '', + value: '', + type: RawReceiveTypes.disabled, + }, + FADE_TO_BLACK: { + message: '', + value: '', + type: RawReceiveTypes.disabled, + }, + SNAP_RECALL: { + message: '', + value: '', + type: RawReceiveTypes.disabled, + }, + }, + toRemote: { + STATE_CHANNEL_PGM: { + message: '', + value: '', + type: RawSendTypes.disabled, + }, + STATE_CHANNEL_PST: { + message: '', + value: '', + type: RawSendTypes.disabled, + }, + STATE_CHANNEL_PFL: { + message: '', + value: '', + type: RawSendTypes.disabled, + }, + STATE_CHANNEL_FADER_LEVEL: [ + { + message: '21', + value: '', + type: RawSendTypes.sendControlChange, + }, + { + message: '01', + value: '', + type: RawSendTypes.sendControlChange, + }, + ], + }, + fader: { + min: 0, + max: 127, + zero: 70, + step: 1, + }, + meter: { + min: 0, + max: 1, + zero: 0.75, + test: 0.6, + }, + }, +} + +export const RemoteFaderProtocolList = Object.getOwnPropertyNames( + RemoteFaderPresets +).map((preset) => { + return { + value: preset, + label: RemoteFaderPresets[preset].label, + } +}) diff --git a/server/utils/RemoteConnection.ts b/server/utils/RemoteConnection.ts index 2983cbec..60c14dd2 100644 --- a/server/utils/RemoteConnection.ts +++ b/server/utils/RemoteConnection.ts @@ -1,4 +1,4 @@ -// import { HuiMidiRemoteConnection } from './remoteConnections/HuiMidiRemoteConnection' +import { HuiMidiRemoteConnection } from './remoteConnections/HuiMidiRemoteConnection' import { SkaarhojRemoteConnection } from './remoteConnections/SkaarhojRemoteConnection' export class RemoteConnection { diff --git a/server/utils/remoteConnections/HuiMidiRemoteConnection.ts b/server/utils/remoteConnections/HuiMidiRemoteConnection.ts index 076d380a..23384e3c 100644 --- a/server/utils/remoteConnections/HuiMidiRemoteConnection.ts +++ b/server/utils/remoteConnections/HuiMidiRemoteConnection.ts @@ -14,7 +14,7 @@ import { IRemoteProtocol, RemoteFaderPresets, MidiReceiveTypes, -} from '../../constants/RemoteFaderPresets' +} from '../../constants/remoteProtocols/HuiRemoteFaderPresets' import { MixerProtocolPresets } from '../../constants/MixerProtocolPresets' export class HuiMidiRemoteConnection { diff --git a/server/utils/remoteConnections/SkaarhojRemoteConnection.ts b/server/utils/remoteConnections/SkaarhojRemoteConnection.ts index 3c314224..9033631f 100644 --- a/server/utils/remoteConnections/SkaarhojRemoteConnection.ts +++ b/server/utils/remoteConnections/SkaarhojRemoteConnection.ts @@ -1,5 +1,5 @@ //Node Modules: -const net = require('net') +const Net = require('net') import { store, state } from '../../reducers/store' import { mixerGenericConnection } from '../../mainClasses' @@ -13,31 +13,31 @@ import { import { IRemoteProtocol, RemoteFaderPresets, - MidiReceiveTypes, -} from '../../constants/RemoteFaderPresets' + RawReceiveTypes, +} from '../../constants/remoteProtocols/SkaarhojProtocol' import { MixerProtocolPresets } from '../../constants/MixerProtocolPresets' import { logger } from '../logger' export class SkaarhojRemoteConnection { store: any remoteProtocol: IRemoteProtocol - midiReceiveTypes = MidiReceiveTypes + rawReceiveTypes = RawReceiveTypes mixerProtocol: any - midiInput: any - midiOutput: any - activeHuiChannel: number = 0 + rawInput: any + rawOutput: any + activeRawChannel: number = 0 constructor() { this.convertFromRemoteLevel = this.convertFromRemoteLevel.bind(this) this.convertToRemoteLevel = this.convertToRemoteLevel.bind(this) this.updateRemoteFaderState = this.updateRemoteFaderState.bind(this) - this.remoteProtocol = RemoteFaderPresets.hui + this.remoteProtocol = RemoteFaderPresets.rawPanel this.mixerProtocol = MixerProtocolPresets[state.settings[0].mixerProtocol] || MixerProtocolPresets.genericMidi - const server = net.createServer((socket: any) => { + const server = Net.createServer((socket: any) => { socket.write('Echo server\r\n') socket.pipe(socket) }) @@ -58,8 +58,8 @@ export class SkaarhojRemoteConnection { } setupRemoteFaderConnection() { - this.midiInput.addListener( - this.midiReceiveTypes[ + this.rawInput.addListener( + this.rawReceiveTypes[ this.remoteProtocol.fromRemote.CHANNEL_FADER_LEVEL.type ], undefined, @@ -83,33 +83,33 @@ export class SkaarhojRemoteConnection { console.log('Received message (' + message.data + ').') if (message.data[2] < 9) { //Set active channel for next midi message: - this.activeHuiChannel = message.data[2] + this.activeRawChannel = message.data[2] } else if (message.data[2] && message.data[2] === 65) { //SELECT button - toggle PGM ON/OFF store.dispatch({ type: TOGGLE_PGM, - channel: this.activeHuiChannel, + channel: this.activeRawChannel, }) mixerGenericConnection.updateOutLevel( - this.activeHuiChannel + this.activeRawChannel ) - this.updateRemotePgmPstPfl(this.activeHuiChannel) + this.updateRemotePgmPstPfl(this.activeRawChannel) } else if (message.data[2] && message.data[2] === 67) { //SOLO button - toggle PFL ON/OFF store.dispatch({ type: TOGGLE_PFL, - channel: this.activeHuiChannel, + channel: this.activeRawChannel, }) mixerGenericConnection.updateOutLevel( - this.activeHuiChannel + this.activeRawChannel ) - this.updateRemotePgmPstPfl(this.activeHuiChannel) + this.updateRemotePgmPstPfl(this.activeRawChannel) } } } ) //for testing: - this.midiInput.addListener('noteon', 'all', (error: any) => { + this.rawInput.addListener('noteon', 'all', (error: any) => { console.log( "Received 'noteon' message (" + error.note.name + @@ -143,7 +143,7 @@ export class SkaarhojRemoteConnection { } updateRemoteFaderState(channelIndex: number, outputLevel: number) { - if (!this.midiOutput) { + if (!this.rawOutput) { return } console.log( @@ -153,30 +153,30 @@ export class SkaarhojRemoteConnection { 'OutputLevel : ', this.convertToRemoteLevel(outputLevel) ) - this.midiOutput.sendControlChange( + this.rawOutput.sendControlChange( channelIndex, this.convertToRemoteLevel(outputLevel), 1 ) - this.midiOutput.sendControlChange(32 + channelIndex, 0, 1) + this.rawOutput.sendControlChange(32 + channelIndex, 0, 1) this.updateRemotePgmPstPfl(channelIndex) } updateRemotePgmPstPfl(channelIndex: number) { - if (!this.midiOutput) { + if (!this.rawOutput) { return } //Update SELECT button: - this.midiOutput.sendControlChange(12, channelIndex, 1) - this.midiOutput.sendControlChange( + this.rawOutput.sendControlChange(12, channelIndex, 1) + this.rawOutput.sendControlChange( 44, 1 + 64 * (state.faders[0].fader[channelIndex].pgmOn ? 1 : 0), 1 ) //Update SOLO button: - this.midiOutput.sendControlChange(12, channelIndex, 1) - this.midiOutput.sendControlChange( + this.rawOutput.sendControlChange(12, channelIndex, 1) + this.rawOutput.sendControlChange( 44, 3 + 64 * (state.faders[0].fader[channelIndex].pflOn ? 1 : 0), 1