@@ -17,32 +17,22 @@ export default function OperatorMono (orca, x, y, passive) {
this.operation = function (force = false) {
if (!this.hasNeighbor('*') && force === false) { return }

if (this.listen(this.ports.channel) === '.') { return }
if (this.listen(this.ports.octave) === '.') { return }
if (this.listen(this.ports.note) === '.') { return }

const channel = this.listen(this.ports.channel, true)
const rawOctave = this.listen(this.ports.octave, true)
const rawNote = this.listen(this.ports.note)
const rawVelocity = this.listen(this.ports.velocity, true)
const channel = this.listen(this.ports.channel)
if (channel === '.') { return }
const octave = this.listen(this.ports.octave)
if (octave === '.') { return }
const note = this.listen(this.ports.note)
if (note === '.') { return }

const velocity = this.listen(this.ports.velocity, true)
const length = this.listen(this.ports.length, true)

if (!isNaN(rawNote)) { return }

const transposed = this.transpose(rawNote, rawOctave)
// 1 - 8
const octave = transposed.octave
// 0 - 11
const note = transposed.value
// 0 - G(127)
const velocity = parseInt((rawVelocity / 16) * 127)

this.draw = false

terminal.io.mono.send(channel, octave, note, velocity, length)

if (force === true) {
terminal.io.mono.run()
}

this.draw = false
}
}
@@ -1,7 +1,5 @@
'use strict'

import transpose from './transpose.js'

export default function Operator (orca, x, y, glyph = '.', passive = false) {
this.name = 'unknown'
this.x = x
@@ -129,18 +127,6 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) {
return false
}

// Notes tools

this.transpose = function (n, o = 3) {
if (!transpose[n]) { return { note: n, octave: o } }
const note = transpose[n].charAt(0)
const octave = clamp(parseInt(transpose[n].charAt(1)) + o, 0, 8)
const value = ['C', 'c', 'D', 'd', 'E', 'F', 'f', 'G', 'g', 'A', 'a', 'B'].indexOf(note)
const id = clamp((octave * 12) + value, 0, 127)
const real = id < 89 ? Object.keys(transpose)[id - 45] : null
return { id, value, note, octave, real }
}

// Docs

function clamp (v, min, max) { return v < min ? min : v > max ? max : v }
@@ -12,7 +12,7 @@ import Controller from './lib/controller.js'
import library from '../../core/library.js'

export default function Terminal () {
this.version = 132
this.version = 133
this.library = library

this.orca = new Orca(this)