Skip to content

Commit

Permalink
feat: Remote midicontroller - Recieve messages working
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon committed Jun 1, 2019
1 parent 41e71ca commit d60ad72
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/constants/RemoteFaderPresets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export enum MidiReceiveTypes {
noteon,
noteoff,
controlchange,
pichtbend
pitchbend
}

export interface IRemoteProtocol {
Expand Down Expand Up @@ -106,7 +106,7 @@ export const RemoteFaderPresets: { [key: string]: IRemoteProtocol } = {
CHANNEL_FADER_LEVEL: {
message: "",
value: "",
type: MidiReceiveTypes.pichtbend
type: MidiReceiveTypes.pitchbend
},
GRP_FADER_PGM_ON_OFF: {
message: "",
Expand Down
19 changes: 12 additions & 7 deletions src/utils/MidiRemoteConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import os from 'os'; // Used to display (log) network addresses on local machine
import WebMidi, { INoteParam, IMidiChannel } from 'webmidi';

//Utils:
import { IRemoteProtocol, RemoteFaderPresets, IMidiMessage, MidiTypes } from '../constants/RemoteFaderPresets';
import { IRemoteProtocol,
RemoteFaderPresets,
IMidiSendMessage,
MidiSendTypes,
IMidiReceiveMessage,
MidiReceiveTypes } from '../constants/RemoteFaderPresets';

export class MidiRemoteConnection {
store: any;
Expand Down Expand Up @@ -46,7 +51,7 @@ export class MidiRemoteConnection {
}

setupMixerConnection() {
this.midiInput.addListener(this.remoteProtocol.fromRemote.CHANNEL_FADER_LEVEL.type, this.remoteProtocol.fromRemote.CHANNEL_FADER_LEVEL.message,
this.midiInput.addListener(MidiReceiveTypes[this.remoteProtocol.fromRemote.CHANNEL_FADER_LEVEL.type], undefined,
(error: any) => {
console.log("Received 'controlchange' message (" + error.data + ").");
window.storeRedux.dispatch({
Expand Down Expand Up @@ -94,15 +99,15 @@ export class MidiRemoteConnection {
*/
}

sendOutMessage(CtrlMessage: IMidiMessage, channel: number, value: string) {
sendOutMessage(CtrlMessage: IMidiSendMessage, channel: number, value: string) {
let convertValue = this.convertToRemoteLevel(parseFloat(value));
if (CtrlMessage.type === MidiTypes.sendControlChange) {
if (CtrlMessage.type === MidiSendTypes.sendControlChange) {
this.midiOutput.sendControlChange(CtrlMessage.message, convertValue, channel);
} else if (CtrlMessage.type === MidiTypes.playNote) {
} else if (CtrlMessage.type === MidiSendTypes.playNote) {
this.midiOutput.playNote(CtrlMessage.message, convertValue, channel);
} else if (CtrlMessage.type === MidiTypes.stopNote) {
} else if (CtrlMessage.type === MidiSendTypes.stopNote) {
this.midiOutput.stopNote(CtrlMessage.message, convertValue, channel);
} else if (CtrlMessage.type === MidiTypes.sendPitchBend) {
} else if (CtrlMessage.type === MidiSendTypes.sendPitchBend) {
this.midiOutput.sendPitchBend(convertValue, channel);
}
}
Expand Down

0 comments on commit d60ad72

Please sign in to comment.