diff options
author | Devine Lu Linvega <[email protected]> | 2018-10-16 20:35:56 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-10-16 20:35:56 +1200 |
commit | 7b7dad37349dcea19cd009cc57697c90b0846f5e (patch) | |
tree | 6ac6dda113e3f41f9d119a6259f52de8f92d3a23 | |
parent | ab309d2a008d4eda57ac7148b0853bdb8b5dd5f1 (diff) | |
download | Orca-7b7dad37349dcea19cd009cc57697c90b0846f5e.tar.gz Orca-7b7dad37349dcea19cd009cc57697c90b0846f5e.zip |
Started midi stuff
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | desktop/sources/scripts/cursor.js | 5 | ||||
-rw-r--r-- | desktop/sources/scripts/qqq.js | 55 | ||||
-rw-r--r-- | desktop/sources/scripts/terminal.js | 42 |
4 files changed, 80 insertions, 24 deletions
@@ -85,9 +85,11 @@ npm start The idea is to build a synth/mini sequencer, here's some tasks I need to tackle before then. +[ ] Add `:MID[CD]` [ ] custom synth functions, like `:SYN[ADSR](C)` [ ] "I wanna be able to 1000x fastforward my pico programs" [ ] sub programs scope +[ ] Implement midi ## Extras diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js index 26fcb44..e69a481 100644 --- a/desktop/sources/scripts/cursor.js +++ b/desktop/sources/scripts/cursor.js @@ -57,9 +57,8 @@ function Cursor (terminal) { return pico.docs[g] ? pico.docs[g] : this._position() } - this._position = function() - { - return `${this.x},${this.y}`+(this.w != 1 || this.h != 1 ? `[${this.w}x${this.h}]` : '') + this._position = function () { + return `${this.x},${this.y}` + (this.w != 1 || this.h != 1 ? `[${this.w}x${this.h}]` : '') } function clamp (v, min, max) { return v < min ? min : v > max ? max : v } diff --git a/desktop/sources/scripts/qqq.js b/desktop/sources/scripts/qqq.js index e9c8d0d..a5642d2 100644 --- a/desktop/sources/scripts/qqq.js +++ b/desktop/sources/scripts/qqq.js @@ -1,9 +1,62 @@ 'use strict' -function QQQ () { +function QQQ (terminal) { + this.terminal = terminal this.volume = 1 + this.midi = false + + this.start = function () { + this.midiSetup() + } + + this.midiSetup = function () { + if (!navigator.requestMIDIAccess) { return } + + navigator.requestMIDIAccess({ sysex: false }).then(this.midiActive, this.midiInactive) + } + + 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; + } + } + + this.midiInactive = function (err) { + + } + + 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 + // ); + } this.setVolume = function (value) { + this.terminal.log(`Changed volume to ${value}.`) this.volume = parseInt(value) / 100.0 } } diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index 6ba4e50..f74c42f 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -22,29 +22,11 @@ function Terminal (pico) { this.theme.install(host) } - this.resize = function () { - this.size = { width: this.tile.w * pico.w, height: this.tile.h * pico.h + (this.tile.h * 3), ratio: 0.75 } - this.el.width = this.size.width - this.el.height = this.size.height + this.tile.h - this.el.style.width = (this.size.width * this.size.ratio) + 'px' - this.el.style.height = (this.size.height * this.size.ratio) + 'px' - - let { remote } = require('electron') - let win = remote.getCurrentWindow() - - win.setSize((this.size.width * this.size.ratio) + 60, (this.size.height * this.size.ratio) + 30, true) - } - - window.onresize = (event) => { - const marginTop = (window.innerHeight - (this.size.height * this.size.ratio)) / 2 - this.el.style.marginTop = (marginTop - 20) + 'px' - } - this.start = function () { - this.theme.start() this.pico.terminal = this this.pico.start() - this.log('Started.') + this.theme.start() + this.qqq.start() this.update() this.setSpeed(120) @@ -85,6 +67,7 @@ function Terminal (pico) { } this.log = function (msg) { + console.info(msg) this.debug = msg this.update() } @@ -213,6 +196,25 @@ function Terminal (pico) { } ctx.fillText(styles.isCursor && g == '.' ? (!pico.isPaused ? '@' : '~') : g.toUpperCase(), (x + 0.5) * this.tile.w, (y + 1) * this.tile.h) } + + this.resize = function () { + this.size = { width: this.tile.w * pico.w, height: this.tile.h * pico.h + (this.tile.h * 3), ratio: 0.75 } + this.el.width = this.size.width + this.el.height = this.size.height + this.tile.h + this.el.style.width = (this.size.width * this.size.ratio) + 'px' + this.el.style.height = (this.size.height * this.size.ratio) + 'px' + + let { remote } = require('electron') + let win = remote.getCurrentWindow() + + win.setSize((this.size.width * this.size.ratio) + 60, (this.size.height * this.size.ratio) + 30, true) + } + + window.onresize = (event) => { + const marginTop = (window.innerHeight - (this.size.height * this.size.ratio)) / 2 + this.el.style.marginTop = (marginTop - 20) + 'px' + } + function clamp (v, min, max) { return v < min ? min : v > max ? max : v } } |