2025-01-18 14:53:29 +00:00
|
|
|
package hardware
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// MIDIPeripheral contains the data of a MIDI peripheral
|
|
|
|
|
type MIDIPeripheral struct {
|
2025-01-25 11:06:03 +01:00
|
|
|
name string // The name of the peripheral
|
|
|
|
|
location int // The location of the peripheral
|
|
|
|
|
serialNumber string // The S/N of the peripheral
|
|
|
|
|
settings map[string]interface{} // The settings of the peripheral
|
2025-01-18 14:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewMIDIPeripheral creates a new MIDI peripheral
|
|
|
|
|
func NewMIDIPeripheral(name string, location int, serialNumber string) *MIDIPeripheral {
|
|
|
|
|
log.Trace().Str("file", "MIDIPeripheral").Str("name", name).Str("s/n", serialNumber).Int("location", location).Msg("MIDI peripheral created")
|
2025-01-25 11:06:03 +01:00
|
|
|
settings := make(map[string]interface{})
|
2025-01-18 14:53:29 +00:00
|
|
|
return &MIDIPeripheral{
|
|
|
|
|
name: name,
|
|
|
|
|
location: location,
|
|
|
|
|
serialNumber: serialNumber,
|
2025-01-25 11:06:03 +01:00
|
|
|
settings: settings,
|
2025-01-18 14:53:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Connect connects the MIDI peripheral
|
|
|
|
|
func (p *MIDIPeripheral) Connect(ctx context.Context) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Disconnect disconnects the MIDI peripheral
|
|
|
|
|
func (p *MIDIPeripheral) Disconnect(ctx context.Context) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Activate activates the MIDI peripheral
|
|
|
|
|
func (p *MIDIPeripheral) Activate(ctx context.Context) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Deactivate deactivates the MIDI peripheral
|
|
|
|
|
func (p *MIDIPeripheral) Deactivate(ctx context.Context) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-25 16:00:02 +01:00
|
|
|
// SetPeripheralSetting sets a specific setting for this peripheral
|
|
|
|
|
func (p *MIDIPeripheral) SetPeripheralSetting(settingName string, settingValue interface{}) error {
|
|
|
|
|
p.settings[settingName] = settingValue
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-18 14:53:29 +00:00
|
|
|
// SetDeviceProperty - not implemented for this kind of peripheral
|
|
|
|
|
func (p *MIDIPeripheral) SetDeviceProperty(context.Context, uint32, uint32, byte) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-25 11:06:03 +01:00
|
|
|
// GetSettings gets the peripheral settings
|
|
|
|
|
func (p *MIDIPeripheral) GetSettings() map[string]interface{} {
|
|
|
|
|
return p.settings
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-18 14:53:29 +00:00
|
|
|
// GetInfo gets the peripheral information
|
|
|
|
|
func (p *MIDIPeripheral) GetInfo() PeripheralInfo {
|
|
|
|
|
return PeripheralInfo{
|
|
|
|
|
Name: p.name,
|
|
|
|
|
ProtocolName: "MIDI",
|
|
|
|
|
SerialNumber: p.serialNumber,
|
|
|
|
|
}
|
|
|
|
|
}
|