diff options
Diffstat (limited to 'desktop/core')
-rw-r--r-- | desktop/core/library/_midi.js | 16 | ||||
-rw-r--r-- | desktop/core/library/v.js | 37 |
2 files changed, 16 insertions, 37 deletions
diff --git a/desktop/core/library/_midi.js b/desktop/core/library/_midi.js index f1ef5c8..65f9012 100644 --- a/desktop/core/library/_midi.js +++ b/desktop/core/library/_midi.js @@ -20,8 +20,10 @@ function OperatorMidi (orca, x, y, passive) { let rawChannel = this.listen(this.ports.input.channel) let rawOctave = this.listen(this.ports.input.octave, true) let rawNote = this.listen(this.ports.input.note) + let rawVelocity = this.listen(this.ports.haste.velocity) + let rawLength = this.listen(this.ports.haste.length) - if (rawChannel === '.' || orca.valueOf(rawChannel) > 15 || rawOctave === 0 || rawOctave > 8 || rawNote === '.') { return } + if (rawChannel === '.' || orca.valueOf(rawChannel) > 15 || rawOctave === 0 || rawOctave > 8 || rawNote === '.' || rawVelocity === '0' || rawLength === '0') { return } // 0 - 16 const channel = clamp(orca.valueOf(rawChannel), 0, 15) @@ -29,10 +31,10 @@ function OperatorMidi (orca, x, y, passive) { const octave = clamp(rawNote === 'b' ? rawOctave + 1 : rawOctave, 1, 9) // 0 - 11 const note = ['C', 'c', 'D', 'd', 'E', 'F', 'f', 'G', 'g', 'A', 'a', 'B'].indexOf(rawNote === 'e' ? 'F' : rawNote === 'b' ? 'C' : rawNote) - // 0 - 127 - const velocity = convertVelocity(this.listen(this.ports.haste.velocity, true), 127) - // 0 - 16 - const length = clamp(this.listen(this.ports.haste.length, true), 1, 16) + // 0 - F(127) + const velocity = rawVelocity === '.' ? 127 : parseInt((clamp(orca.valueOf(rawVelocity), 1, 15) / 15) * 127) + // 0 - F(15) + const length = clamp(orca.valueOf(rawLength), 1, 15) if (note < 0) { console.warn(`Unknown note:${rawNote}`); return } @@ -41,10 +43,6 @@ function OperatorMidi (orca, x, y, passive) { terminal.io.sendMidi(channel, octave, note, velocity, length) } - function convertVelocity (val, max) { - return parseInt((!val ? 1 : val < 10 ? (val / 9) : (val - 10) / 25) * max) - } - function clamp (v, min, max) { return v < min ? min : v > max ? max : v } } diff --git a/desktop/core/library/v.js b/desktop/core/library/v.js index 01167fd..59b4fd1 100644 --- a/desktop/core/library/v.js +++ b/desktop/core/library/v.js @@ -18,45 +18,26 @@ function OperatorV (orca, x, y, passive) { this.storage.write = this.listen(this.ports.haste.write) this.storage.read = this.listen(this.ports.input.read) - if (!this.isWritting()) { return } - - this.ports.output = null + if (this.storage.write !== '.' && this.storage.read !== '.') { + this.ports.output = null + } } this.run = function () { - if (!this.isReading()) { return } - - const key = this.storage.read - const res = this.read(key) - - this.output(`${res}`) - } - - this.isWritting = function () { - const key = this.storage.write - const val = this.storage.read + if (this.storage.write !== '.' || this.storage.read === '.') { return } - return key !== '.' && val !== '.' - } - - this.isReading = function () { - const key = this.storage.write - const val = this.storage.read - - return key === '.' && val !== '.' - } - - this.read = function (key) { for (const id in orca.runtime) { const operator = orca.runtime[id] if (orca.lockAt(operator.x, operator.y)) { continue } const glyph = operator.glyph.toLowerCase() if (glyph !== 'v') { continue } const write = operator.storage.write - if (write !== key) { continue } - return operator.storage.read + if (write !== this.storage.read) { continue } + this.output(operator.storage.read) + return } - return '.' + + this.output('.') } } |