Skip to content

Commit

Permalink
cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
davay42 committed Nov 10, 2024
1 parent d6c621c commit 616f98e
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/useMidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { reactive, computed, watchEffect, onMounted, ref, watch, shallowReactive
const inputs = shallowReactive({})
const outputs = shallowReactive({})


const midi = reactive({
enabled: false,
playing: false,
Expand Down Expand Up @@ -39,7 +38,20 @@ function initMidi() {
forwarder: input.addForwarder(),
}
input.removeListener();
setupInputListeners(input);
Object.entries({
start: () => { midi.playing = true; midi.stopped = false; },
stop: () => { midi.playing = false; midi.stopped = Date.now(); },
// clock: handleClock(input),
// midimessage: handleMidiMessage(input),
// noteon: ev => inputs[input.id].note = noteInOn(ev),
// noteoff: ev => inputs[input.id].note = noteInOn(ev),
// controlchange: handleControlChange(input),
// channelaftertouch: handleMonoAftertouch(input),
// keyaftertouch: handlePolyAftertouch(input),
// pitchbend: handlePitchBend(input),
}).forEach(([event, handler]) => {
input.addListener(event, handler);
});
})
WebMidi.outputs.forEach(output => {
outputs[output.id] = {
Expand All @@ -49,19 +61,5 @@ function initMidi() {
})
}

function setupInputListeners(input) {
Object.entries({
start: () => { midi.playing = true; midi.stopped = false; },
stop: () => { midi.playing = false; midi.stopped = Date.now(); },
// clock: handleClock(input),
// midimessage: handleMidiMessage(input),
// noteon: ev => inputs[input.id].note = noteInOn(ev),
// noteoff: ev => inputs[input.id].note = noteInOn(ev),
// controlchange: handleControlChange(input),
// channelaftertouch: handleMonoAftertouch(input),
// keyaftertouch: handlePolyAftertouch(input),
// pitchbend: handlePitchBend(input),
}).forEach(([event, handler]) => {
input.addListener(event, handler);
});
}


0 comments on commit 616f98e

Please sign in to comment.