aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2018-10-17 07:56:52 +1200
committerDevine Lu Linvega <[email protected]>2018-10-17 07:56:52 +1200
commit8f60f2dbb8c512ba283eff1bc12a2cb4c048fbfe (patch)
treee2fec2f9905e357261fb764d4ba59064f22da212
parent7b7dad37349dcea19cd009cc57697c90b0846f5e (diff)
downloadOrca-8f60f2dbb8c512ba283eff1bc12a2cb4c048fbfe.tar.gz
Orca-8f60f2dbb8c512ba283eff1bc12a2cb4c048fbfe.zip
Started QQQ node
-rw-r--r--desktop/core/lib.js3
-rw-r--r--desktop/core/lib/__qqq.js26
-rw-r--r--desktop/sources/scripts/qqq.js48
3 files changed, 46 insertions, 31 deletions
diff --git a/desktop/core/lib.js b/desktop/core/lib.js
index 883cb58..47ded70 100644
--- a/desktop/core/lib.js
+++ b/desktop/core/lib.js
@@ -51,6 +51,7 @@ module.exports = {
},
queries: {
'bpm': require('./lib/__bpm'),
- 'vol': require('./lib/__vol')
+ 'vol': require('./lib/__vol'),
+ 'qqq': require('./lib/__qqq'),
}
}
diff --git a/desktop/core/lib/__qqq.js b/desktop/core/lib/__qqq.js
new file mode 100644
index 0000000..199d778
--- /dev/null
+++ b/desktop/core/lib/__qqq.js
@@ -0,0 +1,26 @@
+'use strict'
+
+const FnBase = require('./_base')
+
+function FnQqq (pico, x, y) {
+ FnBase.call(this, pico, x, y)
+
+ this.name = 'qqq'
+ this.glyph = '?'
+ this.info = 'Play note.'
+
+ this.ports = [{ x: 0, y: -1, input: true }]
+
+ this.haste = function () {
+ pico.lock(this.x, this.y - 1)
+ }
+
+ this.run = function () {
+ const n = this.north()
+ if(n){
+ terminal.qqq.play()
+ }
+ }
+}
+
+module.exports = FnQqq
diff --git a/desktop/sources/scripts/qqq.js b/desktop/sources/scripts/qqq.js
index a5642d2..5710ab5 100644
--- a/desktop/sources/scripts/qqq.js
+++ b/desktop/sources/scripts/qqq.js
@@ -4,6 +4,7 @@ function QQQ (terminal) {
this.terminal = terminal
this.volume = 1
this.midi = false
+ this.outputs = []
this.start = function () {
this.midiSetup()
@@ -16,43 +17,30 @@ function QQQ (terminal) {
}
this.midiActive = function (midiAccess) {
- var outputs = midiAccess.outputs.values()
- // loop over all available inputs and listen for any MIDI input
- for (var output = outputs.next(); output && !output.done; output = outputs.next()) {
- console.log(output)
- // each time there is a midi message call the onMIDIMessage function
- // output.value.onmidimessage = onMIDIMessage;
+
+ 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);
}
}
this.midiInactive = function (err) {
-
+ console.warn("No Midi")
}
this.play = function () {
-
- // var noteon,
- // noteoff,
- // outputs = [];
-
- // // Grab an array of all available devices
- // var iter = interface.outputs.values();
- // for (var i = iter.next(); i && !i.done; i = iter.next()) {
- // outputs.push(i.value);
- // }
-
- // // Craft 'note on' and 'note off' messages (channel 3, note number 60 [C3], max velocity)
- // noteon = [0x92, 60, 127];
- // noteoff = [0x82, 60, 127];
-
- // // Send the 'note on' and schedule the 'note off' for 1 second later
- // outputs[0].send(noteon);
- // setTimeout(
- // function() {
- // outputs[0].send(noteoff);
- // },
- // 1000
- // );
+ let noteon, noteoff;
+ noteon = [0x92, 60, 127];
+ noteoff = [0x82, 60, 127];
+
+ terminal.qqq.outputs[0].send(noteon);
+ setTimeout(
+ function() {
+ // terminal.qqq.outputs[0].send(noteoff);
+ },
+ 500
+ );
}
this.setVolume = function (value) {