WIP: beunsize map work
This commit is contained in:
parent
cad9433266
commit
4dd4db6f65
4 changed files with 153 additions and 8 deletions
|
|
@ -42,7 +42,7 @@ export class MidiControl<T extends MessageType> {
|
|||
|
||||
constructor(
|
||||
private device: MidiDevice,
|
||||
public type: MessageType,
|
||||
public type: T,
|
||||
private filter: Partial<DataLookup[T]>,
|
||||
private options: Partial<IMidiControlOptions> = {}
|
||||
|
||||
|
|
@ -101,8 +101,17 @@ export class MidiControl<T extends MessageType> {
|
|||
|
||||
private feedback(data: DataLookup[T]) {
|
||||
if (!this.device.output) console.log('midi device tried to send output without output device defined')
|
||||
|
||||
let type: MessageType = this.type;
|
||||
|
||||
if (this.type === MessageType.NoteOnOff) {
|
||||
const rawData = data as NoteOnOffValue;
|
||||
|
||||
type = rawData.value ? MessageType.NoteOn : MessageType.NoteOff;
|
||||
}
|
||||
|
||||
// ugly typing here, but library overloads are a little annoying to work around. worst case scenario nothing happens
|
||||
this.device.output?.send(this.type as any, { ...data, ...this.filter } as any);
|
||||
this.device.output?.send(type as any, { ...data, ...this.filter } as any);
|
||||
}
|
||||
|
||||
public getPage(): number { return this.page };
|
||||
|
|
@ -147,9 +156,19 @@ export class MidiDevice {
|
|||
|
||||
public controls: Array<MidiControl<MessageType>> = [];
|
||||
|
||||
constructor(inputDevice: string, outputDevice: string | boolean = false) {
|
||||
constructor(inputDevice: string, outputDevice: string | boolean = false, virtual: boolean = false) {
|
||||
if (outputDevice === true) outputDevice = inputDevice;
|
||||
|
||||
if (virtual) {
|
||||
this.input = new midi.Input(inputDevice, true)
|
||||
|
||||
if (outputDevice) {
|
||||
this.output = new midi.Output(outputDevice, true);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
const inputDeviceFull = midi.getInputs().find(i => i.includes(inputDevice));
|
||||
|
||||
if (!inputDeviceFull) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import osc from "osc";
|
|||
|
||||
interface IOSCEvent {
|
||||
address: string;
|
||||
handler: (message: osc.ResponseMessage<osc.MessageArg>) => void;
|
||||
handler: (message: osc.ResponseMessage<osc.MessageArg[]>) => void;
|
||||
}
|
||||
|
||||
export class OSCDevice {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue