aboutsummaryrefslogtreecommitdiffhomepage
path: root/desktop/core/library/_keys.js
blob: 634670caeeaf8a98e710043441bcee2fd0719f4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict'

import Operator from '../operator.js'

export default function OperatorKeys (orca, x, y, passive) {
  Operator.call(this, orca, x, y, '&', true)

  this.name = 'keys'
  this.info = 'Receive MIDI note'

  this.ports.channel = { x: 1, y: 0, clamp: { min: 0, max: 16 }, default: '0' }
  this.ports.output = { x: 0, y: 1 }

  this.operation = function (force = false) {
    const channel = this.listen(this.ports.channel, true)

    const id = terminal.io.midi.keys[channel]

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

    return id ? terminal.io.midi.convert(id) : '.'
  }
}