Created
October 21, 2020 15:16
-
-
Save toszlanyi/97ff0dd1bb833f54a7980374f8ee1afd to your computer and use it in GitHub Desktop.
MC7000 mapping using Components JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// rewrite of te MC7000 mapping using Components JS | |
// WIP | |
var MC7000 = {}; | |
MC7000.init = function () { | |
// get current status of all knobs and faders | |
midi.sendSysexMsg([0xF0, 0x00, 0x20, 0x7F, 0x03, 0x01, 0xF7], 7); | |
MC7000.deck = []; | |
for (var i = 1; i <= 4; i++) { | |
MC7000.deck[i] = new MC7000.Deck([i], [i] - 1); | |
} | |
}; | |
MC7000.Deck = function (deckNumbers, offset) { | |
components.Deck.call(this, deckNumbers); | |
// Mixer elements | |
this.pregain = new components.Pot({ | |
midi: [0xB0 + offset, 0x16], | |
group: "[Channel" + deckNumbers + "]", | |
inKey: "pregain", | |
}); | |
this.eqKnob = []; | |
for (var eq = 1; eq <= 3; eq++) { | |
this.eqKnob[eq] = new components.Pot({ | |
midi: [0xB0 + offset, 0x20 - eq], | |
group: "[EqualizerRack1_" + this.currentDeck + "_Effect1]", | |
inKey: "parameter" + eq, | |
}); | |
} | |
this.filter = new components.Pot({ | |
midi: [0xB0 + offset, 0x1A], | |
group: "[QuickEffectRack1_" + this.currentDeck + "]", | |
inKey: "super1", | |
}); | |
this.pflButton = new components.Button({ | |
midi: [0x90 + offset, 0x1B], | |
key: "pfl", | |
type: components.Button.prototype.types.toggle, | |
on: 127, | |
off: 1, | |
}); | |
this.volume = new components.Pot({ | |
midi: [0xB0 + offset, 0x1C], | |
inKey: "volume", | |
}); | |
// Transport section | |
this.playButton = new components.PlayButton({ | |
midi: [0x90 + offset, 0x00], | |
on: 127, | |
off: 1, | |
}); | |
this.cueButton = new components.CueButton({ | |
midi: [0x90 + offset, 0x01], | |
on: 127, | |
off: 1, | |
}); | |
this.syncButton = new components.SyncButton({ | |
midi: [0x90 + offset, 0x02], | |
on: 127, | |
off: 1, | |
}); | |
// Jog Wheels | |
this.wheelTouch = function(channel, control, value, status, group) { | |
if (value === 0x7F) { | |
var alpha = 1.0/8; | |
var beta = alpha/32; | |
engine.scratchEnable(script.deckFromGroup(this.currentDeck), 894, 33.3, alpha, beta); | |
} else { // If not touched | |
engine.scratchDisable(script.deckFromGroup(this.currentDeck)); | |
} | |
}; | |
this.wheelTurn = function(channel, control, value, status, group) { | |
// For a control that centers on 0: | |
var jogValue = (value < 0x64) ? value : (value - 128); | |
var deck = script.deckFromGroup(this.currentDeck); | |
if (engine.isScratching(deck)) { | |
engine.scratchTick(deck, jogValue); // Scratch! | |
} else { | |
engine.setValue(this.currentDeck, "jog", jogValue / 10); // Pitch bend | |
} | |
}; | |
// Channel VU Meters | |
this.vuMeter = new components.Component({ | |
midi: [0xB0 + offset, 0x1F], | |
group: "[Channel" + deckNumbers + "]", | |
outKey: "VuMeter", | |
output: function(value, group, control) { | |
if (engine.getValue(group, "PeakIndicator") === 1) { | |
value = 0x76; | |
} else { | |
value = Math.pow(value, 4) * 0x75; | |
} | |
this.send(value); | |
}, | |
}); | |
this.reconnectComponents(function (c) { | |
if (c.group === undefined) { | |
c.group = this.currentDeck; | |
} | |
}); | |
}; | |
MC7000.Deck.prototype = new components.Deck(); | |
MC7000.crossfader = new components.Pot({ | |
midi: [0xBF, 0x08], | |
group: "[Master]", | |
inKey: "crossfader", | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 114-121: What is this good for?