diff options
author | Devine Lu Linvega <[email protected]> | 2019-06-01 10:59:09 +0900 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2019-06-01 10:59:09 +0900 |
commit | 53a23870f1c021e56ecb3a1c4c6801384c1be6cc (patch) | |
tree | 57265b66cb51068c91c90314af450645b101b97e | |
parent | 935e47f3edd9aa87d6f0e7cf49a4e169385bffc8 (diff) | |
download | Orca-53a23870f1c021e56ecb3a1c4c6801384c1be6cc.tar.gz Orca-53a23870f1c021e56ecb3a1c4c6801384c1be6cc.zip |
Removed logic from Midi operator
-rw-r--r-- | desktop/core/io/mono.js | 16 | ||||
-rw-r--r-- | desktop/core/library/_midi.js | 30 |
2 files changed, 16 insertions, 30 deletions
diff --git a/desktop/core/io/mono.js b/desktop/core/io/mono.js index 5f51927..95ae59a 100644 --- a/desktop/core/io/mono.js +++ b/desktop/core/io/mono.js @@ -37,20 +37,16 @@ export default function Mono (terminal) { delete this.stack[item.channel] } - this.send = function (channel, octave, note, velocity, length, isPlayed = false) { - if (this.stack[channel]) { - this.release(this.stack[channel]) - } - this.stack[channel] = { channel, octave, note, velocity, length, isPlayed } - } - this.silence = function () { for (const id in this.stack) { this.release(this.stack[id]) } } - // UI - - function clamp (v, min, max) { return v < min ? min : v > max ? max : v } + this.send = function (channel, octave, note, velocity, length, isPlayed = false) { + if (this.stack[channel]) { + this.release(this.stack[channel]) + } + this.stack[channel] = { channel, octave, note, velocity, length, isPlayed } + } } diff --git a/desktop/core/library/_midi.js b/desktop/core/library/_midi.js index 2f8ccc1..e4b1bfc 100644 --- a/desktop/core/library/_midi.js +++ b/desktop/core/library/_midi.js @@ -17,32 +17,22 @@ export default function OperatorMidi (orca, x, y, passive) { this.operation = function (force = false) { if (!this.hasNeighbor('*') && force === false) { return } - if (this.listen(this.ports.channel) === '.') { return } - if (this.listen(this.ports.octave) === '.') { return } - if (this.listen(this.ports.note) === '.') { return } - - const channel = this.listen(this.ports.channel, true) - const rawOctave = this.listen(this.ports.octave, true) - const rawNote = this.listen(this.ports.note) - const rawVelocity = this.listen(this.ports.velocity, true) - const length = this.listen(this.ports.length, true) - - if (!isNaN(rawNote)) { return } - - const transposed = this.transpose(rawNote, rawOctave) - // 1 - 8 - const octave = transposed.octave - // 0 - 11 - const note = transposed.value - // 0 - G(127) - const velocity = parseInt((rawVelocity / 16) * 127) + const channel = this.listen(this.ports.channel) + if (channel === '.') { return } + const octave = this.listen(this.ports.octave) + if (octave === '.') { return } + const note = this.listen(this.ports.note) + if (note === '.') { return } - this.draw = false + const velocity = this.listen(this.ports.velocity) + const length = this.listen(this.ports.length) terminal.io.midi.send(channel, octave, note, velocity, length) if (force === true) { terminal.io.midi.run() } + + this.draw = false } } |