Skip to content

Commit bd7e751

Browse files
committed
fix Devices on linux, add keystation test
1 parent 4dfd805 commit bd7e751

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

keystation_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package midi
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
"testing"
7+
)
8+
9+
func TestKeystation(t *testing.T) {
10+
devices, err := Devices()
11+
if err != nil {
12+
t.Fatal(err)
13+
}
14+
var keystation *Device
15+
for _, d := range devices {
16+
if strings.Contains(strings.ToLower(d.Name), "keystation") {
17+
keystation = d
18+
break
19+
}
20+
}
21+
if keystation == nil {
22+
t.Log("no keystation detected")
23+
t.SkipNow()
24+
}
25+
fmt.Println("keystation detected")
26+
27+
if err := keystation.Open(); err != nil {
28+
t.Fatal(err)
29+
}
30+
packets, err := keystation.Packets()
31+
if err != nil {
32+
t.Fatal(err)
33+
}
34+
i := 0
35+
for pkt := range packets {
36+
if i == 4 {
37+
break
38+
}
39+
fmt.Printf("%#v\n", pkt)
40+
}
41+
}

launchpad_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestLaunchpad(t *testing.T) {
1313
// The reason this package exists is because of issues that popped up when
1414
// trying to use github.com/rakyll/portmidi to talk to the launchpad on Linux.
1515
// For the launchpad MIDI reference, see https://d19ulaff0trnck.cloudfront.net/sites/default/files/novation/downloads/4080/launchpad-programmers-reference.pdf
16-
// t.SkipNow()
16+
t.SkipNow()
1717

1818
device := &Device{ID: "hw:0"}
1919
if err := device.Open(); err != nil {

midi_linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,14 @@ func Devices() ([]*Device, error) {
118118
if err != nil {
119119
return nil, err
120120
}
121+
devices = append(devices, cardDevices...)
122+
121123
if rc := C.snd_card_next(&card); rc != 0 {
122124
return nil, alsaMidiError(rc)
123125
}
124126
if card < 0 {
125127
break
126128
}
127-
devices = append(devices, cardDevices...)
128129
}
129130
return devices, nil
130131
}

0 commit comments

Comments
 (0)