diff options
author | Devine Lu Linvega <[email protected]> | 2018-11-17 14:49:08 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-11-17 14:49:08 +1200 |
commit | 1f738ddebddd2f09a10183063211c067bc12e885 (patch) | |
tree | dcf900fec5e6e2b120e906522519e3e96896dad3 | |
parent | 1c8d49e63ad3b15488c146363ce7fa9dbe5b3f2a (diff) | |
download | Orca-1f738ddebddd2f09a10183063211c067bc12e885.tar.gz Orca-1f738ddebddd2f09a10183063211c067bc12e885.zip |
Improved the midi nodeNew-Ports
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | desktop/core/lib/_midi.js | 30 | ||||
-rw-r--r-- | desktop/core/lib/e.js | 1 | ||||
-rw-r--r-- | desktop/core/lib/n.js | 1 | ||||
-rw-r--r-- | desktop/core/lib/s.js | 1 | ||||
-rw-r--r-- | desktop/core/lib/w.js | 1 | ||||
-rw-r--r-- | examples/blank.pico | 20 | ||||
-rw-r--r-- | examples/mini.pico | 12 |
8 files changed, 25 insertions, 43 deletions
@@ -9,7 +9,7 @@ ### alpha functions - `A`, **add**: Creates the result of the addition of east and west fns, southward. -- `B`, **Banger**: Bangs southward in the presence of `1`, `N`, `S`, `W`, `E` or `Z` northward. +- `B`, **banger**: Bangs southward in the presence of `1`, `N`, `S`, `W`, `E` or `Z` northward. - `C`, **clock**: A sync value. - `D`, **<missing name>**: Missing docs. - `E`, **east**: Moves eastward, or bangs. diff --git a/desktop/core/lib/_midi.js b/desktop/core/lib/_midi.js index 91bd475..1e4c112 100644 --- a/desktop/core/lib/_midi.js +++ b/desktop/core/lib/_midi.js @@ -8,35 +8,21 @@ function FnMidi (pico, x, y, isPassive) { this.name = 'midi' this.info = 'Sends Midi' - this.ports = [{ x: 1, y: 0, input: true }, { x: 2, y: 0, input: true }, { x: 3, y: 0, input: true }, { x: 0, y: 0, bang: true }] - - this.haste = function () { - pico.lock(this.x + 1, this.y) - pico.lock(this.x + 2, this.y) - pico.lock(this.x + 3, this.y) - } + this.ports.input.channel = { x: 1, y: 0 } + this.ports.input.octave = { x: 2, y: 0 } + this.ports.input.note = { x: 3, y: 0 } this.run = function () { if (!this.bang()) { return } const notes = ['C', 'c', 'D', 'd', 'E', 'F', 'f', 'G', 'g', 'A', 'a', 'b'] + const channel = clamp(this.listen(this.ports.input.channel, true),0,15) + const octave = clamp(this.listen(this.ports.input.octave, true),2,9) + const note = this.listen(this.ports.input.note) - const channelGlyph = pico.glyphAt(this.x + 1, this.y) - const octaveGlyph = pico.glyphAt(this.x + 2, this.y) - const noteGlyph = pico.glyphAt(this.x + 3, this.y) - - if (channelGlyph === '.' || octaveGlyph === '.' || noteGlyph === '.') { return } - if (notes.indexOf(noteGlyph) < 0) { return } - - const channelValue = pico.valueOf(channelGlyph) - const octaveValue = pico.valueOf(octaveGlyph) - const noteValue = pico.valueOf(noteGlyph) - - const channel = clamp(channelValue, 0, 15) - const octave = clamp(octaveValue, 2, 9) - const note = notes.indexOf(noteGlyph) + if (notes.indexOf(note) < 0) { return } - terminal.midi.send(channel, octave, note, 127) + terminal.midi.send(channel, octave, notes.indexOf(note), 127) } function clamp (v, min, max) { return v < min ? min : v > max ? max : v } diff --git a/desktop/core/lib/e.js b/desktop/core/lib/e.js index f1a4ea2..edc5269 100644 --- a/desktop/core/lib/e.js +++ b/desktop/core/lib/e.js @@ -11,6 +11,7 @@ function FnE (pico, x, y, isPassive) { this.haste = function () { if (this.isFree(1, 0) !== true) { this.replace('*'); this.lock(); return } this.move(1, 0) + this.isPassive = false } } diff --git a/desktop/core/lib/n.js b/desktop/core/lib/n.js index c263280..d31cb91 100644 --- a/desktop/core/lib/n.js +++ b/desktop/core/lib/n.js @@ -11,6 +11,7 @@ function FnN (pico, x, y, isPassive) { this.haste = function () { if (this.isFree(0, -1) !== true) { this.replace('*'); this.lock(); return } this.move(0, -1) + this.isPassive = false } } diff --git a/desktop/core/lib/s.js b/desktop/core/lib/s.js index 56f56fc..6beb57d 100644 --- a/desktop/core/lib/s.js +++ b/desktop/core/lib/s.js @@ -11,6 +11,7 @@ function FnS (pico, x, y, isPassive) { this.haste = function () { if (this.isFree(0, 1) !== true) { this.replace('*'); return } this.move(0, 1) + this.isPassive = false } } diff --git a/desktop/core/lib/w.js b/desktop/core/lib/w.js index ef0a12c..2f4b6e2 100644 --- a/desktop/core/lib/w.js +++ b/desktop/core/lib/w.js @@ -11,6 +11,7 @@ function FnW (pico, x, y, isPassive) { this.haste = function () { if (this.isFree(-1, 0) !== true) { this.replace('*'); this.lock(); return } this.move(-1, 0) + this.isPassive = false } } diff --git a/examples/blank.pico b/examples/blank.pico deleted file mode 100644 index d6280c0..0000000 --- a/examples/blank.pico +++ /dev/null @@ -1,20 +0,0 @@ -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -........................................................... -...........................................................
\ No newline at end of file diff --git a/examples/mini.pico b/examples/mini.pico new file mode 100644 index 0000000..cb1e1e3 --- /dev/null +++ b/examples/mini.pico @@ -0,0 +1,12 @@ +....................... +....................... +....................... +....................... +....................... +....................... +....................... +....................... +....................... +....................... +....................... +....................... |