fixed multiple MIDI devices S/N

This commit is contained in:
2024-12-26 14:55:55 +01:00
9 changed files with 142 additions and 36 deletions

View File

@@ -10,25 +10,6 @@ import (
"github.com/mattrtaylor/go-rtmidi"
)
/*
DMXConnect
DMXUSBProtocol.go
Copyright (c) Valentin Boulanger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// MIDIDriver represents how the protocol is defined
type MIDIDriver struct {
peripherals map[string]Peripheral // The list of peripherals
@@ -109,7 +90,8 @@ func (d *MIDIDriver) Scan(ctx context.Context) error {
}
fmt.Printf("New MIDI device found: %s on %i\n", name, location)
// Add the peripheral to the temporary list
midiPeripherals[portName] = NewMIDIPeripheral(name, location)
sn := strings.ToLower(strings.Replace(name, " ", "_", -1))
midiPeripherals[sn] = NewMIDIPeripheral(name, location, sn)
}
// Compare with the current peripherals to detect arrivals/removals
removedList, addedList := comparePeripherals(d.peripherals, midiPeripherals)