mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
36 lines
691 B
Go
36 lines
691 B
Go
package processing
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"gitlab.com/gomidi/midi/v2"
|
|
)
|
|
|
|
type MIDIMessageEncode struct {
|
|
config ProcessorConfig
|
|
}
|
|
|
|
func (mme *MIDIMessageEncode) Process(ctx context.Context, payload any) (any, error) {
|
|
payloadMessage, ok := payload.(midi.Message)
|
|
|
|
if !ok {
|
|
return nil, fmt.Errorf("mqtt.message.encode processor only accepts an mqtt.Message")
|
|
}
|
|
|
|
return payloadMessage.Bytes(), nil
|
|
}
|
|
|
|
func (mme *MIDIMessageEncode) Type() string {
|
|
return mme.config.Type
|
|
}
|
|
|
|
func init() {
|
|
RegisterProcessor(ProcessorRegistration{
|
|
Type: "midi.message.encode",
|
|
New: func(config ProcessorConfig) (Processor, error) {
|
|
return &MIDIMessageEncode{config: config}, nil
|
|
},
|
|
})
|
|
}
|