-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
key.go
33 lines (26 loc) · 766 Bytes
/
key.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package control
import (
"fmt"
"github.com/emicklei/melrose/core"
)
type Key struct {
deviceID int
channel int
note core.Note
}
func NewKey(deviceID int, channel int, note core.Note) Key {
return Key{deviceID: deviceID, channel: channel, note: note}
}
// Inspect is part of Inspectable
func (k Key) Inspect(i core.Inspection) {
i.Properties["device"] = k.deviceID
i.Properties["channel"] = k.channel
i.Properties["note"] = k.note
}
func (k Key) Channel() int { return k.channel }
func (k Key) DeviceID() int { return k.deviceID }
func (k Key) Note() core.Note { return k.note }
// Storex is part of core.Storable
func (k Key) Storex() string {
return fmt.Sprintf("key(device(%d,channel(%d,%s)))", k.deviceID, k.channel, k.note.Storex())
}