Fixes WebMidi use and possible undefined issue
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
6af9436544
commit
41f498d85d
24
src/App.tsx
24
src/App.tsx
@ -13,20 +13,20 @@ function App() {
|
||||
function connect() {
|
||||
WebMidi.enable()
|
||||
.then(
|
||||
(_: WebMidi) => midiReady(),
|
||||
(_) => midiReady(),
|
||||
(err) => console.log('Something went wrong', err));
|
||||
}
|
||||
|
||||
function midiReady() {
|
||||
// react to device changes.
|
||||
//midi.addEventListener('statechange', (event) => initDevices(event.target));
|
||||
initDevices(WebMidi);
|
||||
initDevices();
|
||||
}
|
||||
|
||||
function initDevices(midi: WebMidi) {
|
||||
function initDevices() {
|
||||
//console.log(midi)
|
||||
let midiOutputMap = new Map()
|
||||
midi.outputs.forEach((outputInfo: Output) => {
|
||||
WebMidi.outputs.forEach((outputInfo: Output) => {
|
||||
console.log(outputInfo.id)
|
||||
midiOutputMap.set(outputInfo.id, outputInfo)
|
||||
})
|
||||
@ -57,13 +57,15 @@ function App() {
|
||||
if(selectedMidiDevice) {
|
||||
let outputDevice = midiDeviceMap.get(selectedMidiDevice)
|
||||
let midiChannel = 2
|
||||
outputDevice.sendControlChange(1, 127, {channels: midiChannel})
|
||||
pause(50)
|
||||
outputDevice.sendProgramChange(bankNumber, {channels: midiChannel})
|
||||
pause(200)
|
||||
outputDevice.sendControlChange(1, 0, {channels: midiChannel})
|
||||
pause(50)
|
||||
outputDevice.sendProgramChange(patchNumber, {channels: midiChannel})
|
||||
if(outputDevice) {
|
||||
outputDevice.sendControlChange(1, 127, {channels: midiChannel})
|
||||
pause(50)
|
||||
outputDevice.sendProgramChange(bankNumber, {channels: midiChannel})
|
||||
pause(200)
|
||||
outputDevice.sendControlChange(1, 0, {channels: midiChannel})
|
||||
pause(50)
|
||||
outputDevice.sendProgramChange(patchNumber, {channels: midiChannel})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user