mirror of https://github.com/nealey/vail.git
Send keyer state every time it's connected
This commit is contained in:
parent
b7de5cf8cb
commit
15e43c28df
|
@ -108,6 +108,8 @@ export class Keyboard extends Input{
|
|||
export class MIDI extends Input{
|
||||
constructor(keyer) {
|
||||
super(keyer)
|
||||
this.ditDuration = 100
|
||||
this.keyerMode = 0
|
||||
|
||||
this.midiAccess = {outputs: []} // stub while we wait for async stuff
|
||||
if (navigator.requestMIDIAccess) {
|
||||
|
@ -122,18 +124,28 @@ export class MIDI extends Input{
|
|||
this.midiStateChange()
|
||||
}
|
||||
|
||||
SetDitDuration(delay) {
|
||||
// Send the Vail adapter the current iambic delay setting
|
||||
sendState() {
|
||||
for (let output of this.midiAccess.outputs.values()) {
|
||||
// MIDI only supports 7-bit values, so we have to divide it by two
|
||||
output.send([0xB0, 0x01, delay/2])
|
||||
// Turn off keyboard mode
|
||||
output.send([0xB0, 0x00, 0x00])
|
||||
|
||||
// MIDI only supports 7-bit values, so we have to divide ditduration by two
|
||||
output.send([0xB0, 0x01, this.ditDuration/2])
|
||||
|
||||
// Send keyer mode
|
||||
output.send([0xC0, this.keyerMode])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SetDitDuration(duration) {
|
||||
this.ditDuration = duration
|
||||
this.sendState()
|
||||
}
|
||||
|
||||
SetKeyerMode(mode) {
|
||||
for (let output of this.midiAccess.outputs.values()) {
|
||||
output.send([0xC0, mode])
|
||||
}
|
||||
this.keyerMode = mode
|
||||
this.sendState()
|
||||
}
|
||||
|
||||
midiStateChange(event) {
|
||||
|
@ -146,9 +158,7 @@ export class MIDI extends Input{
|
|||
}
|
||||
|
||||
// Tell the Vail adapter to disable keyboard events: we can do MIDI!
|
||||
for (let output of this.midiAccess.outputs.values()) {
|
||||
output.send([0xB0, 0x00, 0x00]) // Turn off keyboard mode
|
||||
}
|
||||
this.sendState()
|
||||
}
|
||||
|
||||
midiMessage(event) {
|
||||
|
|
Loading…
Reference in New Issue