diff options
author | Devine Lu Linvega <[email protected]> | 2018-10-18 20:54:14 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-10-18 20:54:14 +1200 |
commit | 0c98174b007dd2131e20d309b0b521c8379e7f15 (patch) | |
tree | 9e0097bd2fe351cb8ebd6ba43ade34996bad2036 | |
parent | e612be470cc41bf2687b08b2c5a6ea4930b3899d (diff) | |
download | Orca-0c98174b007dd2131e20d309b0b521c8379e7f15.tar.gz Orca-0c98174b007dd2131e20d309b0b521c8379e7f15.zip |
Started to implement passive
41 files changed, 101 insertions, 88 deletions
@@ -88,6 +88,8 @@ The idea is to build a synth/mini sequencer, here's some tasks I need to tackle - [ ] Finish midi channel implementation - [ ] Convert notes to midi values - [ ] Implement a block comment syntax +- [ ] Maybe caps should all be passive? +- [ ] Maybe lowercase trigger only on bang? ## Extras diff --git a/desktop/core/lib/__bpm.js b/desktop/core/lib/__bpm.js index a248406..9662882 100644 --- a/desktop/core/lib/__bpm.js +++ b/desktop/core/lib/__bpm.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnBpm (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnBpm (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'midi' this.name = 'bpm' diff --git a/desktop/core/lib/__qqq.js b/desktop/core/lib/__qqq.js index f322182..e88f5bd 100644 --- a/desktop/core/lib/__qqq.js +++ b/desktop/core/lib/__qqq.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnQqq (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnQqq (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'midi' this.name = 'qqq' diff --git a/desktop/core/lib/__vol.js b/desktop/core/lib/__vol.js index 02bda99..51c6273 100644 --- a/desktop/core/lib/__vol.js +++ b/desktop/core/lib/__vol.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnVol (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnVol (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'midi' this.name = 'volume' diff --git a/desktop/core/lib/_base.js b/desktop/core/lib/_base.js index 6fc687e..98efd7a 100644 --- a/desktop/core/lib/_base.js +++ b/desktop/core/lib/_base.js @@ -1,6 +1,6 @@ 'use strict' -function FnBase (pico, x, y) { +function FnBase (pico, x, y, passive) { this.x = x this.y = y this.name = '<missing name>' diff --git a/desktop/core/lib/_move.js b/desktop/core/lib/_move.js index 9219216..1c1e65c 100644 --- a/desktop/core/lib/_move.js +++ b/desktop/core/lib/_move.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnMove (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnMove (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.direction = true diff --git a/desktop/core/lib/_null.js b/desktop/core/lib/_null.js index d305a41..1474be7 100644 --- a/desktop/core/lib/_null.js +++ b/desktop/core/lib/_null.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnNull (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnNull (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'null' this.glyph = '.' diff --git a/desktop/core/lib/_query.js b/desktop/core/lib/_query.js index a95e212..473ac99 100644 --- a/desktop/core/lib/_query.js +++ b/desktop/core/lib/_query.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnQuery (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnQuery (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'query' this.glyph = ':' diff --git a/desktop/core/lib/_wiref.js b/desktop/core/lib/_wiref.js index 7b07585..73a32dd 100644 --- a/desktop/core/lib/_wiref.js +++ b/desktop/core/lib/_wiref.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnWireF (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnWireF (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'wire' this.name = 'wire-f' diff --git a/desktop/core/lib/_wireh.js b/desktop/core/lib/_wireh.js index fc55721..746def3 100644 --- a/desktop/core/lib/_wireh.js +++ b/desktop/core/lib/_wireh.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnWireH (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnWireH (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'wire' this.name = 'wire-h' diff --git a/desktop/core/lib/_wiren.js b/desktop/core/lib/_wiren.js index 5eb8d7c..fdd877c 100644 --- a/desktop/core/lib/_wiren.js +++ b/desktop/core/lib/_wiren.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnWireN (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnWireN (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'wire' this.name = 'wire-n' diff --git a/desktop/core/lib/_wirev.js b/desktop/core/lib/_wirev.js index b8369df..812a6ee 100644 --- a/desktop/core/lib/_wirev.js +++ b/desktop/core/lib/_wirev.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnWireH (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnWireH (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'wire' this.name = 'wire-v' diff --git a/desktop/core/lib/a.js b/desktop/core/lib/a.js index ff52ff4..f8981f8 100644 --- a/desktop/core/lib/a.js +++ b/desktop/core/lib/a.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnA (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnA (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'math' this.name = 'add' diff --git a/desktop/core/lib/b.js b/desktop/core/lib/b.js index c9cb8e8..4002463 100644 --- a/desktop/core/lib/b.js +++ b/desktop/core/lib/b.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnB (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnB (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'unique' this.name = 'bang' diff --git a/desktop/core/lib/c.js b/desktop/core/lib/c.js index 7ba709d..2669449 100644 --- a/desktop/core/lib/c.js +++ b/desktop/core/lib/c.js @@ -1,8 +1,8 @@ 'use strict' const FnBase = require('./_base') -function FnC (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnC (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'clamp' this.glyph = 'c' diff --git a/desktop/core/lib/d.js b/desktop/core/lib/d.js index f360ae1..85f70a6 100644 --- a/desktop/core/lib/d.js +++ b/desktop/core/lib/d.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnD (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnD (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'deflect' this.glyph = 'd' diff --git a/desktop/core/lib/e.js b/desktop/core/lib/e.js index 7d83af2..e00f8f4 100644 --- a/desktop/core/lib/e.js +++ b/desktop/core/lib/e.js @@ -2,8 +2,8 @@ const FnMove = require('./_move') -function FnE (pico, x, y) { - FnMove.call(this, pico, x, y) +function FnE (pico, x, y, passive) { + FnMove.call(this, pico, x, y, passive) this.type = 'direction' this.name = 'east' diff --git a/desktop/core/lib/f.js b/desktop/core/lib/f.js index 4328870..358f5e1 100644 --- a/desktop/core/lib/f.js +++ b/desktop/core/lib/f.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnF (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnF (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'math' this.name = 'if' diff --git a/desktop/core/lib/g.js b/desktop/core/lib/g.js index a31bf8b..487da00 100644 --- a/desktop/core/lib/g.js +++ b/desktop/core/lib/g.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnG (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnG (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'transport' this.name = 'generator' diff --git a/desktop/core/lib/h.js b/desktop/core/lib/h.js index 9f7f734..0001484 100644 --- a/desktop/core/lib/h.js +++ b/desktop/core/lib/h.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnH (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnH (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'stopper' this.name = 'halt' diff --git a/desktop/core/lib/i.js b/desktop/core/lib/i.js index b271190..5207fa4 100644 --- a/desktop/core/lib/i.js +++ b/desktop/core/lib/i.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnI (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnI (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'trigger' this.name = 'increment' diff --git a/desktop/core/lib/j.js b/desktop/core/lib/j.js index ea4e99c..09054e6 100644 --- a/desktop/core/lib/j.js +++ b/desktop/core/lib/j.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnJ (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnJ (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) // TODO this.name = 'jump' diff --git a/desktop/core/lib/k.js b/desktop/core/lib/k.js index e56be6d..644a8c1 100644 --- a/desktop/core/lib/k.js +++ b/desktop/core/lib/k.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnK (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnK (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'trigger' this.name = 'kill' diff --git a/desktop/core/lib/l.js b/desktop/core/lib/l.js index df8992a..e97ad94 100644 --- a/desktop/core/lib/l.js +++ b/desktop/core/lib/l.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnL (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnL (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'list' this.name = 'loop' diff --git a/desktop/core/lib/m.js b/desktop/core/lib/m.js index 17644fb..ed1461a 100644 --- a/desktop/core/lib/m.js +++ b/desktop/core/lib/m.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnM (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnM (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'math' this.name = 'modulo' diff --git a/desktop/core/lib/n.js b/desktop/core/lib/n.js index 02ce071..d982600 100644 --- a/desktop/core/lib/n.js +++ b/desktop/core/lib/n.js @@ -2,8 +2,8 @@ const FnMove = require('./_move') -function FnN (pico, x, y) { - FnMove.call(this, pico, x, y) +function FnN (pico, x, y, passive) { + FnMove.call(this, pico, x, y, passive) this.type = 'direction' this.name = 'north' diff --git a/desktop/core/lib/o.js b/desktop/core/lib/o.js index 6479aad..52a7e64 100644 --- a/desktop/core/lib/o.js +++ b/desktop/core/lib/o.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnO (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnO (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'odd' this.glyph = 'o' diff --git a/desktop/core/lib/p.js b/desktop/core/lib/p.js index 2f23f25..d3a67c7 100644 --- a/desktop/core/lib/p.js +++ b/desktop/core/lib/p.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnP (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnP (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'push' this.glyph = 'p' diff --git a/desktop/core/lib/q.js b/desktop/core/lib/q.js index 520f33a..4686440 100644 --- a/desktop/core/lib/q.js +++ b/desktop/core/lib/q.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnQ (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnQ (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'even' this.glyph = 'q' diff --git a/desktop/core/lib/r.js b/desktop/core/lib/r.js index 2ecb290..6c38daa 100644 --- a/desktop/core/lib/r.js +++ b/desktop/core/lib/r.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnR (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnR (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'transport' this.name = 'raycast' diff --git a/desktop/core/lib/s.js b/desktop/core/lib/s.js index 00a8133..7ece44d 100644 --- a/desktop/core/lib/s.js +++ b/desktop/core/lib/s.js @@ -2,8 +2,8 @@ const FnMove = require('./_move') -function FnS (pico, x, y) { - FnMove.call(this, pico, x, y) +function FnS (pico, x, y, passive) { + FnMove.call(this, pico, x, y, passive) this.type = 'direction' this.name = 'south' diff --git a/desktop/core/lib/t.js b/desktop/core/lib/t.js index b30a2da..716282f 100644 --- a/desktop/core/lib/t.js +++ b/desktop/core/lib/t.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnT (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnT (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'trigger' this.glyph = 't' diff --git a/desktop/core/lib/u.js b/desktop/core/lib/u.js index f5551b1..c36d198 100644 --- a/desktop/core/lib/u.js +++ b/desktop/core/lib/u.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnU (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnU (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'idle' this.glyph = 'u' diff --git a/desktop/core/lib/v.js b/desktop/core/lib/v.js index 4ce9c74..0c6ee91 100644 --- a/desktop/core/lib/v.js +++ b/desktop/core/lib/v.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnV (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnV (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'value' this.glyph = 'v' diff --git a/desktop/core/lib/w.js b/desktop/core/lib/w.js index 17f23bc..f3c2440 100644 --- a/desktop/core/lib/w.js +++ b/desktop/core/lib/w.js @@ -2,8 +2,8 @@ const FnMove = require('./_move') -function FnW (pico, x, y) { - FnMove.call(this, pico, x, y) +function FnW (pico, x, y, passive) { + FnMove.call(this, pico, x, y, passive) this.type = 'direction' this.name = 'west' diff --git a/desktop/core/lib/x.js b/desktop/core/lib/x.js index 7edb8eb..6407ca7 100644 --- a/desktop/core/lib/x.js +++ b/desktop/core/lib/x.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnX (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnX (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'split' this.glyph = 'x' diff --git a/desktop/core/lib/y.js b/desktop/core/lib/y.js index f93c727..9da635e 100644 --- a/desktop/core/lib/y.js +++ b/desktop/core/lib/y.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnY (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnY (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.type = 'math' this.name = 'type' diff --git a/desktop/core/lib/z.js b/desktop/core/lib/z.js index d5b6319..af8458e 100644 --- a/desktop/core/lib/z.js +++ b/desktop/core/lib/z.js @@ -2,8 +2,8 @@ const FnBase = require('./_base') -function FnZ (pico, x, y) { - FnBase.call(this, pico, x, y) +function FnZ (pico, x, y, passive) { + FnBase.call(this, pico, x, y, passive) this.name = 'creep' this.glyph = 'z' diff --git a/desktop/core/pico.js b/desktop/core/pico.js index a4717e5..dc2b7b4 100644 --- a/desktop/core/pico.js +++ b/desktop/core/pico.js @@ -44,6 +44,19 @@ function Pico (w, h) { } } + this.findFn = function (g, x, y) { + if (g === '.') { return } + + if (this.lib.special[g]) { + return new this.lib.special[g](this, x, y) + } + + if (this.lib.alpha[g.toLowerCase()]) { + const passive = g === g.toUpperCase() + return new this.lib.alpha[g.toLowerCase()](this, x, y, passive) + } + } + this.findFns = function () { const a = [] let y = 0 @@ -51,11 +64,9 @@ function Pico (w, h) { let x = 0 while (x < this.w) { const g = this.glyphAt(x, y) - if (this.lib.alpha[g]) { - a.push(new this.lib.alpha[g](this, x, y)) - } - if (this.lib.special[g]) { - a.push(new this.lib.special[g](this, x, y)) + const fn = this.findFn(g, x, y) + if (fn) { + a.push(fn) } x += 1 } @@ -68,15 +79,15 @@ function Pico (w, h) { this.unlock() // Move for (const id in fns) { - const p = fns[id] - if (this.isLocked(p.x, p.y)) { continue } - p.haste() + const fn = fns[id] + if (this.isLocked(fn.x, fn.y)) { continue } + fn.haste() } // Operate for (const id in fns) { - const p = fns[id] - if (this.isLocked(p.x, p.y)) { continue } - p.run() + const fn = fns[id] + if (this.isLocked(fn.x, fn.y)) { continue } + fn.run() } } @@ -85,7 +96,7 @@ function Pico (w, h) { } this.add = function (x, y, ch) { - const glyph = ch.substr(0, 1).toLowerCase() + const glyph = ch.substr(0, 1) if (!this.isAllowed(glyph)) { this.terminal.log(`[${glyph}] is not allowed`); return } if (!this.inBounds(x, y)) { this.terminal.log(`[${glyph}] is out of range`); return } const index = this.indexAt(x, y) @@ -112,7 +123,7 @@ function Pico (w, h) { } this.isAllowed = function (g) { - return this.lib.alpha[g] || this.lib.num[g] || this.lib.special[g] + return this.lib.alpha[g.toLowerCase()] || this.lib.num[g] || this.lib.special[g] } this.glyphAt = function (x, y, req = null) { diff --git a/desktop/sources/scripts/qqq.js b/desktop/sources/scripts/qqq.js index 9e0253a..e9bf05f 100644 --- a/desktop/sources/scripts/qqq.js +++ b/desktop/sources/scripts/qqq.js @@ -41,7 +41,7 @@ function QQQ (terminal) { } this.midiInactive = function (err) { - console.warn('No Midi',err) + console.warn('No Midi', err) } this.send = function (channel, octave, note, velocity) { diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index 461aa69..a7b1199 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -203,7 +203,7 @@ function Terminal (pico) { } else { ctx.fillStyle = 'white' } - ctx.fillText(styles.isCursor && g === '.' ? (!pico.isPaused ? '@' : '~') : g.toUpperCase(), (x + 0.5) * this.tile.w, (y + 1) * this.tile.h) + ctx.fillText(styles.isCursor && g === '.' ? (!pico.isPaused ? '@' : '~') : g, (x + 0.5) * this.tile.w, (y + 1) * this.tile.h) } this.reset = function () { |