aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2018-10-17 11:27:33 +1200
committerDevine Lu Linvega <[email protected]>2018-10-17 11:27:33 +1200
commit00b141b03f6a6a6c7d97f86dbef77d51e314687d (patch)
tree2a64ddf3ba74268a358a6fafaa707ec953034420
parent5bab4a25f0986b845d8afc1df58b9c0a8786d91c (diff)
downloadOrca-00b141b03f6a6a6c7d97f86dbef77d51e314687d.tar.gz
Orca-00b141b03f6a6a6c7d97f86dbef77d51e314687d.zip
Progress on QQQ
-rw-r--r--desktop/core/lib/__qqq.js17
-rw-r--r--desktop/sources/scripts/qqq.js10
-rw-r--r--desktop/sources/scripts/terminal.js5
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