diff options
author | Devine Lu Linvega <[email protected]> | 2018-10-17 11:12:32 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-10-17 11:12:32 +1200 |
commit | 5bab4a25f0986b845d8afc1df58b9c0a8786d91c (patch) | |
tree | 5747f8125502e6277b5cf65a184b19d91754c85a | |
parent | 8f60f2dbb8c512ba283eff1bc12a2cb4c048fbfe (diff) | |
download | Orca-5bab4a25f0986b845d8afc1df58b9c0a8786d91c.tar.gz Orca-5bab4a25f0986b845d8afc1df58b9c0a8786d91c.zip |
Figured out some midi channel stuff
-rw-r--r-- | README.md | 15 | ||||
-rw-r--r-- | desktop/core/lib.js | 2 | ||||
-rw-r--r-- | desktop/core/lib/__qqq.js | 4 | ||||
-rw-r--r-- | desktop/sources/scripts/qqq.js | 30 |
4 files changed, 33 insertions, 18 deletions
@@ -81,6 +81,21 @@ npm install npm start ``` +## Notes + +- `0x92 & 0xf0 = 144`, Ch3 noteOn +- `0x80 & 0xf0 = 128`, Ch1 noteOff + +``` +function frequencyFromNoteNumber(note) { + return 440 * Math.pow(2, (note - 69) / 12); +} +``` + +- Note values are on a range from 0–127, lowest to highest. For example, the lowest note on an 88-key piano has a value of 21, and the highest note is 108. A “middle C” is 60. +- Velocity values are also given on a range from 0–127 (softest to loudest). The softest possible “note on” velocity is 1. + + ## TODO The idea is to build a synth/mini sequencer, here's some tasks I need to tackle before then. diff --git a/desktop/core/lib.js b/desktop/core/lib.js index 47ded70..eaab5b8 100644 --- a/desktop/core/lib.js +++ b/desktop/core/lib.js @@ -52,6 +52,6 @@ module.exports = { queries: { 'bpm': require('./lib/__bpm'), 'vol': require('./lib/__vol'), - 'qqq': require('./lib/__qqq'), + 'qqq': require('./lib/__qqq') } } diff --git a/desktop/core/lib/__qqq.js b/desktop/core/lib/__qqq.js index 199d778..a91affb 100644 --- a/desktop/core/lib/__qqq.js +++ b/desktop/core/lib/__qqq.js @@ -17,8 +17,8 @@ function FnQqq (pico, x, y) { this.run = function () { const n = this.north() - if(n){ - terminal.qqq.play() + if (n) { + terminal.qqq.play() } } } diff --git a/desktop/sources/scripts/qqq.js b/desktop/sources/scripts/qqq.js index 5710ab5..3eb2bc5 100644 --- a/desktop/sources/scripts/qqq.js +++ b/desktop/sources/scripts/qqq.js @@ -17,30 +17,30 @@ function QQQ (terminal) { } this.midiActive = function (midiAccess) { - - const iter = midiAccess.outputs.values(); + 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.qqq.outputs.push(i.value) } } this.midiInactive = function (err) { - console.warn("No Midi") + console.warn('No Midi') } this.play = function () { - 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.ch1() + this.ch3() + } + + this.ch1 = function () { + terminal.qqq.outputs[0].send([0x90, 60, 127]) + terminal.qqq.outputs[0].send([0x80, 60, 127], window.performance.now() + 250.0) + } + + this.ch3 = function () { + terminal.qqq.outputs[0].send([0x92, 60, 127]) + terminal.qqq.outputs[0].send([0x82, 60, 127], window.performance.now() + 250.0) } this.setVolume = function (value) { |