Added device enumeration to client

live
noah metz 2024-04-08 11:32:39 -06:00
parent 4a2ce02617
commit 689cd9d4dc
1 changed files with 36 additions and 0 deletions

@ -17,6 +17,42 @@ func main() {
defer ctx.Free() defer ctx.Free()
defer ctx.Uninit() defer ctx.Uninit()
// Playback devices.
infos, err := ctx.Devices(malgo.Playback)
if err != nil {
panic(err)
}
fmt.Println("Playback Devices")
for i, info := range infos {
e := "ok"
full, err := ctx.DeviceInfo(malgo.Playback, info.ID, malgo.Shared)
if err != nil {
e = err.Error()
}
fmt.Printf(" %d: %v, %s, [%s], formats: %+v\n",
i, info.ID, info.Name(), e, full.Formats)
}
fmt.Println()
// Capture devices.
infos, err = ctx.Devices(malgo.Capture)
if err != nil {
panic(err)
}
fmt.Println("Capture Devices")
for i, info := range infos {
e := "ok"
full, err := ctx.DeviceInfo(malgo.Capture, info.ID, malgo.Shared)
if err != nil {
e = err.Error()
}
fmt.Printf(" %d: %v, %s, [%s], formats: %+v\n",
i, info.ID, info.Name(), e, full.Formats)
}
inDeviceConfig := malgo.DefaultDeviceConfig(malgo.Capture) inDeviceConfig := malgo.DefaultDeviceConfig(malgo.Capture)
inDeviceConfig.Capture.Format = malgo.FormatF32 inDeviceConfig.Capture.Format = malgo.FormatF32
inDeviceConfig.Capture.Channels = 1 inDeviceConfig.Capture.Channels = 1