diff options
author | Devine Lu Linvega <[email protected]> | 2018-12-10 10:15:19 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-12-10 10:15:19 +1200 |
commit | 01c133a8af0f7e8c2a629fa5209885e6e99efc36 (patch) | |
tree | 35a7984d633ecb20ea89cdfe59ca46e470c74c10 | |
parent | 785010ea5621efd0c888ba662cc3b426b0a52881 (diff) | |
download | Orca-01c133a8af0f7e8c2a629fa5209885e6e99efc36.tar.gz Orca-01c133a8af0f7e8c2a629fa5209885e6e99efc36.zip |
Optimized V
-rw-r--r-- | desktop/core/library/_midi.js | 6 | ||||
-rw-r--r-- | desktop/core/library/q.js | 4 | ||||
-rw-r--r-- | desktop/core/library/v.js | 19 |
3 files changed, 16 insertions, 13 deletions
diff --git a/desktop/core/library/_midi.js b/desktop/core/library/_midi.js index 74016ad..f1ef5c8 100644 --- a/desktop/core/library/_midi.js +++ b/desktop/core/library/_midi.js @@ -17,14 +17,14 @@ function OperatorMidi (orca, x, y, passive) { this.run = function () { if (!this.bang()) { return } - let rawChannel = this.listen(this.ports.input.channel, true) + 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) - if (rawOctave === 0 || rawOctave > 8 || rawNote === '.' || rawChannel > 15) { return } + if (rawChannel === '.' || orca.valueOf(rawChannel) > 15 || rawOctave === 0 || rawOctave > 8 || rawNote === '.') { return } // 0 - 16 - const channel = clamp(rawChannel, 0, 15) + const channel = clamp(orca.valueOf(rawChannel), 0, 15) // 1 - 9 const octave = clamp(rawNote === 'b' ? rawOctave + 1 : rawOctave, 1, 9) // 0 - 11 diff --git a/desktop/core/library/q.js b/desktop/core/library/q.js index f1d9ded..95265fd 100644 --- a/desktop/core/library/q.js +++ b/desktop/core/library/q.js @@ -29,9 +29,7 @@ function OperatorQ (orca, x, y, passive) { // Read let str = '' for (const id in this.ports.input) { - const port = this.ports.input[id] - const val = this.listen(port) - str += val + str += this.listen(this.ports.input[id]) } // Write for (let i = 0; i < str.length; i++) { diff --git a/desktop/core/library/v.js b/desktop/core/library/v.js index 29b85e5..01167fd 100644 --- a/desktop/core/library/v.js +++ b/desktop/core/library/v.js @@ -12,7 +12,12 @@ function OperatorV (orca, x, y, passive) { this.ports.input.read = { x: 1, y: 0 } this.ports.output = { x: 0, y: 1 } + this.storage = { write: null, read: null } + this.haste = function () { + 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 @@ -21,22 +26,22 @@ function OperatorV (orca, x, y, passive) { this.run = function () { if (!this.isReading()) { return } - const key = this.listen(this.ports.input.read) + const key = this.storage.read const res = this.read(key) this.output(`${res}`) } this.isWritting = function () { - const key = this.listen(this.ports.haste.write) - const val = this.listen(this.ports.input.read) + const key = this.storage.write + const val = this.storage.read return key !== '.' && val !== '.' } this.isReading = function () { - const key = this.listen(this.ports.haste.write) - const val = this.listen(this.ports.input.read) + const key = this.storage.write + const val = this.storage.read return key === '.' && val !== '.' } @@ -47,9 +52,9 @@ function OperatorV (orca, x, y, passive) { if (orca.lockAt(operator.x, operator.y)) { continue } const glyph = operator.glyph.toLowerCase() if (glyph !== 'v') { continue } - const write = operator.listen(operator.ports.haste.write) + const write = operator.storage.write if (write !== key) { continue } - return operator.listen(operator.ports.input.read) + return operator.storage.read } return '.' } |