WIP: reorganizing and beunsize mapping
This commit is contained in:
parent
569a03245c
commit
cad9433266
6 changed files with 502 additions and 401 deletions
43
src/mappings/beunsize-ma3.ts
Normal file
43
src/mappings/beunsize-ma3.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import * as midi from 'easymidi'
|
||||
import { MessageType, MidiControl, MidiDevice } from "../devices/Midi.js"
|
||||
import { OSCDevice } from "../devices/OSC.js"
|
||||
import { mapNumber } from '../utilityFunctions.js'
|
||||
|
||||
export default async function mapping() {
|
||||
|
||||
const xtouch = new MidiDevice('X Touch Compact')
|
||||
const keyboard = new MidiDevice('idobo')
|
||||
|
||||
const ma3 = new OSCDevice('0.0.0.0', '127.0.0.1', 3000, 3001)
|
||||
|
||||
// Executor Faders
|
||||
const faders = [0, 1, 2, 3, 4, 5, 6, 7, 8].map(f => xtouch.addControl(MessageType.CC, { controller: f }))
|
||||
|
||||
faders.forEach((fader, index) => {
|
||||
const firstExec = 201;
|
||||
const exec = firstExec - 1 + index;
|
||||
const address = `/Page/Fader${exec}`;
|
||||
|
||||
fader.addOutput(0, (message) => {
|
||||
ma3.sendFloat(address, mapNumber(message.value, 0, 127, 0, 1));
|
||||
})
|
||||
|
||||
ma3.addListener(address, d => {
|
||||
const value = (d.args as any)[0]?.value;
|
||||
if (value !== undefined) {
|
||||
const mappedValue = mapNumber(value, 0, 1, 0, 127);
|
||||
fader.handleFeedback(0, { value: mappedValue })
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const executorButtons: MidiControl<MessageType.NoteOnOff>[][] = [
|
||||
[16, 17, 18, 19, 20, 21, 22, 23],
|
||||
[24, 25, 26, 27, 28, 29, 30, 31],
|
||||
[32, 33, 34, 35, 36, 37, 38, 39],
|
||||
[40, 41, 42, 43, 44, 45, 46, 47, 48],
|
||||
].map(row => row.map(note => { xtouch.addControl(MessageType.NoteOnOff)))
|
||||
|
||||
|
||||
|
||||
}
|
||||
188
src/mappings/xr18-home.ts
Normal file
188
src/mappings/xr18-home.ts
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
|
||||
import * as midi from 'easymidi';
|
||||
import { MessageType, MidiControl, MidiDevice } from '../devices/Midi.js';
|
||||
import { OSCDevice } from '../devices/OSC.js';
|
||||
import { mapNumber } from '../utilityFunctions.js';
|
||||
|
||||
export default async function mapping() {
|
||||
const deviceName = midi.getInputs().find(i => i.includes('Platform X'));
|
||||
if (!deviceName) {
|
||||
console.log('midi device not found')
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const mdev = new MidiDevice('Platform X', true);
|
||||
|
||||
const odev = new OSCDevice('0.0.0.0', '192.168.0.47', 10024);
|
||||
|
||||
// Polling for XR18 feedback
|
||||
setInterval(() => {
|
||||
odev.sendInt('/xremote', 1)
|
||||
}, 5000)
|
||||
|
||||
// const client = new osc.OSCClient('192.168.0.26', 9889);
|
||||
|
||||
// DEBUG OUT
|
||||
//['noteon', 'pitch'].map((v) => mdev.input.addListener(v, (data) => { console.log('data', data) }))
|
||||
|
||||
|
||||
// MM MM MMMM MMMMMM MMMMMM MMMMMM MM MM MMMM MMMM
|
||||
// MMMM MMMM MM MM MM MM MM MM MM MMMM MM MM MM MM MM
|
||||
// MM MM MM MMMMMMMM MM MM MM MM MM MM MMMM MM MM
|
||||
// MM MM MM MM MMMMMM MMMMMM MM MM MM MM MMMM MM
|
||||
// MM MM MM MM MM MM MM MM MM MM MM MM MM
|
||||
// MM MM MM MM MM MM MMMMMM MM MM MMMM MMMM
|
||||
|
||||
const PAGE_MAIN = 0;
|
||||
const PAGE_HP = 1;
|
||||
const PAGE_PC = 2;
|
||||
|
||||
const ALL_PAGES = [PAGE_MAIN, PAGE_HP, PAGE_PC];
|
||||
|
||||
const OSC_LEVEL_0 = 0.75;
|
||||
|
||||
|
||||
// TURN OFF ALL LEDS
|
||||
const feedbackOff = () => {
|
||||
for (const control of mdev.controls) {
|
||||
if (control.type === MessageType.NoteOn) {
|
||||
control.handleFeedback(ALL_PAGES, { velocity: 0 }, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
const offButton = mdev.addControl(MessageType.NoteOn, { channel: 0, note: 39 }, { noPageFeedback: true })
|
||||
offButton.addOutput(ALL_PAGES, (d) => feedbackOff());
|
||||
odev.addListener('/offleds', () => feedbackOff());
|
||||
|
||||
// PAGE SWITCHING
|
||||
const pageFeedback = () => {
|
||||
const page = mdev.page;
|
||||
buttonSel1.handleFeedback(ALL_PAGES, { velocity: page === PAGE_MAIN ? 127 : 0 })
|
||||
buttonSel2.handleFeedback(ALL_PAGES, { velocity: page === PAGE_HP ? 127 : 0 })
|
||||
buttonSel3.handleFeedback(ALL_PAGES, { velocity: page === PAGE_PC ? 127 : 0 })
|
||||
}
|
||||
|
||||
const buttonSel1 = mdev.addControl(MessageType.NoteOn, { channel: 0, note: 8 }, { noPageFeedback: true })
|
||||
buttonSel1.addOutput(ALL_PAGES, (d) => {
|
||||
if (d.velocity === 127) mdev.setPage(PAGE_MAIN)
|
||||
pageFeedback();
|
||||
});
|
||||
|
||||
const buttonSel2 = mdev.addControl(MessageType.NoteOn, { channel: 0, note: 9 }, { noPageFeedback: true })
|
||||
buttonSel2.addOutput(ALL_PAGES, (d) => {
|
||||
if (d.velocity === 127) mdev.setPage(PAGE_HP)
|
||||
pageFeedback();
|
||||
});
|
||||
|
||||
const buttonSel3 = mdev.addControl(MessageType.NoteOn, { channel: 0, note: 10 }, { noPageFeedback: true })
|
||||
buttonSel3.addOutput(ALL_PAGES, (d) => {
|
||||
if (d.velocity === 127) mdev.setPage(PAGE_PC)
|
||||
pageFeedback();
|
||||
});
|
||||
|
||||
|
||||
// FADERS
|
||||
const faders = [0, 1, 2, 3, 4, 5, 6, 7].map((f) => mdev.addControl(MessageType.Pitch, { channel: f as midi.Channel }, { feedbackInput: true }));
|
||||
|
||||
const setLevel = (addr: string, value: number, max: number = 1) => odev.sendFloat(addr, mapNumber(value, 0, 16383, 0, max));
|
||||
const levelFeedback = (fader: number, page: number, value: number, max: number = 1) => {
|
||||
faders[fader]?.handleFeedback(page, { value: mapNumber(value, 0, max, 0, 16383) });
|
||||
}
|
||||
|
||||
const fader2way = (fader: number, page: number, addr: string, max: number = 1) => {
|
||||
faders[fader]?.addOutput(page, d => setLevel(addr, d.value, max));
|
||||
odev.addListener(addr, d => { levelFeedback(fader, page, (d.args as any)[0], max) });
|
||||
|
||||
odev.sendNull(addr);
|
||||
}
|
||||
|
||||
|
||||
// PAGE 1: Main
|
||||
fader2way(0, PAGE_MAIN, '/dca/1/fader', OSC_LEVEL_0)
|
||||
fader2way(1, PAGE_MAIN, '/rtn/1/mix/fader', OSC_LEVEL_0)
|
||||
fader2way(2, PAGE_MAIN, '/bus/1/mix/fader', OSC_LEVEL_0)
|
||||
fader2way(3, PAGE_MAIN, '/ch/01/mix/fader')
|
||||
fader2way(4, PAGE_MAIN, '/ch/03/mix/fader')
|
||||
fader2way(5, PAGE_MAIN, '/ch/05/mix/fader')
|
||||
fader2way(6, PAGE_MAIN, '/ch/07/mix/fader')
|
||||
fader2way(7, PAGE_MAIN, '/ch/09/mix/fader')
|
||||
|
||||
|
||||
// PAGE 2: Headphones
|
||||
fader2way(0, PAGE_HP, '/bus/1/mix/fader', OSC_LEVEL_0)
|
||||
fader2way(1, PAGE_HP, '/ch/15/mix/01/level')
|
||||
fader2way(2, PAGE_HP, '/ch/16/mix/01/level')
|
||||
fader2way(3, PAGE_HP, '/ch/01/mix/01/level')
|
||||
fader2way(4, PAGE_HP, '/ch/03/mix/01/level')
|
||||
fader2way(5, PAGE_HP, '/ch/05/mix/01/level')
|
||||
fader2way(6, PAGE_HP, '/ch/07/mix/01/level')
|
||||
fader2way(7, PAGE_HP, '/ch/09/mix/01/level')
|
||||
|
||||
|
||||
// PAGE 3: PC
|
||||
fader2way(0, PAGE_PC, '/bus/1/mix/fader', OSC_LEVEL_0)
|
||||
fader2way(1, PAGE_PC, '/ch/15/mix/03/level')
|
||||
fader2way(2, PAGE_PC, '/ch/16/mix/03/level')
|
||||
fader2way(3, PAGE_PC, '/ch/01/mix/03/level')
|
||||
fader2way(4, PAGE_PC, '/ch/03/mix/03/level')
|
||||
fader2way(5, PAGE_PC, '/ch/05/mix/03/level')
|
||||
fader2way(6, PAGE_PC, '/ch/07/mix/03/level')
|
||||
fader2way(7, PAGE_PC, '/ch/09/mix/03/level')
|
||||
|
||||
|
||||
const button = (note: number) => mdev.addControl(MessageType.NoteOn, { channel: 0, note }, { feedbackInput: false, noStoreInput: true });
|
||||
const mutes = [16, 17, 18, 19, 20, 21, 22, 23].map(n => button(n));
|
||||
|
||||
// MUTE BUTTONS
|
||||
const buttonToggle = (control: MidiControl<MessageType.NoteOn> | undefined, page: number, addr: string) => {
|
||||
if (!control) return;
|
||||
|
||||
control.addOutput(page, (d) => {
|
||||
if (d.velocity !== 127) return;
|
||||
const value = control.getValue(page);
|
||||
if (!value || value.velocity > 1) {
|
||||
control.handleFeedback(page, { velocity: 0 });
|
||||
odev.sendInt(addr, 1);
|
||||
} else {
|
||||
control.handleFeedback(page, { velocity: 127 });
|
||||
odev.sendInt(addr, 0);
|
||||
}
|
||||
})
|
||||
|
||||
odev.addListener(addr, d => {
|
||||
control.handleFeedback(page, { velocity: (d.args as any)[0] === 0 ? 127 : 0 });
|
||||
})
|
||||
|
||||
odev.sendNull(addr);
|
||||
}
|
||||
|
||||
// PAGE 1: Main
|
||||
buttonToggle(mutes[0], PAGE_MAIN, '/dca/1/on')
|
||||
buttonToggle(mutes[1], PAGE_MAIN, '/rtn/1/mix/on')
|
||||
buttonToggle(mutes[2], PAGE_MAIN, '/bus/1/mix/on')
|
||||
buttonToggle(mutes[3], PAGE_MAIN, '/ch/01/mix/on')
|
||||
buttonToggle(mutes[4], PAGE_MAIN, '/ch/03/mix/on')
|
||||
buttonToggle(mutes[5], PAGE_MAIN, '/ch/05/mix/on')
|
||||
buttonToggle(mutes[6], PAGE_MAIN, '/ch/07/mix/on')
|
||||
buttonToggle(mutes[7], PAGE_MAIN, '/ch/09/mix/on')
|
||||
|
||||
// PAGE 2: Headphones
|
||||
buttonToggle(mutes[0], PAGE_HP, '/bus/1/mix/on')
|
||||
buttonToggle(mutes[1], PAGE_HP, '/ch/15/mix/on')
|
||||
buttonToggle(mutes[2], PAGE_HP, '/ch/16/mix/on')
|
||||
buttonToggle(mutes[3], PAGE_HP, '/ch/01/mix/on')
|
||||
buttonToggle(mutes[4], PAGE_HP, '/ch/03/mix/on')
|
||||
buttonToggle(mutes[5], PAGE_HP, '/ch/05/mix/on')
|
||||
buttonToggle(mutes[6], PAGE_HP, '/ch/07/mix/on')
|
||||
buttonToggle(mutes[7], PAGE_HP, '/ch/09/mix/on')
|
||||
|
||||
// PAGE 3: PC
|
||||
buttonToggle(mutes[0], PAGE_PC, '/bus/1/mix/on')
|
||||
buttonToggle(mutes[1], PAGE_PC, '/ch/15/mix/on')
|
||||
buttonToggle(mutes[2], PAGE_PC, '/ch/16/mix/on')
|
||||
buttonToggle(mutes[3], PAGE_PC, '/ch/01/mix/on')
|
||||
buttonToggle(mutes[4], PAGE_PC, '/ch/03/mix/on')
|
||||
buttonToggle(mutes[5], PAGE_PC, '/ch/05/mix/on')
|
||||
buttonToggle(mutes[6], PAGE_PC, '/ch/07/mix/on')
|
||||
buttonToggle(mutes[7], PAGE_PC, '/ch/09/mix/on')
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue