mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-04-18 14:53:34 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c67887ad7 | |||
| 4db173154b | |||
| 27922d41bb | |||
| e21fd59564 | |||
| 2d829e28e1 | |||
| 3f8861ded2 | |||
| 1ad214ba4a | |||
| 66da965edd | |||
| 079a0b240d | |||
| fe711f79f1 | |||
| c94ac62cb8 | |||
| 5933b25114 |
21
README.md
21
README.md
@@ -12,7 +12,7 @@ go install github.com/onyx-and-iris/xair-cli@latest
|
|||||||
|
|
||||||
- --host/-H: Host of the mixer.
|
- --host/-H: Host of the mixer.
|
||||||
- --port/-P: Port of the mixer.
|
- --port/-P: Port of the mixer.
|
||||||
- --kind/-k: The kind of mixer. May one of (*xair*, *x32*).
|
- --kind/-k: The kind of mixer. May be one of (*xair*, *x32*).
|
||||||
- Use this flag to connect to an x32 mixer.
|
- Use this flag to connect to an x32 mixer.
|
||||||
|
|
||||||
#### Environment Variables
|
#### Environment Variables
|
||||||
@@ -25,7 +25,7 @@ Example .envrc:
|
|||||||
XAIR_CLI_HOST=mixer.local
|
XAIR_CLI_HOST=mixer.local
|
||||||
XAIR_CLI_PORT=10024
|
XAIR_CLI_PORT=10024
|
||||||
XAIR_CLI_KIND=xair
|
XAIR_CLI_KIND=xair
|
||||||
XAIR_CLI_RAW_TIMEOUT=50ms
|
XAIR_CLI_TIMEOUT=100ms
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use
|
### Use
|
||||||
@@ -37,10 +37,12 @@ A CLI to control Behringer X-Air mixers.
|
|||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help Show context-sensitive help.
|
-h, --help Show context-sensitive help.
|
||||||
--host="mixer.local" The host of the X-Air device ($XAIR_CLI_HOST).
|
-H, --host="mixer.local" The host of the X-Air device ($XAIR_CLI_HOST).
|
||||||
--port=10024 The port of the X-Air device ($XAIR_CLI_PORT).
|
-P, --port=10024 The port of the X-Air device ($XAIR_CLI_PORT).
|
||||||
--kind="xr18" The kind of the X-Air device ($XAIR_CLI_KIND).
|
-K, --kind="xair" The kind of the X-Air device ($XAIR_CLI_KIND).
|
||||||
-v, --version Print gobs-cli version information and quit
|
-T, --timeout=100ms Timeout for OSC operations ($XAIR_CLI_TIMEOUT).
|
||||||
|
-L, --loglevel="warn" Log level for the CLI ($XAIR_CLI_LOGLEVEL).
|
||||||
|
-v, --version Print xair-cli version information and quit
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
completion (c) Generate shell completion scripts.
|
completion (c) Generate shell completion scripts.
|
||||||
@@ -109,6 +111,13 @@ Headamp
|
|||||||
headamp <index> gain Get or set the gain of the headamp.
|
headamp <index> gain Get or set the gain of the headamp.
|
||||||
headamp <index> phantom Get or set the phantom power state of the headamp.
|
headamp <index> phantom Get or set the phantom power state of the headamp.
|
||||||
|
|
||||||
|
Snapshot
|
||||||
|
snapshot list List all snapshots.
|
||||||
|
snapshot <index> name Get or set the name of a snapshot.
|
||||||
|
snapshot <index> save Save the current mixer state.
|
||||||
|
snapshot <index> load Load a mixer state.
|
||||||
|
snapshot <index> delete Delete a snapshot.
|
||||||
|
|
||||||
Run "xair-cli <command> --help" for more information on a command.
|
Run "xair-cli <command> --help" for more information on a command.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
22
bus.go
22
bus.go
@@ -148,7 +148,7 @@ func (cmd *BusFadeoutCmd) Run(ctx *context, bus *BusCmdGroup) error {
|
|||||||
|
|
||||||
// BusNameCmd defines the command for getting or setting the name of a bus.
|
// BusNameCmd defines the command for getting or setting the name of a bus.
|
||||||
type BusNameCmd struct {
|
type BusNameCmd struct {
|
||||||
Name *string `arg:"" help:"The name to set for the bus. If not provided, the current name will be returned."`
|
Name *string `arg:"" help:"The name to set for the bus. If not provided, the current name will be returned." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the BusNameCmd command, either retrieving the current name of the bus or setting it based on the provided argument.
|
// Run executes the BusNameCmd command, either retrieving the current name of the bus or setting it based on the provided argument.
|
||||||
@@ -238,7 +238,7 @@ func (cmd *BusEqModeCmd) Run(ctx *context, bus *BusCmdGroup) error {
|
|||||||
|
|
||||||
// BusEqBandGainCmd defines the command for getting or setting the gain of a specific EQ band of a bus.
|
// BusEqBandGainCmd defines the command for getting or setting the gain of a specific EQ band of a bus.
|
||||||
type BusEqBandGainCmd struct {
|
type BusEqBandGainCmd struct {
|
||||||
Gain *float64 `arg:"" help:"The gain to set for the EQ band (in dB). If not provided, the current gain will be returned."`
|
Gain *float64 `arg:"" help:"The gain to set for the EQ band (in dB). If not provided, the current gain will be returned." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the BusEqBandGainCmd command, either retrieving the current gain of the specified EQ band of the bus or setting it based on the provided argument.
|
// Run executes the BusEqBandGainCmd command, either retrieving the current gain of the specified EQ band of the bus or setting it based on the provided argument.
|
||||||
@@ -261,7 +261,7 @@ func (cmd *BusEqBandGainCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmd
|
|||||||
|
|
||||||
// BusEqBandFreqCmd defines the command for getting or setting the frequency of a specific EQ band of a bus.
|
// BusEqBandFreqCmd defines the command for getting or setting the frequency of a specific EQ band of a bus.
|
||||||
type BusEqBandFreqCmd struct {
|
type BusEqBandFreqCmd struct {
|
||||||
Freq *float64 `arg:"" help:"The frequency to set for the EQ band (in Hz). If not provided, the current frequency will be returned."`
|
Freq *float64 `arg:"" help:"The frequency to set for the EQ band (in Hz). If not provided, the current frequency will be returned." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the BusEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band of the bus or setting it based on the provided argument.
|
// Run executes the BusEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band of the bus or setting it based on the provided argument.
|
||||||
@@ -284,7 +284,7 @@ func (cmd *BusEqBandFreqCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmd
|
|||||||
|
|
||||||
// BusEqBandQCmd defines the command for getting or setting the Q factor of a specific EQ band of a bus.
|
// BusEqBandQCmd defines the command for getting or setting the Q factor of a specific EQ band of a bus.
|
||||||
type BusEqBandQCmd struct {
|
type BusEqBandQCmd struct {
|
||||||
Q *float64 `arg:"" help:"The Q factor to set for the EQ band. If not provided, the current Q factor will be returned."`
|
Q *float64 `arg:"" help:"The Q factor to set for the EQ band. If not provided, the current Q factor will be returned." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the BusEqBandQCmd command, either retrieving the current Q factor of the specified EQ band of the bus or setting it based on the provided argument.
|
// Run executes the BusEqBandQCmd command, either retrieving the current Q factor of the specified EQ band of the bus or setting it based on the provided argument.
|
||||||
@@ -389,7 +389,7 @@ func (cmd *BusCompModeCmd) Run(ctx *context, bus *BusCmdGroup) error {
|
|||||||
|
|
||||||
// BusCompThresholdCmd defines the command for getting or setting the compressor threshold of a bus.
|
// BusCompThresholdCmd defines the command for getting or setting the compressor threshold of a bus.
|
||||||
type BusCompThresholdCmd struct {
|
type BusCompThresholdCmd struct {
|
||||||
Threshold *float64 `arg:"" help:"The compressor threshold to set (in dB). If not provided, the current compressor threshold will be returned."`
|
Threshold *float64 `arg:"" help:"The compressor threshold to set (in dB). If not provided, the current compressor threshold will be returned." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the BusCompThresholdCmd command, either retrieving the current compressor threshold of the bus or setting it based on the provided argument.
|
// Run executes the BusCompThresholdCmd command, either retrieving the current compressor threshold of the bus or setting it based on the provided argument.
|
||||||
@@ -412,7 +412,7 @@ func (cmd *BusCompThresholdCmd) Run(ctx *context, bus *BusCmdGroup) error {
|
|||||||
|
|
||||||
// BusCompRatioCmd defines the command for getting or setting the compressor ratio of a bus.
|
// BusCompRatioCmd defines the command for getting or setting the compressor ratio of a bus.
|
||||||
type BusCompRatioCmd struct {
|
type BusCompRatioCmd struct {
|
||||||
Ratio *float64 `arg:"" help:"The compressor ratio to set. If not provided, the current compressor ratio will be returned."`
|
Ratio *float64 `arg:"" help:"The compressor ratio to set. If not provided, the current compressor ratio will be returned." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the BusCompRatioCmd command, either retrieving the current compressor ratio of the bus or setting it based on the provided argument.
|
// Run executes the BusCompRatioCmd command, either retrieving the current compressor ratio of the bus or setting it based on the provided argument.
|
||||||
@@ -435,7 +435,7 @@ func (cmd *BusCompRatioCmd) Run(ctx *context, bus *BusCmdGroup) error {
|
|||||||
|
|
||||||
// BusCompMixCmd defines the command for getting or setting the compressor mix level of a bus.
|
// BusCompMixCmd defines the command for getting or setting the compressor mix level of a bus.
|
||||||
type BusCompMixCmd struct {
|
type BusCompMixCmd struct {
|
||||||
Mix *float64 `arg:"" help:"The compressor mix level to set (in %). If not provided, the current compressor mix level will be returned."`
|
Mix *float64 `arg:"" help:"The compressor mix level to set (in %). If not provided, the current compressor mix level will be returned." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the BusCompMixCmd command, either retrieving the current compressor mix level of the bus or setting it based on the provided argument.
|
// Run executes the BusCompMixCmd command, either retrieving the current compressor mix level of the bus or setting it based on the provided argument.
|
||||||
@@ -458,7 +458,7 @@ func (cmd *BusCompMixCmd) Run(ctx *context, bus *BusCmdGroup) error {
|
|||||||
|
|
||||||
// BusCompMakeupCmd defines the command for getting or setting the compressor makeup gain of a bus.
|
// BusCompMakeupCmd defines the command for getting or setting the compressor makeup gain of a bus.
|
||||||
type BusCompMakeupCmd struct {
|
type BusCompMakeupCmd struct {
|
||||||
Makeup *float64 `arg:"" help:"The compressor makeup gain to set (in dB). If not provided, the current compressor makeup gain will be returned."`
|
Makeup *float64 `arg:"" help:"The compressor makeup gain to set (in dB). If not provided, the current compressor makeup gain will be returned." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the BusCompMakeupCmd command, either retrieving the current compressor makeup gain of the bus or setting it based on the provided argument.
|
// Run executes the BusCompMakeupCmd command, either retrieving the current compressor makeup gain of the bus or setting it based on the provided argument.
|
||||||
@@ -481,7 +481,7 @@ func (cmd *BusCompMakeupCmd) Run(ctx *context, bus *BusCmdGroup) error {
|
|||||||
|
|
||||||
// BusCompAttackCmd defines the command for getting or setting the compressor attack time of a bus.
|
// BusCompAttackCmd defines the command for getting or setting the compressor attack time of a bus.
|
||||||
type BusCompAttackCmd struct {
|
type BusCompAttackCmd struct {
|
||||||
Attack *float64 `arg:"" help:"The compressor attack time to set (in ms). If not provided, the current compressor attack time will be returned."`
|
Attack *float64 `arg:"" help:"The compressor attack time to set (in ms). If not provided, the current compressor attack time will be returned." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the BusCompAttackCmd command, either retrieving the current compressor attack time of the bus or setting it based on the provided argument.
|
// Run executes the BusCompAttackCmd command, either retrieving the current compressor attack time of the bus or setting it based on the provided argument.
|
||||||
@@ -504,7 +504,7 @@ func (cmd *BusCompAttackCmd) Run(ctx *context, bus *BusCmdGroup) error {
|
|||||||
|
|
||||||
// BusCompHoldCmd defines the command for getting or setting the compressor hold time of a bus.
|
// BusCompHoldCmd defines the command for getting or setting the compressor hold time of a bus.
|
||||||
type BusCompHoldCmd struct {
|
type BusCompHoldCmd struct {
|
||||||
Hold *float64 `arg:"" help:"The compressor hold time to set (in ms). If not provided, the current compressor hold time will be returned."`
|
Hold *float64 `arg:"" help:"The compressor hold time to set (in ms). If not provided, the current compressor hold time will be returned." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the BusCompHoldCmd command, either retrieving the current compressor hold time of the bus or setting it based on the provided argument.
|
// Run executes the BusCompHoldCmd command, either retrieving the current compressor hold time of the bus or setting it based on the provided argument.
|
||||||
@@ -527,7 +527,7 @@ func (cmd *BusCompHoldCmd) Run(ctx *context, bus *BusCmdGroup) error {
|
|||||||
|
|
||||||
// BusCompReleaseCmd defines the command for getting or setting the compressor release time of a bus.
|
// BusCompReleaseCmd defines the command for getting or setting the compressor release time of a bus.
|
||||||
type BusCompReleaseCmd struct {
|
type BusCompReleaseCmd struct {
|
||||||
Release *float64 `arg:"" help:"The compressor release time to set (in ms). If not provided, the current compressor release time will be returned."`
|
Release *float64 `arg:"" help:"The compressor release time to set (in ms). If not provided, the current compressor release time will be returned." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the BusCompReleaseCmd command, either retrieving the current compressor release time of the bus or setting it based on the provided argument.
|
// Run executes the BusCompReleaseCmd command, either retrieving the current compressor release time of the bus or setting it based on the provided argument.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type HeadampCmdGroup struct {
|
|||||||
// HeadampGainCmd defines the command for getting or setting the gain of a headamp, allowing users to specify the gain in dB and an optional duration for a gradual fade when setting the gain.
|
// HeadampGainCmd defines the command for getting or setting the gain of a headamp, allowing users to specify the gain in dB and an optional duration for a gradual fade when setting the gain.
|
||||||
type HeadampGainCmd struct {
|
type HeadampGainCmd struct {
|
||||||
Duration time.Duration `help:"The duration of the fade in/out when setting the gain." default:"5s"`
|
Duration time.Duration `help:"The duration of the fade in/out when setting the gain." default:"5s"`
|
||||||
Gain *float64 `help:"The gain of the headamp in dB." arg:""`
|
Gain *float64 `help:"The gain of the headamp in dB." arg:"" optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the HeadampGainCmd command, either retrieving the current gain of the headamp or setting it based on the provided argument, with an optional fade duration for smooth transitions.
|
// Run executes the HeadampGainCmd command, either retrieving the current gain of the headamp or setting it based on the provided argument, with an optional fade duration for smooth transitions.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package xair
|
package xair
|
||||||
|
|
||||||
var xairAddressMap = map[string]string{
|
var xairAddressMap = map[string]string{
|
||||||
|
"main": "/lr",
|
||||||
"strip": "/ch/%02d",
|
"strip": "/ch/%02d",
|
||||||
"bus": "/bus/%01d",
|
"bus": "/bus/%01d",
|
||||||
"headamp": "/headamp/%02d",
|
"headamp": "/headamp/%02d",
|
||||||
@@ -8,9 +9,12 @@ var xairAddressMap = map[string]string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var x32AddressMap = map[string]string{
|
var x32AddressMap = map[string]string{
|
||||||
"strip": "/ch/%02d",
|
"main": "/main/st",
|
||||||
"bus": "/bus/%02d",
|
"mainmono": "/main/mono",
|
||||||
"headamp": "/headamp/%02d",
|
"strip": "/ch/%02d",
|
||||||
|
"bus": "/bus/%02d",
|
||||||
|
"headamp": "/headamp/%02d",
|
||||||
|
"snapshot": "/-snap",
|
||||||
}
|
}
|
||||||
|
|
||||||
func addressMapForMixerKind(kind MixerKind) map[string]string {
|
func addressMapForMixerKind(kind MixerKind) map[string]string {
|
||||||
|
|||||||
@@ -26,8 +26,11 @@ func (b *Bus) Mute(bus int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-b.client.respChan
|
msg, err := b.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for bus mute value")
|
return false, fmt.Errorf("unexpected argument type for bus mute value")
|
||||||
}
|
}
|
||||||
@@ -52,8 +55,11 @@ func (b *Bus) Fader(bus int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-b.client.respChan
|
msg, err := b.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for bus fader value")
|
return 0, fmt.Errorf("unexpected argument type for bus fader value")
|
||||||
}
|
}
|
||||||
@@ -75,8 +81,11 @@ func (b *Bus) Name(bus int) (string, error) {
|
|||||||
return "", fmt.Errorf("failed to send bus name request: %v", err)
|
return "", fmt.Errorf("failed to send bus name request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-b.client.respChan
|
msg, err := b.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(string)
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for bus name value")
|
return "", fmt.Errorf("unexpected argument type for bus name value")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ import (
|
|||||||
"github.com/hypebeast/go-osc/osc"
|
"github.com/hypebeast/go-osc/osc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type parser interface {
|
|
||||||
Parse(data []byte) (*osc.Message, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
engine
|
engine
|
||||||
Main *Main
|
Main *Main
|
||||||
@@ -45,6 +41,7 @@ func NewClient(mixerIP string, mixerPort int, opts ...Option) (*Client, error) {
|
|||||||
|
|
||||||
e := &engine{
|
e := &engine{
|
||||||
Kind: KindXAir,
|
Kind: KindXAir,
|
||||||
|
timeout: 100 * time.Millisecond,
|
||||||
conn: conn,
|
conn: conn,
|
||||||
mixerAddr: mixerAddr,
|
mixerAddr: mixerAddr,
|
||||||
parser: newParser(),
|
parser: newParser(),
|
||||||
@@ -60,10 +57,11 @@ func NewClient(mixerIP string, mixerPort int, opts ...Option) (*Client, error) {
|
|||||||
c := &Client{
|
c := &Client{
|
||||||
engine: *e,
|
engine: *e,
|
||||||
}
|
}
|
||||||
c.Main = newMain(c)
|
c.Main = newMainStereo(c)
|
||||||
c.Strip = NewStrip(c)
|
c.Strip = NewStrip(c)
|
||||||
c.Bus = NewBus(c)
|
c.Bus = NewBus(c)
|
||||||
c.HeadAmp = NewHeadAmp(c)
|
c.HeadAmp = NewHeadAmp(c)
|
||||||
|
c.Snapshot = NewSnapshot(c)
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
@@ -88,32 +86,35 @@ func (c *Client) SendMessage(address string, args ...any) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ReceiveMessage receives an OSC message from the mixer
|
// ReceiveMessage receives an OSC message from the mixer
|
||||||
func (c *Client) ReceiveMessage(timeout time.Duration) (*osc.Message, error) {
|
func (c *Client) ReceiveMessage() (*osc.Message, error) {
|
||||||
t := time.Tick(timeout)
|
t := time.Tick(c.engine.timeout)
|
||||||
select {
|
select {
|
||||||
case <-t:
|
case <-t:
|
||||||
return nil, nil
|
return nil, fmt.Errorf("timeout waiting for response")
|
||||||
case val := <-c.respChan:
|
case msg := <-c.respChan:
|
||||||
if val == nil {
|
if msg == nil {
|
||||||
return nil, fmt.Errorf("no message received")
|
return nil, fmt.Errorf("no message received")
|
||||||
}
|
}
|
||||||
return val, nil
|
return msg, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequestInfo requests mixer information
|
// RequestInfo requests mixer information
|
||||||
func (c *Client) RequestInfo() (InfoResponse, error) {
|
func (c *Client) RequestInfo() (InfoResponse, error) {
|
||||||
|
var info InfoResponse
|
||||||
err := c.SendMessage("/xinfo")
|
err := c.SendMessage("/xinfo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return InfoResponse{}, err
|
return info, err
|
||||||
}
|
}
|
||||||
|
|
||||||
val := <-c.respChan
|
msg, err := c.ReceiveMessage()
|
||||||
var info InfoResponse
|
if err != nil {
|
||||||
if len(val.Arguments) >= 3 {
|
return info, err
|
||||||
info.Host = val.Arguments[0].(string)
|
}
|
||||||
info.Name = val.Arguments[1].(string)
|
if len(msg.Arguments) >= 3 {
|
||||||
info.Model = val.Arguments[2].(string)
|
info.Host = msg.Arguments[0].(string)
|
||||||
|
info.Name = msg.Arguments[1].(string)
|
||||||
|
info.Model = msg.Arguments[2].(string)
|
||||||
}
|
}
|
||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,11 @@ func (c *Comp) On(index int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-c.client.respChan
|
msg, err := c.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for Compressor on value")
|
return false, fmt.Errorf("unexpected argument type for Compressor on value")
|
||||||
}
|
}
|
||||||
@@ -59,8 +62,11 @@ func (c *Comp) Mode(index int) (string, error) {
|
|||||||
|
|
||||||
possibleModes := []string{"comp", "exp"}
|
possibleModes := []string{"comp", "exp"}
|
||||||
|
|
||||||
resp := <-c.client.respChan
|
msg, err := c.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for Compressor mode value")
|
return "", fmt.Errorf("unexpected argument type for Compressor mode value")
|
||||||
}
|
}
|
||||||
@@ -82,8 +88,11 @@ func (c *Comp) Threshold(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-c.client.respChan
|
msg, err := c.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor threshold value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor threshold value")
|
||||||
}
|
}
|
||||||
@@ -106,8 +115,11 @@ func (c *Comp) Ratio(index int) (float32, error) {
|
|||||||
|
|
||||||
possibleValues := []float32{1.1, 1.3, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.0, 10, 20, 100}
|
possibleValues := []float32{1.1, 1.3, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.0, 10, 20, 100}
|
||||||
|
|
||||||
resp := <-c.client.respChan
|
msg, err := c.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor ratio value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor ratio value")
|
||||||
}
|
}
|
||||||
@@ -131,8 +143,11 @@ func (c *Comp) Attack(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-c.client.respChan
|
msg, err := c.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor attack value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor attack value")
|
||||||
}
|
}
|
||||||
@@ -153,8 +168,11 @@ func (c *Comp) Hold(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-c.client.respChan
|
msg, err := c.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor hold value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor hold value")
|
||||||
}
|
}
|
||||||
@@ -175,8 +193,11 @@ func (c *Comp) Release(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-c.client.respChan
|
msg, err := c.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor release value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor release value")
|
||||||
}
|
}
|
||||||
@@ -197,8 +218,11 @@ func (c *Comp) Makeup(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-c.client.respChan
|
msg, err := c.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor makeup gain value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor makeup gain value")
|
||||||
}
|
}
|
||||||
@@ -219,8 +243,11 @@ func (c *Comp) Mix(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-c.client.respChan
|
msg, err := c.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor mix value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor mix value")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,13 @@ import (
|
|||||||
"github.com/hypebeast/go-osc/osc"
|
"github.com/hypebeast/go-osc/osc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type parser interface {
|
||||||
|
Parse(data []byte) (*osc.Message, error)
|
||||||
|
}
|
||||||
|
|
||||||
type engine struct {
|
type engine struct {
|
||||||
Kind MixerKind
|
Kind MixerKind
|
||||||
|
timeout time.Duration
|
||||||
conn *net.UDPConn
|
conn *net.UDPConn
|
||||||
mixerAddr *net.UDPAddr
|
mixerAddr *net.UDPAddr
|
||||||
|
|
||||||
@@ -30,7 +35,7 @@ func (e *engine) receiveLoop() {
|
|||||||
case <-e.done:
|
case <-e.done:
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
// Set read timeout to avoid blocking forever
|
// Set a short read deadline to prevent blocking indefinitely
|
||||||
e.conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
|
e.conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
|
||||||
n, _, err := e.conn.ReadFromUDP(buffer)
|
n, _, err := e.conn.ReadFromUDP(buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -31,8 +31,11 @@ func (e *Eq) On(index int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-e.client.respChan
|
msg, err := e.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for EQ on value")
|
return false, fmt.Errorf("unexpected argument type for EQ on value")
|
||||||
}
|
}
|
||||||
@@ -58,8 +61,11 @@ func (e *Eq) Mode(index int) (string, error) {
|
|||||||
|
|
||||||
possibleModes := []string{"peq", "geq", "teq"}
|
possibleModes := []string{"peq", "geq", "teq"}
|
||||||
|
|
||||||
resp := <-e.client.respChan
|
msg, err := e.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for EQ mode value")
|
return "", fmt.Errorf("unexpected argument type for EQ mode value")
|
||||||
}
|
}
|
||||||
@@ -80,8 +86,11 @@ func (e *Eq) Gain(index int, band int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-e.client.respChan
|
msg, err := e.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for EQ gain value")
|
return 0, fmt.Errorf("unexpected argument type for EQ gain value")
|
||||||
}
|
}
|
||||||
@@ -102,8 +111,11 @@ func (e *Eq) Frequency(index int, band int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-e.client.respChan
|
msg, err := e.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for EQ frequency value")
|
return 0, fmt.Errorf("unexpected argument type for EQ frequency value")
|
||||||
}
|
}
|
||||||
@@ -124,8 +136,11 @@ func (e *Eq) Q(index int, band int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-e.client.respChan
|
msg, err := e.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for EQ Q value")
|
return 0, fmt.Errorf("unexpected argument type for EQ Q value")
|
||||||
}
|
}
|
||||||
@@ -148,8 +163,11 @@ func (e *Eq) Type(index int, band int) (string, error) {
|
|||||||
|
|
||||||
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
|
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
|
||||||
|
|
||||||
resp := <-e.client.respChan
|
msg, err := e.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for EQ type value")
|
return "", fmt.Errorf("unexpected argument type for EQ type value")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,11 @@ func (g *Gate) On(index int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-g.client.respChan
|
msg, err := g.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for Gate on value")
|
return false, fmt.Errorf("unexpected argument type for Gate on value")
|
||||||
}
|
}
|
||||||
@@ -47,8 +50,11 @@ func (g *Gate) Mode(index int) (string, error) {
|
|||||||
|
|
||||||
possibleModes := []string{"exp2", "exp3", "exp4", "gate", "duck"}
|
possibleModes := []string{"exp2", "exp3", "exp4", "gate", "duck"}
|
||||||
|
|
||||||
resp := <-g.client.respChan
|
msg, err := g.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for Gate mode value")
|
return "", fmt.Errorf("unexpected argument type for Gate mode value")
|
||||||
}
|
}
|
||||||
@@ -71,8 +77,11 @@ func (g *Gate) Threshold(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-g.client.respChan
|
msg, err := g.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Gate threshold value")
|
return 0, fmt.Errorf("unexpected argument type for Gate threshold value")
|
||||||
}
|
}
|
||||||
@@ -93,8 +102,11 @@ func (g *Gate) Range(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-g.client.respChan
|
msg, err := g.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Gate range value")
|
return 0, fmt.Errorf("unexpected argument type for Gate range value")
|
||||||
}
|
}
|
||||||
@@ -115,8 +127,11 @@ func (g *Gate) Attack(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-g.client.respChan
|
msg, err := g.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Gate attack value")
|
return 0, fmt.Errorf("unexpected argument type for Gate attack value")
|
||||||
}
|
}
|
||||||
@@ -137,8 +152,11 @@ func (g *Gate) Hold(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-g.client.respChan
|
msg, err := g.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Gate hold value")
|
return 0, fmt.Errorf("unexpected argument type for Gate hold value")
|
||||||
}
|
}
|
||||||
@@ -159,8 +177,11 @@ func (g *Gate) Release(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-g.client.respChan
|
msg, err := g.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Gate release value")
|
return 0, fmt.Errorf("unexpected argument type for Gate release value")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,11 @@ func (h *HeadAmp) Gain(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-h.client.respChan
|
msg, err := h.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for headamp gain value")
|
return 0, fmt.Errorf("unexpected argument type for headamp gain value")
|
||||||
}
|
}
|
||||||
@@ -45,8 +48,11 @@ func (h *HeadAmp) PhantomPower(index int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-h.client.respChan
|
msg, err := h.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for phantom power value")
|
return false, fmt.Errorf("unexpected argument type for phantom power value")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,24 +3,39 @@ package xair
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
type Main struct {
|
type Main struct {
|
||||||
client *Client
|
baseAddress string
|
||||||
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMain(c *Client) *Main {
|
func newMainStereo(c *Client) *Main {
|
||||||
return &Main{
|
return &Main{
|
||||||
client: c,
|
baseAddress: c.addressMap["main"],
|
||||||
|
client: c,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Still considering the best way to implement main mono support.
|
||||||
|
func newMainMono(c *Client) *Main {
|
||||||
|
return &Main{
|
||||||
|
baseAddress: c.addressMap["mainmono"],
|
||||||
|
client: c,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Fader requests the current main L/R fader level
|
// Fader requests the current main L/R fader level
|
||||||
func (m *Main) Fader() (float64, error) {
|
func (m *Main) Fader() (float64, error) {
|
||||||
err := m.client.SendMessage("/lr/mix/fader")
|
address := m.baseAddress + "/mix/fader"
|
||||||
|
err := m.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-m.client.respChan
|
msg, err := m.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for main LR fader value")
|
return 0, fmt.Errorf("unexpected argument type for main LR fader value")
|
||||||
}
|
}
|
||||||
@@ -29,18 +44,23 @@ func (m *Main) Fader() (float64, error) {
|
|||||||
|
|
||||||
// SetFader sets the main L/R fader level
|
// SetFader sets the main L/R fader level
|
||||||
func (m *Main) SetFader(level float64) error {
|
func (m *Main) SetFader(level float64) error {
|
||||||
return m.client.SendMessage("/lr/mix/fader", float32(mustDbInto(level)))
|
address := m.baseAddress + "/mix/fader"
|
||||||
|
return m.client.SendMessage(address, float32(mustDbInto(level)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mute requests the current main L/R mute status
|
// Mute requests the current main L/R mute status
|
||||||
func (m *Main) Mute() (bool, error) {
|
func (m *Main) Mute() (bool, error) {
|
||||||
err := m.client.SendMessage("/lr/mix/on")
|
address := m.baseAddress + "/mix/on"
|
||||||
|
err := m.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-m.client.respChan
|
msg, err := m.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for main LR mute value")
|
return false, fmt.Errorf("unexpected argument type for main LR mute value")
|
||||||
}
|
}
|
||||||
@@ -49,9 +69,10 @@ func (m *Main) Mute() (bool, error) {
|
|||||||
|
|
||||||
// SetMute sets the main L/R mute status
|
// SetMute sets the main L/R mute status
|
||||||
func (m *Main) SetMute(muted bool) error {
|
func (m *Main) SetMute(muted bool) error {
|
||||||
|
address := m.baseAddress + "/mix/on"
|
||||||
var value int32
|
var value int32
|
||||||
if !muted {
|
if !muted {
|
||||||
value = 1
|
value = 1
|
||||||
}
|
}
|
||||||
return m.client.SendMessage("/lr/mix/on", value)
|
return m.client.SendMessage(address, value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package xair
|
package xair
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
type Option func(*engine)
|
type Option func(*engine)
|
||||||
|
|
||||||
func WithKind(kind string) Option {
|
func WithKind(kind string) Option {
|
||||||
@@ -8,3 +10,9 @@ func WithKind(kind string) Option {
|
|||||||
e.addressMap = addressMapForMixerKind(e.Kind)
|
e.addressMap = addressMapForMixerKind(e.Kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithTimeout(timeout time.Duration) Option {
|
||||||
|
return func(e *engine) {
|
||||||
|
e.timeout = timeout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,14 +16,17 @@ func NewSnapshot(c *Client) *Snapshot {
|
|||||||
|
|
||||||
// Name gets the name of the snapshot at the given index.
|
// Name gets the name of the snapshot at the given index.
|
||||||
func (s *Snapshot) Name(index int) (string, error) {
|
func (s *Snapshot) Name(index int) (string, error) {
|
||||||
address := s.baseAddress + fmt.Sprintf("/name/%d", index)
|
address := s.baseAddress + fmt.Sprintf("/%02d/name", index)
|
||||||
err := s.client.SendMessage(address)
|
err := s.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-s.client.respChan
|
msg, err := s.client.ReceiveMessage()
|
||||||
name, ok := resp.Arguments[0].(string)
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
name, ok := msg.Arguments[0].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for snapshot name")
|
return "", fmt.Errorf("unexpected argument type for snapshot name")
|
||||||
}
|
}
|
||||||
@@ -32,24 +35,30 @@ func (s *Snapshot) Name(index int) (string, error) {
|
|||||||
|
|
||||||
// SetName sets the name of the snapshot at the given index.
|
// SetName sets the name of the snapshot at the given index.
|
||||||
func (s *Snapshot) SetName(index int, name string) error {
|
func (s *Snapshot) SetName(index int, name string) error {
|
||||||
address := s.baseAddress + fmt.Sprintf("/name/%d", index)
|
address := s.baseAddress + fmt.Sprintf("/%02d/name", index)
|
||||||
return s.client.SendMessage(address, name)
|
return s.client.SendMessage(address, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load loads the snapshot at the given index.
|
// CurrentName sets the name of the current snapshot.
|
||||||
func (s *Snapshot) Load(index int) error {
|
func (s *Snapshot) CurrentName(name string) error {
|
||||||
address := s.baseAddress + fmt.Sprintf("/load/%d", index)
|
address := s.baseAddress + "/name"
|
||||||
return s.client.SendMessage(address)
|
return s.client.SendMessage(address, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save saves the current state to the snapshot at the given index.
|
// CurrentLoad loads the snapshot at the given index.
|
||||||
func (s *Snapshot) Save(index int) error {
|
func (s *Snapshot) CurrentLoad(index int) error {
|
||||||
address := s.baseAddress + fmt.Sprintf("/save/%d", index)
|
address := s.baseAddress + "/load"
|
||||||
return s.client.SendMessage(address)
|
return s.client.SendMessage(address, int32(index))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete deletes the snapshot at the given index.
|
// CurrentSave saves the current state to the snapshot at the given index.
|
||||||
func (s *Snapshot) Delete(index int) error {
|
func (s *Snapshot) CurrentSave(index int) error {
|
||||||
address := s.baseAddress + fmt.Sprintf("/delete/%d", index)
|
address := s.baseAddress + "/save"
|
||||||
return s.client.SendMessage(address)
|
return s.client.SendMessage(address, int32(index))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CurrentDelete deletes the snapshot at the given index.
|
||||||
|
func (s *Snapshot) CurrentDelete(index int) error {
|
||||||
|
address := s.baseAddress + "/delete"
|
||||||
|
return s.client.SendMessage(address, int32(index))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,11 @@ func (s *Strip) Mute(index int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-s.client.respChan
|
msg, err := s.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for strip mute value")
|
return false, fmt.Errorf("unexpected argument type for strip mute value")
|
||||||
}
|
}
|
||||||
@@ -54,8 +57,11 @@ func (s *Strip) Fader(strip int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-s.client.respChan
|
msg, err := s.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for fader value")
|
return 0, fmt.Errorf("unexpected argument type for fader value")
|
||||||
}
|
}
|
||||||
@@ -77,8 +83,11 @@ func (s *Strip) Name(strip int) (string, error) {
|
|||||||
return "", fmt.Errorf("failed to send strip name request: %v", err)
|
return "", fmt.Errorf("failed to send strip name request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-s.client.respChan
|
msg, err := s.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(string)
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for strip name value")
|
return "", fmt.Errorf("unexpected argument type for strip name value")
|
||||||
}
|
}
|
||||||
@@ -99,8 +108,11 @@ func (s *Strip) Color(strip int) (int32, error) {
|
|||||||
return 0, fmt.Errorf("failed to send strip color request: %v", err)
|
return 0, fmt.Errorf("failed to send strip color request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-s.client.respChan
|
msg, err := s.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(int32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(int32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for strip color value")
|
return 0, fmt.Errorf("unexpected argument type for strip color value")
|
||||||
}
|
}
|
||||||
@@ -121,8 +133,11 @@ func (s *Strip) SendLevel(strip int, bus int) (float64, error) {
|
|||||||
return 0, fmt.Errorf("failed to send strip send level request: %v", err)
|
return 0, fmt.Errorf("failed to send strip send level request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := <-s.client.respChan
|
msg, err := s.client.ReceiveMessage()
|
||||||
val, ok := resp.Arguments[0].(float32)
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
val, ok := msg.Arguments[0].(float32)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for strip send level value")
|
return 0, fmt.Errorf("unexpected argument type for strip send level value")
|
||||||
}
|
}
|
||||||
|
|||||||
4
lr.go
4
lr.go
@@ -16,7 +16,7 @@ type MainCmdGroup struct {
|
|||||||
|
|
||||||
// MainMuteCmd defines the command for getting or setting the mute state of the Main L/R output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
|
// MainMuteCmd defines the command for getting or setting the mute state of the Main L/R output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
|
||||||
type MainMuteCmd struct {
|
type MainMuteCmd struct {
|
||||||
Mute *bool `arg:"" help:"The mute state to set. If not provided, the current state will be printed."`
|
Mute *bool `arg:"" help:"The mute state to set. If not provided, the current state will be printed." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the MainMuteCmd command, either retrieving the current mute state of the Main L/R output or setting it based on the provided argument.
|
// Run executes the MainMuteCmd command, either retrieving the current mute state of the Main L/R output or setting it based on the provided argument.
|
||||||
@@ -39,7 +39,7 @@ func (cmd *MainMuteCmd) Run(ctx *context) error {
|
|||||||
|
|
||||||
// MainFaderCmd defines the command for getting or setting the fader level of the Main L/R output, allowing users to specify the desired level in dB.
|
// MainFaderCmd defines the command for getting or setting the fader level of the Main L/R output, allowing users to specify the desired level in dB.
|
||||||
type MainFaderCmd struct {
|
type MainFaderCmd struct {
|
||||||
Level *float64 `arg:"" help:"The fader level to set. If not provided, the current level will be printed."`
|
Level *float64 `arg:"" help:"The fader level to set. If not provided, the current level will be printed." optional:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the MainFaderCmd command, either retrieving the current fader level of the Main L/R output or setting it based on the provided argument.
|
// Run executes the MainFaderCmd command, either retrieving the current fader level of the Main L/R output or setting it based on the provided argument.
|
||||||
|
|||||||
35
main.go
35
main.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
@@ -32,9 +33,11 @@ type context struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Host string `default:"mixer.local" help:"The host of the X-Air device." env:"XAIR_CLI_HOST" short:"H"`
|
Host string `default:"mixer.local" help:"The host of the X-Air device." env:"XAIR_CLI_HOST" short:"H"`
|
||||||
Port int `default:"10024" help:"The port of the X-Air device." env:"XAIR_CLI_PORT" short:"P"`
|
Port int `default:"10024" help:"The port of the X-Air device." env:"XAIR_CLI_PORT" short:"P"`
|
||||||
Kind string `default:"xr18" help:"The kind of the X-Air device." env:"XAIR_CLI_KIND" short:"K"`
|
Kind string `default:"xair" help:"The kind of the X-Air device." env:"XAIR_CLI_KIND" short:"K" enum:"xair,x32"`
|
||||||
|
Timeout time.Duration `default:"100ms" help:"Timeout for OSC operations." env:"XAIR_CLI_TIMEOUT" short:"T"`
|
||||||
|
Loglevel string `default:"warn" help:"Log level for the CLI." env:"XAIR_CLI_LOGLEVEL" short:"L" enum:"debug,info,warn,error,fatal"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CLI is the main struct for the command-line interface.
|
// CLI is the main struct for the command-line interface.
|
||||||
@@ -42,15 +45,16 @@ type Config struct {
|
|||||||
type CLI struct {
|
type CLI struct {
|
||||||
Config `embed:"" prefix:"" help:"The configuration for the CLI."`
|
Config `embed:"" prefix:"" help:"The configuration for the CLI."`
|
||||||
|
|
||||||
Version VersionFlag `help:"Print gobs-cli version information and quit" name:"version" short:"v"`
|
Version VersionFlag `help:"Print xair-cli version information and quit" name:"version" short:"v"`
|
||||||
|
|
||||||
Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:"" aliases:"c"`
|
Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:"" aliases:"c"`
|
||||||
|
|
||||||
Raw RawCmd `help:"Send raw OSC messages to the mixer." cmd:"" group:"Raw"`
|
Raw RawCmd `help:"Send raw OSC messages to the mixer." cmd:"" group:"Raw"`
|
||||||
Main MainCmdGroup `help:"Control the Main L/R output" cmd:"" group:"Main"`
|
Main MainCmdGroup `help:"Control the Main L/R output" cmd:"" group:"Main"`
|
||||||
Strip StripCmdGroup `help:"Control the strips." cmd:"" group:"Strip"`
|
Strip StripCmdGroup `help:"Control the strips." cmd:"" group:"Strip"`
|
||||||
Bus BusCmdGroup `help:"Control the buses." cmd:"" group:"Bus"`
|
Bus BusCmdGroup `help:"Control the buses." cmd:"" group:"Bus"`
|
||||||
Headamp HeadampCmdGroup `help:"Control input gain and phantom power." cmd:"" group:"Headamp"`
|
Headamp HeadampCmdGroup `help:"Control input gain and phantom power." cmd:"" group:"Headamp"`
|
||||||
|
Snapshot SnapshotCmdGroup `help:"Save and load mixer states." cmd:"" group:"Snapshot"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -84,6 +88,12 @@ func main() {
|
|||||||
// run is the main entry point for the CLI.
|
// run is the main entry point for the CLI.
|
||||||
// It connects to the X-Air device, retrieves mixer info, and then runs the command.
|
// It connects to the X-Air device, retrieves mixer info, and then runs the command.
|
||||||
func run(ctx *kong.Context, config Config) error {
|
func run(ctx *kong.Context, config Config) error {
|
||||||
|
loglevel, err := log.ParseLevel(config.Loglevel)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid log level: %w", err)
|
||||||
|
}
|
||||||
|
log.SetLevel(loglevel)
|
||||||
|
|
||||||
client, err := connect(config)
|
client, err := connect(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to connect to X-Air device: %w", err)
|
return fmt.Errorf("failed to connect to X-Air device: %w", err)
|
||||||
@@ -107,7 +117,12 @@ func run(ctx *kong.Context, config Config) error {
|
|||||||
|
|
||||||
// connect creates a new X-Air client based on the provided configuration.
|
// connect creates a new X-Air client based on the provided configuration.
|
||||||
func connect(config Config) (*xair.Client, error) {
|
func connect(config Config) (*xair.Client, error) {
|
||||||
client, err := xair.NewClient(config.Host, config.Port, xair.WithKind(config.Kind))
|
client, err := xair.NewClient(
|
||||||
|
config.Host,
|
||||||
|
config.Port,
|
||||||
|
xair.WithKind(config.Kind),
|
||||||
|
xair.WithTimeout(config.Timeout),
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
15
raw.go
15
raw.go
@@ -2,14 +2,14 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
"github.com/charmbracelet/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RawCmd represents the command to send raw OSC messages to the mixer.
|
// RawCmd represents the command to send raw OSC messages to the mixer.
|
||||||
type RawCmd struct {
|
type RawCmd struct {
|
||||||
Timeout time.Duration `help:"Timeout for the OSC message send operation." default:"100ms" short:"t" env:"XAIR_CLI_RAW_TIMEOUT"`
|
Address string `help:"The OSC address to send the message to." arg:""`
|
||||||
Address string `help:"The OSC address to send the message to." arg:""`
|
Args []string `help:"The arguments to include in the OSC message." arg:"" optional:""`
|
||||||
Args []string `help:"The arguments to include in the OSC message." arg:"" optional:""`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the RawCmd by sending the specified OSC message to the mixer and optionally waiting for a response.
|
// Run executes the RawCmd by sending the specified OSC message to the mixer and optionally waiting for a response.
|
||||||
@@ -22,7 +22,12 @@ func (cmd *RawCmd) Run(ctx *context) error {
|
|||||||
return fmt.Errorf("failed to send raw OSC message: %w", err)
|
return fmt.Errorf("failed to send raw OSC message: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := ctx.Client.ReceiveMessage(cmd.Timeout)
|
if len(params) > 0 {
|
||||||
|
log.Debugf("Sent OSC message: %s with args: %v\n", cmd.Address, cmd.Args)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := ctx.Client.ReceiveMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to receive response for raw OSC message: %w", err)
|
return fmt.Errorf("failed to receive response for raw OSC message: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
75
snapshot.go
Normal file
75
snapshot.go
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type SnapshotCmdGroup struct {
|
||||||
|
List ListCmd `help:"List all snapshots." cmd:"list"`
|
||||||
|
Index struct {
|
||||||
|
Index int `arg:"" help:"The index of the snapshot."`
|
||||||
|
Name NameCmd `help:"Get or set the name of a snapshot." cmd:"name"`
|
||||||
|
Save SaveCmd `help:"Save the current mixer state." cmd:"save"`
|
||||||
|
Load LoadCmd `help:"Load a mixer state." cmd:"load"`
|
||||||
|
Delete DeleteCmd `help:"Delete a snapshot." cmd:"delete"`
|
||||||
|
} `help:"The index of the snapshot." arg:""`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListCmd struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ListCmd) Run(ctx *context) error {
|
||||||
|
for i := range 64 {
|
||||||
|
name, err := ctx.Client.Snapshot.Name(i + 1)
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if name == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fmt.Fprintf(ctx.Out, "%d: %s\n", i+1, name)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type NameCmd struct {
|
||||||
|
Name *string `arg:"" help:"The name of the snapshot." optional:""`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *NameCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
|
||||||
|
if c.Name == nil {
|
||||||
|
name, err := ctx.Client.Snapshot.Name(snapshot.Index.Index)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Fprintln(ctx.Out, name)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.Client.Snapshot.SetName(snapshot.Index.Index, *c.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
type SaveCmd struct {
|
||||||
|
Name string `arg:"" help:"The name of the snapshot."`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SaveCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
|
||||||
|
err := ctx.Client.Snapshot.CurrentName(c.Name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.Client.Snapshot.CurrentSave(snapshot.Index.Index)
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoadCmd struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *LoadCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
|
||||||
|
return ctx.Client.Snapshot.CurrentLoad(snapshot.Index.Index)
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteCmd struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
|
||||||
|
return ctx.Client.Snapshot.CurrentDelete(snapshot.Index.Index)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user