aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2018-12-13 15:32:02 +1200
committerDevine Lu Linvega <[email protected]>2018-12-13 15:32:02 +1200
commitb48dad5a4cc2df2e1da62e4d079c43c6060c56cd (patch)
treee5a06a16d4dbe6f2136d4d462987e5aa6e4ffd2a
parent38daf9ca4441e633b91302044670ece068b06d4c (diff)
downloadOrca-b48dad5a4cc2df2e1da62e4d079c43c6060c56cd.tar.gz
Orca-b48dad5a4cc2df2e1da62e4d079c43c6060c56cd.zip
Changed midi specs
-rw-r--r--README.md4
-rw-r--r--desktop/core/library/_midi.js16
-rw-r--r--desktop/core/library/v.js37
-rw-r--r--desktop/sources/scripts/io.js2
4 files changed, 19 insertions, 40 deletions
diff --git a/README.md b/README.md
index 6c5d938..334a45c 100644
--- a/README.md
+++ b/README.md
@@ -95,11 +95,11 @@ The midi operator `:` takes up to 5 inputs('channel, 'octave, 'note, velocity, l
#### Velocity*
-Velocity is either from `0-9`(10 steps), or `A-Z`(26 steps). For example, `:34C8`, is a **C note, on the 4th octave, through the 4th MIDI channel with a velocity of 112/127(88%)**, `:34CT`, is a **C note, on the 4th octave, through the 4th MIDI channel with a velocity of 96/127(75%)**.
+Velocity is a value from `1`(8/127) to `g`(127/127). For example, `:34C8.`, is a **C note, on the 4th octave, through the 4th MIDI channel with a velocity of 63/127(50%)**, `:34CG.`, is a **C note, on the 4th octave, through the 4th MIDI channel with a velocity of 127/127(100%)**.
#### Note Length*
-Note length is a value from `1-f`, which is a ratio of a full bar, *1* being `1/1`(a full bar), *2* being `1/2`(half), *3* being `1/3`(third).. and *f* being `1/16`. For example, `:27FZ4`, is a **F note, on the 7th octave, through the 3rd MIDI channel with a velocity of 100%, lasting for 1/4 of a bar**.
+Note length is a value from `1`(1/16) to `g`(16/16), which is a ratio of a full bar, *f* being `16/16`(a full bar), *8* being `1/2`(half), *4* being `1/4`(quarter).. and *1* being `1/16`. For example, `:27D.F`, is a **D note, on the 7th octave, through the 3rd MIDI channel lasting for a full bar**.
### UDP Output
diff --git a/desktop/core/library/_midi.js b/desktop/core/library/_midi.js
index f1ef5c8..65f9012 100644
--- a/desktop/core/library/_midi.js
+++ b/desktop/core/library/_midi.js
@@ -20,8 +20,10 @@ function OperatorMidi (orca, x, y, passive) {
let rawChannel = this.listen(this.ports.input.channel)
let rawOctave = this.listen(this.ports.input.octave, true)
let rawNote = this.listen(this.ports.input.note)
+ let rawVelocity = this.listen(this.ports.haste.velocity)
+ let rawLength = this.listen(this.ports.haste.length)
- if (rawChannel === '.' || orca.valueOf(rawChannel) > 15 || rawOctave === 0 || rawOctave > 8 || rawNote === '.') { return }
+ if (rawChannel === '.' || orca.valueOf(rawChannel) > 15 || rawOctave === 0 || rawOctave > 8 || rawNote === '.' || rawVelocity === '0' || rawLength === '0') { return }
// 0 - 16
const channel = clamp(orca.valueOf(rawChannel), 0, 15)
@@ -29,10 +31,10 @@ function OperatorMidi (orca, x, y, passive) {
const octave = clamp(rawNote === 'b' ? rawOctave + 1 : rawOctave, 1, 9)
// 0 - 11
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)
+ // 0 - F(127)
+ const velocity = rawVelocity === '.' ? 127 : parseInt((clamp(orca.valueOf(rawVelocity), 1, 15) / 15) * 127)
+ // 0 - F(15)
+ const length = clamp(orca.valueOf(rawLength), 1, 15)
if (note < 0) { console.warn(`Unknown note:${rawNote}`); return }
@@ -41,10 +43,6 @@ function OperatorMidi (orca, x, y, passive) {
terminal.io.sendMidi(channel, octave, note, velocity, length)
}
- function convertVelocity (val, max) {
- return parseInt((!val ? 1 : val < 10 ? (val / 9) : (val - 10) / 25) * max)
- }
-
function clamp (v, min, max) { return v < min ? min : v > max ? max : v }
}
diff --git a/desktop/core/library/v.js b/desktop/core/library/v.js
index 01167fd..59b4fd1 100644
--- a/desktop/core/library/v.js
+++ b/desktop/core/library/v.js
@@ -18,45 +18,26 @@ function OperatorV (orca, x, y, passive) {
this.storage.write = this.listen(this.ports.haste.write)
this.storage.read = this.listen(this.ports.input.read)
- if (!this.isWritting()) { return }
-
- this.ports.output = null
+ if (this.storage.write !== '.' && this.storage.read !== '.') {
+ this.ports.output = null
+ }
}
this.run = function () {
- if (!this.isReading()) { return }
-
- const key = this.storage.read
- const res = this.read(key)
-
- this.output(`${res}`)
- }
-
- this.isWritting = function () {
- const key = this.storage.write
- const val = this.storage.read
+ if (this.storage.write !== '.' || this.storage.read === '.') { return }
- return key !== '.' && val !== '.'
- }
-
- this.isReading = function () {
- const key = this.storage.write
- const val = this.storage.read
-
- return key === '.' && val !== '.'
- }
-
- this.read = function (key) {
for (const id in orca.runtime) {
const operator = orca.runtime[id]
if (orca.lockAt(operator.x, operator.y)) { continue }
const glyph = operator.glyph.toLowerCase()
if (glyph !== 'v') { continue }
const write = operator.storage.write
- if (write !== key) { continue }
- return operator.storage.read
+ if (write !== this.storage.read) { continue }
+ this.output(operator.storage.read)
+ return
}
- return '.'
+
+ this.output('.')
}
}
diff --git a/desktop/sources/scripts/io.js b/desktop/sources/scripts/io.js
index 2b4f80c..ce884d9 100644
--- a/desktop/sources/scripts/io.js
+++ b/desktop/sources/scripts/io.js
@@ -107,7 +107,7 @@ function IO (terminal) {
}
function convertLength (val, bpm) {
- return (60000 / bpm) / val
+ return (60000 / bpm) * (val / 15)
}
// Setup