diff options
-rw-r--r-- | desktop/core/lib/__qqq.js | 17 | ||||
-rw-r--r-- | desktop/sources/scripts/qqq.js | 10 | ||||
-rw-r--r-- | desktop/sources/scripts/terminal.js | 5 |
3 files changed, 27 insertions, 5 deletions
diff --git a/desktop/core/lib/__qqq.js b/desktop/core/lib/__qqq.js index a91affb..b4f10c5 100644 --- a/desktop/core/lib/__qqq.js +++ b/desktop/core/lib/__qqq.js @@ -9,17 +9,26 @@ function FnQqq (pico, x, y) { this.glyph = '?' this.info = 'Play note.' - this.ports = [{ x: 0, y: -1, input: true }] + this.ports = [{ x: 0, y: -1, input: true }, { x: 1, y: 0, output: true }] this.haste = function () { pico.lock(this.x, this.y - 1) + pico.lock(this.x + 1, this.y) } this.run = function () { const n = this.north() - if (n) { - terminal.qqq.play() - } + if (!n) { return } + const e = this.east() + + const octave = !e ? 3 : this.convert(e.glyph) + const note = this.convert(n.glyph) + const velocity = 127 + terminal.qqq.send(octave, note, velocity) + } + + this.convert = function (glyph) { + return pico.allowed.indexOf(glyph) } } diff --git a/desktop/sources/scripts/qqq.js b/desktop/sources/scripts/qqq.js index 3eb2bc5..1797ef7 100644 --- a/desktop/sources/scripts/qqq.js +++ b/desktop/sources/scripts/qqq.js @@ -10,6 +10,10 @@ function QQQ (terminal) { this.midiSetup() } + this.run = function () { + + } + this.midiSetup = function () { if (!navigator.requestMIDIAccess) { return } @@ -19,15 +23,19 @@ function QQQ (terminal) { this.midiActive = function (midiAccess) { const iter = midiAccess.outputs.values() for (let i = iter.next(); i && !i.done; i = iter.next()) { - console.log(terminal.qqq) terminal.qqq.outputs.push(i.value) } + terminal.log(`Midi is active, devices: ${terminal.qqq.outputs.length}`) } this.midiInactive = function (err) { console.warn('No Midi') } + this.send = function (octave, note, velocity) { + console.log('Received ', octave, note, velocity) + } + this.play = function () { this.ch1() this.ch3() diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index f74c42f..9ad7d08 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -44,6 +44,7 @@ function Terminal (pico) { if (this.isPaused) { return } this.pico.run() + this.qqq.run() this.update() } @@ -80,6 +81,10 @@ function Terminal (pico) { this.draw_inspector(0) } + this.new = function () { + pico.clear() + } + this.draw_program = function () { const ports = this.find_ports() const terminal = this |