diff options
author | neauoire <[email protected]> | 2019-11-10 16:32:45 -0500 |
---|---|---|
committer | neauoire <[email protected]> | 2019-11-10 16:32:45 -0500 |
commit | f8d02fe8a4c5f8964cd098919037701e1f58930d (patch) | |
tree | 3d9230730831b153da902c7807104cca4b5f5eea | |
parent | c278419fc8034695666fdea1295576deec778d94 (diff) | |
download | Orca-f8d02fe8a4c5f8964cd098919037701e1f58930d.tar.gz Orca-f8d02fe8a4c5f8964cd098919037701e1f58930d.zip |
*
-rw-r--r-- | desktop/sources/scripts/client.js | 6 | ||||
-rw-r--r-- | desktop/sources/scripts/core/io/midi.js | 12 | ||||
-rw-r--r-- | desktop/sources/scripts/core/io/mono.js | 4 | ||||
-rw-r--r-- | desktop/sources/scripts/core/io/osc.js | 4 | ||||
-rw-r--r-- | desktop/sources/scripts/core/io/udp.js | 4 | ||||
-rw-r--r-- | desktop/sources/scripts/core/operator.js | 7 | ||||
-rw-r--r-- | desktop/sources/scripts/core/orca.js | 3 | ||||
-rw-r--r-- | desktop/sources/scripts/cursor.js | 12 |
8 files changed, 25 insertions, 27 deletions
diff --git a/desktop/sources/scripts/client.js b/desktop/sources/scripts/client.js index f6115c5..e3cfe9b 100644 --- a/desktop/sources/scripts/client.js +++ b/desktop/sources/scripts/client.js @@ -256,12 +256,10 @@ function Client () { this.findPorts = () => { const a = new Array((this.orca.w * this.orca.h) - 1) - for (const id in this.orca.runtime) { - const operator = this.orca.runtime[id] + for (const operator of this.orca.runtime) { if (this.orca.lockAt(operator.x, operator.y)) { continue } const ports = operator.getPorts() - for (const i in ports) { - const port = ports[i] + for (const port of ports) { const index = this.orca.indexAt(port[0], port[1]) a[index] = port } diff --git a/desktop/sources/scripts/core/io/midi.js b/desktop/sources/scripts/core/io/midi.js index a1a2c28..10e76aa 100644 --- a/desktop/sources/scripts/core/io/midi.js +++ b/desktop/sources/scripts/core/io/midi.js @@ -24,8 +24,9 @@ function Midi (client) { this.run = function () { for (const id in this.stack) { - if (this.stack[id].length < 1) { - this.release(this.stack[id], id) + const item = this.stack[id] + if (item.length < 1) { + this.release(item, id) } if (!this.stack[id]) { continue } if (this.stack[id].isPlayed === false) { @@ -65,8 +66,8 @@ function Midi (client) { } this.silence = function () { - for (const id in this.stack) { - this.release(this.stack[id]) + for (const item of this.stack) { + this.release(item) } } @@ -74,7 +75,8 @@ function Midi (client) { const item = { channel, octave, note, velocity, length, isPlayed } // Retrigger duplicates for (const id in this.stack) { - if (this.stack[id].channel === channel && this.stack[id].octave === octave && this.stack[id].note === note) { this.release(item, id) } + const dup = this.stack[id] + if (dup.channel === channel && dup.octave === octave && dup.note === note) { this.release(item, id) } } this.stack.push(item) } diff --git a/desktop/sources/scripts/core/io/mono.js b/desktop/sources/scripts/core/io/mono.js index b9cd5bc..5837eb8 100644 --- a/desktop/sources/scripts/core/io/mono.js +++ b/desktop/sources/scripts/core/io/mono.js @@ -37,8 +37,8 @@ function Mono (client) { } this.silence = function () { - for (const id in this.stack) { - this.release(this.stack[id]) + for (const item of this.stack) { + this.release(item) } } diff --git a/desktop/sources/scripts/core/io/osc.js b/desktop/sources/scripts/core/io/osc.js index e2d28e9..2a605e8 100644 --- a/desktop/sources/scripts/core/io/osc.js +++ b/desktop/sources/scripts/core/io/osc.js @@ -20,8 +20,8 @@ function Osc (client) { } this.run = function () { - for (const id in this.stack) { - this.play(this.stack[id]) + for (const item of this.stack) { + this.play(item) } } diff --git a/desktop/sources/scripts/core/io/udp.js b/desktop/sources/scripts/core/io/udp.js index 9a5afa6..e94ff64 100644 --- a/desktop/sources/scripts/core/io/udp.js +++ b/desktop/sources/scripts/core/io/udp.js @@ -37,8 +37,8 @@ function Udp (client) { } this.run = function () { - for (const id in this.stack) { - this.play(this.stack[id]) + for (const item of this.stack) { + this.play(item) } } diff --git a/desktop/sources/scripts/core/operator.js b/desktop/sources/scripts/core/operator.js index c643823..7292b2c 100644 --- a/desktop/sources/scripts/core/operator.js +++ b/desktop/sources/scripts/core/operator.js @@ -8,7 +8,7 @@ function Operator (orca, x, y, glyph = '.', passive = false) { this.draw = passive this.glyph = passive ? glyph.toUpperCase() : glyph this.info = '--' - this.ports = { bang: !passive } + this.ports = {} // Actions @@ -41,10 +41,9 @@ function Operator (orca, x, y, glyph = '.', passive = false) { // Operate const payload = this.operation(force) // Permissions - for (const id in this.ports) { - orca.lock(this.x + this.ports[id].x, this.y + this.ports[id].y) + for (const port of Object.values(this.ports)) { + orca.lock(this.x + port.x, this.y + port.y) } - this.draw = true if (this.ports.output) { if (this.ports.output.bang === true) { diff --git a/desktop/sources/scripts/core/orca.js b/desktop/sources/scripts/core/orca.js index 1d65cf7..e320cb4 100644 --- a/desktop/sources/scripts/core/orca.js +++ b/desktop/sources/scripts/core/orca.js @@ -80,8 +80,7 @@ function Orca (library) { this.operate = function (operators) { this.release() - for (const id in operators) { - const operator = operators[id] + for (const operator of operators) { if (this.lockAt(operator.x, operator.y)) { continue } if (operator.passive || operator.hasNeighbor('*')) { operator.run() diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js index 0ca04e4..74deea0 100644 --- a/desktop/sources/scripts/cursor.js +++ b/desktop/sources/scripts/cursor.js @@ -189,9 +189,9 @@ function Cursor (client) { this.comment = function () { const block = this.getBlock() - for (const id in block) { - block[id][0] = block[id][0] === '#' ? '.' : '#' - block[id][block[id].length - 1] = block[id][block[id].length - 1] === '#' ? '.' : '#' + for (const val of block) { + val[0] = val[0] === '#' ? '.' : '#' + val[val.length - 1] = val[val.length - 1] === '#' ? '.' : '#' } this.writeBlock(block) } @@ -215,10 +215,10 @@ function Cursor (client) { if (!block || block.length === 0) { return } const rect = this.toRect() let _y = rect.y - for (const x in block) { + for (const line of block) { let _x = rect.x - for (const y in block[x]) { - const glyph = block[x][y] + for (const y in line) { + const glyph = line[y] client.orca.write(_x, _y, overlap === true && glyph === '.' ? client.orca.glyphAt(_x, _y) : glyph) _x++ } |