diff options
author | Devine Lu Linvega <[email protected]> | 2018-12-09 08:04:04 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-12-09 08:04:04 +1200 |
commit | 677eac43915eef8300b9695c06bf9fdaffa21b94 (patch) | |
tree | 12b7e9773f5ff3a585e53bc37efa4f27581615be | |
parent | 8a2656f420de865e944139e8d07e74bb90748384 (diff) | |
download | Orca-677eac43915eef8300b9695c06bf9fdaffa21b94.tar.gz Orca-677eac43915eef8300b9695c06bf9fdaffa21b94.zip |
Fixed issue with E# and B#
-rw-r--r-- | desktop/core/library/_midi.js | 20 | ||||
-rw-r--r-- | examples/octave.orca | 13 |
2 files changed, 22 insertions, 11 deletions
diff --git a/desktop/core/library/_midi.js b/desktop/core/library/_midi.js index 18987e4..a993e75 100644 --- a/desktop/core/library/_midi.js +++ b/desktop/core/library/_midi.js @@ -17,28 +17,26 @@ function OperatorMidi (orca, x, y, passive) { this.run = function () { if (!this.bang()) { return } - const rawChannel = this.listen(this.ports.input.channel, true) - const rawOctave = this.listen(this.ports.input.octave, true) - const rawNote = this.listen(this.ports.input.note, true) + let rawChannel = this.listen(this.ports.input.channel, true) + let rawOctave = this.listen(this.ports.input.octave, true) + let rawNote = this.listen(this.ports.input.note) - if (rawOctave === 0 || rawNote === 0) { return } - - this.draw = false - - const notes = ['C', 'c', 'D', 'd', 'E', 'F', 'f', 'G', 'g', 'A', 'a', 'B'] + if (rawOctave === 0 || rawNote === '.') { return } // 0 - 16 const channel = clamp(rawChannel, 0, 15) // 1 - 9 - const octave = clamp(rawOctave, 1, 9) + const octave = clamp(rawNote === 'b' ? rawOctave + 1 : rawOctave, 1, 9) // 0 - 11 - const note = notes.indexOf(this.listen(this.ports.input.note)) + const note = ['C', 'c', 'D', 'd', 'E', 'F', 'f', 'G', 'g', 'A', 'a', 'B'].indexOf(rawNote === 'e' ? 'F' : rawNote === 'b' ? 'C' : rawNote) // 0 - 127 const velocity = convertVelocity(this.listen(this.ports.haste.velocity, true), 127) // 0 - 16 const length = clamp(this.listen(this.ports.haste.length, true), 1, 16) - if (note < 0) { return } + if (note < 0) { console.warn(`Unknown note:${rawNote}`); return } + + this.draw = false terminal.io.sendMidi(channel, octave, note, velocity, length) } diff --git a/examples/octave.orca b/examples/octave.orca new file mode 100644 index 0000000..8afc418 --- /dev/null +++ b/examples/octave.orca @@ -0,0 +1,13 @@ +......................................... +.#.OCTAVE.#.............................. +......................................... +......................................... +......................................... +...4Cc................................... +.4D32cTCcDdEFfGgAaB...................... +...:03D.................................. +......................................... +......................................... +......................................... +......................................... +........................................
\ No newline at end of file |