Skip to content

Commit

Permalink
feat: yamaha qlcl - inital req of fader levels. - split buffers - 2 b…
Browse files Browse the repository at this point in the history
…yte channel message
  • Loading branch information
olzzon committed Jan 30, 2020
1 parent d434dd3 commit f462841
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
19 changes: 14 additions & 5 deletions server/constants/mixerProtocols/yamahaQLCL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ export const YamahaQLCL: IMixerProtocol = {
pingCommand: [emptyMixerMessage()],
pingResponseCommand: [emptyMixerMessage()],
pingTime: 10000,
initializeCommands: [emptyMixerMessage()],
initializeCommands: [
{
mixerMessage: 'f0 43 30 3e 19 01 00 37 00 00 {channel} f7',
value: 0,
type: '',
min: 0,
max: 1,
zero: 0.75
}
],
channelTypes: [{
channelTypeName: 'CH',
channelTypeColor: '#2f2f2f',
fromMixer: {
CHANNEL_FADER_LEVEL: [emptyMixerMessage()], //PgmChange 0 - ignores this command
CHANNEL_OUT_GAIN: [{ mixerMessage: 'f0 43 10 3e 19 01 00 37 00 00 00 {channel} 00 00 00 {level} f7', value: 0, type: '', min: 0, max: 1, zero: 0.75}], //PgmChange 0 - ignores this command
CHANNEL_OUT_GAIN: [{ mixerMessage: 'f0 43 10 3e 19 01 00 37 00 00 {channel} 00 00 00 {level} f7', value: 0, type: '', min: 0, max: 1, zero: 0.75}], //PgmChange 0 - ignores this command
CHANNEL_VU: [{ mixerMessage: "0", value: 0, type: 'f', min: 0, max: 1, zero: 0.75}], //PgmChange 0 - ignores this command
CHANNEL_NAME: [emptyMixerMessage()],
PFL: [emptyMixerMessage()],
Expand All @@ -32,7 +41,7 @@ export const YamahaQLCL: IMixerProtocol = {
},
toMixer: {
CHANNEL_FADER_LEVEL: [emptyMixerMessage()],
CHANNEL_OUT_GAIN: [{ mixerMessage: 'f0 43 10 3e 19 01 00 37 00 00 00 {channel} 00 00 00 {level} f7', value: 0, type: '', min: 0, max: 1, zero: 0.75}],
CHANNEL_OUT_GAIN: [{ mixerMessage: 'f0 43 10 3e 19 01 00 37 00 00 {channel} 00 00 00 {level} f7', value: 0, type: '', min: 0, max: 1, zero: 0.75}],
CHANNEL_NAME: [emptyMixerMessage()],
PFL_ON: [emptyMixerMessage()],
PFL_OFF: [emptyMixerMessage()],
Expand All @@ -44,8 +53,8 @@ export const YamahaQLCL: IMixerProtocol = {
MID: [emptyMixerMessage()],
HIGH: [emptyMixerMessage()],
AUX_LEVEL: [emptyMixerMessage()],
CHANNEL_MUTE_ON: [{ mixerMessage: 'f0 43 10 3e 19 01 00 35 00 00 00 {channel} 00 00 00 00 00 f7', value: 0, type: '', min: 0, max: 1, zero: 0.75}],
CHANNEL_MUTE_OFF: [{ mixerMessage: 'f0 43 10 3e 19 01 00 35 00 00 00 {channel} 00 00 00 00 01 f7', value: 0, type: '', min: 0, max: 1, zero: 0.75}]
CHANNEL_MUTE_ON: [{ mixerMessage: 'f0 43 10 3e 19 01 00 35 00 00 {channel} 00 00 00 00 00 f7', value: 0, type: '', min: 0, max: 1, zero: 0.75}],
CHANNEL_MUTE_OFF: [{ mixerMessage: 'f0 43 10 3e 19 01 00 35 00 00 {channel} 00 00 00 00 01 f7', value: 0, type: '', min: 0, max: 1, zero: 0.75}]
},
}],
fader: {
Expand Down
37 changes: 15 additions & 22 deletions server/utils/mixerConnections/YamahaQlClConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ export class QlClMixerConnection {
this.mixerProtocol.initializeCommands.map((item) => {
if (item.mixerMessage.includes("{channel}")) {
state.channels[0].channel.map((channel: any, index: any) => {
this.sendOutRequest(item.mixerMessage, (index + 1));
});
this.sendOutMessage(item.mixerMessage, (index + 1), 0, '')
})
} else {
this.sendOutMessage(item.mixerMessage, 0, item.value, item.type);
this.sendOutMessage(item.mixerMessage, 0, item.value, item.type)
}
});
})
global.mainThreadHandler.updateFullClientStore()
})
.on('data', (data: any) => {
clearTimeout(this.mixerOnlineTimer)
Expand All @@ -71,8 +72,8 @@ export class QlClMixerConnection {
let buffers = []
let lastIndex = 0
for (let index=1; index<data.length; index++) {
if (data[index] === 241) {
buffers.push(data.slice(lastIndex, index - 1))
if (data[index] === 240) {
buffers.push(data.slice(lastIndex, index))
lastIndex = index
}
}
Expand Down Expand Up @@ -181,7 +182,7 @@ export class QlClMixerConnection {
return valid
}

sendOutMessage(message: string, channelIndex: number, value: string | number, type: string) {
sendOutMessage(message: string, channel: number, value: string | number, type: string) {
let valueNumber: number
if (typeof value === 'string') {
value = parseFloat(value)
Expand All @@ -193,27 +194,19 @@ export class QlClMixerConnection {
(valueNumber & 0x00ff),
])

let command = message.replace('{channel}', channelIndex.toString(16))
let channelByte = new Uint8Array([
(channel & 0xff00) >> 8,
(channel & 0x00ff),
])

let command = message.replace('{channel}', channelByte[0].toString(16) + ' ' + channelByte[1].toString(16))
command = command.replace('{level}', valueByte[0].toString(16) + ' ' + valueByte[1].toString(16))
let a = command.split(' ')
let buf = new Buffer(a.map((val:string) => { return parseInt(val, 16) }))
console.log("Sending Command :", command)
this.midiConnection.write(buf)
}


sendOutRequest(oscMessage: string, channel: number) {
let channelString = channel.toString();
let message = oscMessage.replace(
"{channel}",
channelString
);
if (message != 'none') {
this.midiConnection.send({
address: message
});
}
}

updateOutLevel(channelIndex: number) {
let channelType = state.channels[0].channel[channelIndex].channelType;
let channelTypeIndex = state.channels[0].channel[channelIndex].channelTypeIndex;
Expand Down

0 comments on commit f462841

Please sign in to comment.