mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-04-18 06:43:33 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fc36e9bf5c | |||
| a9110f0986 | |||
| 72f43452a8 | |||
| 89ab8ee258 | |||
| c4a86adf14 | |||
| 1623b53cff | |||
| 98e131d4ad | |||
| c44413da6b | |||
| 90839d24a1 | |||
| 7d521e0111 | |||
| 625987759f | |||
| 08b232dcbf | |||
| 0b72556b7e | |||
| 9898c21197 | |||
| 64b4be032f | |||
| d894cc1317 | |||
| 4c4d52c74e |
45
README.md
45
README.md
@@ -1,4 +1,10 @@
|
|||||||
# Xair-CLI
|
# xair-cli
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
```console
|
||||||
|
go install github.com/onyx-and-iris/xair-cli@latest
|
||||||
|
```
|
||||||
|
|
||||||
### Use
|
### Use
|
||||||
|
|
||||||
@@ -14,6 +20,7 @@ Usage:
|
|||||||
Available Commands:
|
Available Commands:
|
||||||
bus Commands to control individual buses
|
bus Commands to control individual buses
|
||||||
completion Generate the autocompletion script for the specified shell
|
completion Generate the autocompletion script for the specified shell
|
||||||
|
headamp Commands to control headamp gain and phantom power
|
||||||
help Help about any command
|
help Help about any command
|
||||||
main Commands to control the main output
|
main Commands to control the main output
|
||||||
strip Commands to control individual strips
|
strip Commands to control individual strips
|
||||||
@@ -24,6 +31,42 @@ Flags:
|
|||||||
-k, --kind string Kind of mixer (xair, x32) (default "xair")
|
-k, --kind string Kind of mixer (xair, x32) (default "xair")
|
||||||
-l, --loglevel string Log level (debug, info, warn, error, fatal, panic) (default "warn")
|
-l, --loglevel string Log level (debug, info, warn, error, fatal, panic) (default "warn")
|
||||||
-p, --port int Port number of the X Air mixer (default 10024)
|
-p, --port int Port number of the X Air mixer (default 10024)
|
||||||
|
-v, --version version for xair-cli
|
||||||
|
|
||||||
Use "xair-cli [command] --help" for more information about a command.
|
Use "xair-cli [command] --help" for more information about a command.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
*Fade out main LR all the way to -∞ over a 5s duration*
|
||||||
|
|
||||||
|
```console
|
||||||
|
xair-cli main fadeout
|
||||||
|
```
|
||||||
|
|
||||||
|
*enable phantom power and set the gain to 28.0dB over a 10s duration for strip 09*
|
||||||
|
```console
|
||||||
|
xair-cli headamp 9 phantom on
|
||||||
|
|
||||||
|
xair-cli headamp 9 gain 28.0 --duration 10s
|
||||||
|
```
|
||||||
|
|
||||||
|
*set strip 09 send level for bus 5 to -18.0dB*
|
||||||
|
```console
|
||||||
|
xair-cli strip send 9 5 -- -18.0
|
||||||
|
```
|
||||||
|
|
||||||
|
*rename bus 01 to 'vocal mix'*
|
||||||
|
```console
|
||||||
|
xair-cli bus 1 name 'vocal mix'
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
I've only implemented the parts I personally need, I don't know how much more I intend to add.
|
||||||
|
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
`xair-cli` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
||||||
|
|||||||
460
cmd/bus.go
460
cmd/bus.go
@@ -1,6 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -21,16 +22,14 @@ var busMuteCmd = &cobra.Command{
|
|||||||
Short: "Get or set the bus mute status",
|
Short: "Get or set the bus mute status",
|
||||||
Long: `Get or set the mute status of a specific bus.`,
|
Long: `Get or set the mute status of a specific bus.`,
|
||||||
Use: "mute [bus number] [true|false]",
|
Use: "mute [bus number] [true|false]",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
cmd.PrintErrln("OSC client not found in context")
|
return fmt.Errorf("OSC client not found in context")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 2 {
|
if len(args) < 2 {
|
||||||
cmd.PrintErrln("Please provide bus number and mute status (true/false)")
|
return fmt.Errorf("Please provide bus number and mute status (true/false)")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
busNum := mustConvToInt(args[0])
|
busNum := mustConvToInt(args[0])
|
||||||
@@ -41,16 +40,16 @@ var busMuteCmd = &cobra.Command{
|
|||||||
case "false", "0":
|
case "false", "0":
|
||||||
muted = false
|
muted = false
|
||||||
default:
|
default:
|
||||||
cmd.PrintErrln("Invalid mute status. Use true/false or 1/0")
|
return fmt.Errorf("Invalid mute status. Use true/false or 1/0")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err := client.Bus.SetMute(busNum, muted)
|
err := client.Bus.SetMute(busNum, muted)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error setting bus mute status:", err)
|
return fmt.Errorf("Error setting bus mute status: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Printf("Bus %d mute set to %v\n", busNum, muted)
|
cmd.Printf("Bus %d mute set to %v\n", busNum, muted)
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,11 +65,10 @@ If a level argument (in dB) is provided, the bus fader is set to that level.`,
|
|||||||
|
|
||||||
# Set the fader level of bus 1 to -10.0 dB
|
# Set the fader level of bus 1 to -10.0 dB
|
||||||
xair-cli bus fader 1 -10.0`,
|
xair-cli bus fader 1 -10.0`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
cmd.PrintErrln("OSC client not found in context")
|
return fmt.Errorf("OSC client not found in context")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
busIndex := mustConvToInt(args[0])
|
busIndex := mustConvToInt(args[0])
|
||||||
@@ -78,26 +76,25 @@ If a level argument (in dB) is provided, the bus fader is set to that level.`,
|
|||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
level, err := client.Bus.Fader(busIndex)
|
level, err := client.Bus.Fader(busIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting bus fader level:", err)
|
return fmt.Errorf("Error getting bus fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
cmd.Printf("Bus %d fader level: %.1f dB\n", busIndex, level)
|
cmd.Printf("Bus %d fader level: %.1f dB\n", busIndex, level)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 2 {
|
if len(args) < 2 {
|
||||||
cmd.PrintErrln("Please provide bus number and fader level (in dB)")
|
return fmt.Errorf("Please provide bus number and fader level (in dB)")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
level := mustConvToFloat64(args[1])
|
level := mustConvToFloat64(args[1])
|
||||||
|
|
||||||
err := client.Bus.SetFader(busIndex, level)
|
err := client.Bus.SetFader(busIndex, level)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error setting bus fader level:", err)
|
return fmt.Errorf("Error setting bus fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Printf("Bus %d fader set to %.2f dB\n", busIndex, level)
|
cmd.Printf("Bus %d fader set to %.2f dB\n", busIndex, level)
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,25 +104,22 @@ var busFadeOutCmd = &cobra.Command{
|
|||||||
Long: "Fade out the bus fader to minimum level over a specified duration in seconds.",
|
Long: "Fade out the bus fader to minimum level over a specified duration in seconds.",
|
||||||
Use: "fadeout [bus number] --duration [seconds] [target level in dB]",
|
Use: "fadeout [bus number] --duration [seconds] [target level in dB]",
|
||||||
Example: ` # Fade out bus 1 over 5 seconds
|
Example: ` # Fade out bus 1 over 5 seconds
|
||||||
xair-cli bus fadeout 1 --duration 5 -- -90.0`,
|
xair-cli bus fadeout 1 --duration 5s -- -90.0`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
cmd.PrintErrln("OSC client not found in context")
|
return fmt.Errorf("OSC client not found in context")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
cmd.PrintErrln("Please provide bus number")
|
return fmt.Errorf("Please provide bus number")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
busIndex := mustConvToInt(args[0])
|
busIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
duration, err := cmd.Flags().GetFloat64("duration")
|
duration, err := cmd.Flags().GetDuration("duration")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting duration flag:", err)
|
return fmt.Errorf("Error getting duration flag: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
target := -90.0
|
target := -90.0
|
||||||
@@ -135,30 +129,29 @@ var busFadeOutCmd = &cobra.Command{
|
|||||||
|
|
||||||
currentFader, err := client.Bus.Fader(busIndex)
|
currentFader, err := client.Bus.Fader(busIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting current bus fader level:", err)
|
return fmt.Errorf("Error getting current bus fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate total steps needed to reach target dB
|
// Calculate total steps needed to reach target dB
|
||||||
totalSteps := float64(currentFader - target)
|
totalSteps := float64(currentFader - target)
|
||||||
if totalSteps <= 0 {
|
if totalSteps <= 0 {
|
||||||
cmd.Println("Bus is already at or below target level")
|
cmd.Println("Bus is already at or below target level")
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
stepDelay := time.Duration(duration*1000/totalSteps) * time.Millisecond
|
stepDelay := time.Duration(duration.Seconds()*1000/totalSteps) * time.Millisecond
|
||||||
|
|
||||||
for currentFader > target {
|
for currentFader > target {
|
||||||
currentFader -= 1.0
|
currentFader -= 1.0
|
||||||
err := client.Bus.SetFader(busIndex, currentFader)
|
err := client.Bus.SetFader(busIndex, currentFader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error setting bus fader level:", err)
|
return fmt.Errorf("Error setting bus fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
time.Sleep(stepDelay)
|
time.Sleep(stepDelay)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Println("Bus fade out completed")
|
cmd.Println("Bus fade out completed")
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,25 +161,22 @@ var busFadeInCmd = &cobra.Command{
|
|||||||
Long: "Fade in the bus fader to maximum level over a specified duration in seconds.",
|
Long: "Fade in the bus fader to maximum level over a specified duration in seconds.",
|
||||||
Use: "fadein [bus number] --duration [seconds] [target level in dB]",
|
Use: "fadein [bus number] --duration [seconds] [target level in dB]",
|
||||||
Example: ` # Fade in bus 1 over 5 seconds
|
Example: ` # Fade in bus 1 over 5 seconds
|
||||||
xair-cli bus fadein 1 --duration 5 -- 0.0`,
|
xair-cli bus fadein 1 --duration 5s -- 0.0`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
cmd.PrintErrln("OSC client not found in context")
|
return fmt.Errorf("OSC client not found in context")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
cmd.PrintErrln("Please provide bus number")
|
return fmt.Errorf("Please provide bus number")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
busIndex := mustConvToInt(args[0])
|
busIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
duration, err := cmd.Flags().GetFloat64("duration")
|
duration, err := cmd.Flags().GetDuration("duration")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting duration flag:", err)
|
return fmt.Errorf("Error getting duration flag: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
target := 0.0
|
target := 0.0
|
||||||
@@ -196,30 +186,385 @@ var busFadeInCmd = &cobra.Command{
|
|||||||
|
|
||||||
currentFader, err := client.Bus.Fader(busIndex)
|
currentFader, err := client.Bus.Fader(busIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting current bus fader level:", err)
|
return fmt.Errorf("Error getting current bus fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate total steps needed to reach target dB
|
// Calculate total steps needed to reach target dB
|
||||||
totalSteps := float64(target - currentFader)
|
totalSteps := float64(target - currentFader)
|
||||||
if totalSteps <= 0 {
|
if totalSteps <= 0 {
|
||||||
cmd.Println("Bus is already at or above target level")
|
cmd.Println("Bus is already at or above target level")
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
stepDelay := time.Duration(duration*1000/totalSteps) * time.Millisecond
|
stepDelay := time.Duration(duration.Seconds()*1000/totalSteps) * time.Millisecond
|
||||||
|
|
||||||
for currentFader < target {
|
for currentFader < target {
|
||||||
currentFader += 1.0
|
currentFader += 1.0
|
||||||
err := client.Bus.SetFader(busIndex, currentFader)
|
err := client.Bus.SetFader(busIndex, currentFader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error setting bus fader level:", err)
|
return fmt.Errorf("Error setting bus fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
time.Sleep(stepDelay)
|
time.Sleep(stepDelay)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Println("Bus fade in completed")
|
cmd.Println("Bus fade in completed")
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// busNameCmd represents the bus name command.
|
||||||
|
var busNameCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the bus name",
|
||||||
|
Long: `Get or set the name of a specific bus.`,
|
||||||
|
Use: "name [bus number] [new name]",
|
||||||
|
Example: ` # Get the name of bus 1
|
||||||
|
xair-cli bus name 1
|
||||||
|
|
||||||
|
# Set the name of bus 1 to "Vocals"
|
||||||
|
xair-cli bus name 1 Vocals`,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("Please provide bus number")
|
||||||
|
}
|
||||||
|
|
||||||
|
busIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
|
if len(args) == 1 {
|
||||||
|
name, err := client.Bus.Name(busIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting bus name: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Bus %d name: %s\n", busIndex, name)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
newName := args[1]
|
||||||
|
err := client.Bus.SetName(busIndex, newName)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting bus name: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Bus %d name set to: %s\n", busIndex, newName)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// busEqCmd represents the bus EQ command.
|
||||||
|
var busEqCmd = &cobra.Command{
|
||||||
|
Short: "Commands to control bus EQ settings",
|
||||||
|
Long: `Commands to control the EQ of individual buses, including turning the EQ on or off.`,
|
||||||
|
Use: "eq",
|
||||||
|
Run: func(cmd *cobra.Command, _ []string) {
|
||||||
|
cmd.Help()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// busEqOnCmd represents the bus EQ on/off command.
|
||||||
|
var busEqOnCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the bus EQ on/off status",
|
||||||
|
Long: `Get or set the EQ on/off status of a specific bus.`,
|
||||||
|
Use: "on [bus number] [true|false]",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide bus number and EQ on status (true/false)")
|
||||||
|
}
|
||||||
|
|
||||||
|
busNum := mustConvToInt(args[0])
|
||||||
|
var eqOn bool
|
||||||
|
switch args[1] {
|
||||||
|
case "true", "1":
|
||||||
|
eqOn = true
|
||||||
|
case "false", "0":
|
||||||
|
eqOn = false
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("Invalid EQ on status. Use true/false or 1/0")
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.Bus.Eq.SetOn(busNum, eqOn)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting bus EQ on status: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Bus %d EQ on set to %v\n", busNum, eqOn)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// busEqModeCmd represents the bus EQ mode command.
|
||||||
|
var busEqModeCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the bus EQ mode",
|
||||||
|
Long: `Get or set the EQ mode of a specific bus.`,
|
||||||
|
Use: "mode [bus number] [mode]",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("Please provide bus number")
|
||||||
|
}
|
||||||
|
|
||||||
|
busIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
|
modeNames := []string{"peq", "geq", "teq"}
|
||||||
|
|
||||||
|
if len(args) == 1 {
|
||||||
|
mode, err := client.Bus.Eq.Mode(busIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting bus EQ mode: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Bus %d EQ mode: %s\n", busIndex, modeNames[mode])
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
mode := indexOf(modeNames, args[1])
|
||||||
|
if mode == -1 {
|
||||||
|
return fmt.Errorf("Invalid EQ mode. Valid modes are: %v", modeNames)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.Bus.Eq.SetMode(busIndex, mode)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting bus EQ mode: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Bus %d EQ mode set to %s\n", busIndex, modeNames[mode])
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// busEqGainCmd represents the bus EQ gain command.
|
||||||
|
var busEqGainCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the bus EQ gain for a specific band",
|
||||||
|
Long: `Get or set the EQ gain (in dB) for a specific band of a bus.
|
||||||
|
|
||||||
|
Gain values range from -15.0 dB to +15.0 dB.`,
|
||||||
|
Use: "gain [bus number] [band number] [gain in dB]",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide bus number and band number")
|
||||||
|
}
|
||||||
|
|
||||||
|
busIndex, bandIndex := func() (int, int) {
|
||||||
|
return mustConvToInt(args[0]), mustConvToInt(args[1])
|
||||||
|
}()
|
||||||
|
|
||||||
|
if len(args) == 2 {
|
||||||
|
gain, err := client.Bus.Eq.Gain(busIndex, bandIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting bus EQ gain: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Bus %d EQ band %d gain: %.1f dB\n", busIndex, bandIndex, gain)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 3 {
|
||||||
|
return fmt.Errorf("Please provide bus number, band number, and gain (in dB)")
|
||||||
|
}
|
||||||
|
|
||||||
|
gain := mustConvToFloat64(args[2])
|
||||||
|
|
||||||
|
err := client.Bus.Eq.SetGain(busIndex, bandIndex, gain)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting bus EQ gain: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Bus %d EQ band %d gain set to %.1f dB\n", busIndex, bandIndex, gain)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// busEqFreqCmd represents the bus EQ frequency command.
|
||||||
|
var busEqFreqCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the bus EQ frequency for a specific band",
|
||||||
|
Long: `Get or set the EQ frequency (in Hz) for a specific band of a bus.`,
|
||||||
|
Use: "freq [bus number] [band number] [frequency in Hz]",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide bus number and band number")
|
||||||
|
}
|
||||||
|
|
||||||
|
busIndex, bandIndex := func() (int, int) {
|
||||||
|
return mustConvToInt(args[0]), mustConvToInt(args[1])
|
||||||
|
}()
|
||||||
|
|
||||||
|
if len(args) == 2 {
|
||||||
|
freq, err := client.Bus.Eq.Frequency(busIndex, bandIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting bus EQ frequency: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Bus %d EQ band %d frequency: %.1f Hz\n", busIndex, bandIndex, freq)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 3 {
|
||||||
|
return fmt.Errorf("Please provide bus number, band number, and frequency (in Hz)")
|
||||||
|
}
|
||||||
|
|
||||||
|
freq := mustConvToFloat64(args[2])
|
||||||
|
|
||||||
|
err := client.Bus.Eq.SetFrequency(busIndex, bandIndex, freq)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting bus EQ frequency: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Bus %d EQ band %d frequency set to %.1f Hz\n", busIndex, bandIndex, freq)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// busEqQCmd represents the bus EQ Q command.
|
||||||
|
var busEqQCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the bus EQ Q factor for a specific band",
|
||||||
|
Long: `Get or set the EQ Q factor for a specific band of a bus.`,
|
||||||
|
Use: "q [bus number] [band number] [Q factor]",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide bus number and band number")
|
||||||
|
}
|
||||||
|
|
||||||
|
busIndex, bandIndex := func() (int, int) {
|
||||||
|
return mustConvToInt(args[0]), mustConvToInt(args[1])
|
||||||
|
}()
|
||||||
|
|
||||||
|
if len(args) == 2 {
|
||||||
|
qFactor, err := client.Bus.Eq.Q(busIndex, bandIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting bus EQ Q factor: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Bus %d EQ band %d Q factor: %.2f\n", busIndex, bandIndex, qFactor)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 3 {
|
||||||
|
return fmt.Errorf("Please provide bus number, band number, and Q factor")
|
||||||
|
}
|
||||||
|
|
||||||
|
qFactor := mustConvToFloat64(args[2])
|
||||||
|
|
||||||
|
err := client.Bus.Eq.SetQ(busIndex, bandIndex, qFactor)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting bus EQ Q factor: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Bus %d EQ band %d Q factor set to %.2f\n", busIndex, bandIndex, qFactor)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// busEqTypeCmd represents the bus EQ type command.
|
||||||
|
var busEqTypeCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the bus EQ band type",
|
||||||
|
Long: `Get or set the EQ band type for a specific band of a bus.`,
|
||||||
|
Use: "type [bus number] [band number] [type]",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide bus number and band number")
|
||||||
|
}
|
||||||
|
|
||||||
|
busIndex, bandIndex := func() (int, int) {
|
||||||
|
return mustConvToInt(args[0]), mustConvToInt(args[1])
|
||||||
|
}()
|
||||||
|
|
||||||
|
eqTypeNames := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
|
||||||
|
|
||||||
|
if len(args) == 2 {
|
||||||
|
currentType, err := client.Bus.Eq.Type(busIndex, bandIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting bus EQ band type: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Bus %d EQ band %d type: %s\n", busIndex, bandIndex, eqTypeNames[currentType])
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
eqType := indexOf(eqTypeNames, args[2])
|
||||||
|
if eqType == -1 {
|
||||||
|
return fmt.Errorf("Invalid EQ band type. Valid types are: %v", eqTypeNames)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.Bus.Eq.SetType(busIndex, bandIndex, eqType)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting bus EQ band type: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Bus %d EQ band %d type set to %s\n", busIndex, bandIndex, eqTypeNames[eqType])
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// busCompCmd represents the bus Compressor command.
|
||||||
|
var busCompCmd = &cobra.Command{
|
||||||
|
Short: "Commands to control bus Compressor settings",
|
||||||
|
Long: `Commands to control the Compressor of individual buses, including turning the Compressor on or off.`,
|
||||||
|
Use: "comp",
|
||||||
|
Run: func(cmd *cobra.Command, _ []string) {
|
||||||
|
cmd.Help()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// busCompOnCmd represents the bus Compressor on/off command.
|
||||||
|
var busCompOnCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the bus Compressor on/off status",
|
||||||
|
Long: `Get or set the Compressor on/off status of a specific bus.`,
|
||||||
|
Use: "on [bus number] [true|false]",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide bus number and Compressor on status (true/false)")
|
||||||
|
}
|
||||||
|
|
||||||
|
busNum := mustConvToInt(args[0])
|
||||||
|
var compOn bool
|
||||||
|
switch args[1] {
|
||||||
|
case "true", "1":
|
||||||
|
compOn = true
|
||||||
|
case "false", "0":
|
||||||
|
compOn = false
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("Invalid Compressor on status. Use true/false or 1/0")
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.Bus.Comp.SetOn(busNum, compOn)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting bus Compressor on status: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Bus %d Compressor on set to %v\n", busNum, compOn)
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,10 +572,21 @@ func init() {
|
|||||||
rootCmd.AddCommand(busCmd)
|
rootCmd.AddCommand(busCmd)
|
||||||
|
|
||||||
busCmd.AddCommand(busMuteCmd)
|
busCmd.AddCommand(busMuteCmd)
|
||||||
|
|
||||||
busCmd.AddCommand(busFaderCmd)
|
busCmd.AddCommand(busFaderCmd)
|
||||||
busCmd.AddCommand(busFadeOutCmd)
|
busCmd.AddCommand(busFadeOutCmd)
|
||||||
busFadeOutCmd.Flags().Float64P("duration", "d", 5.0, "Duration for fade out in seconds")
|
busFadeOutCmd.Flags().DurationP("duration", "d", 5*time.Second, "Duration for fade out in seconds")
|
||||||
busCmd.AddCommand(busFadeInCmd)
|
busCmd.AddCommand(busFadeInCmd)
|
||||||
busFadeInCmd.Flags().Float64P("duration", "d", 5.0, "Duration for fade in in seconds")
|
busFadeInCmd.Flags().DurationP("duration", "d", 5*time.Second, "Duration for fade in in seconds")
|
||||||
|
busCmd.AddCommand(busNameCmd)
|
||||||
|
|
||||||
|
busCmd.AddCommand(busEqCmd)
|
||||||
|
busEqCmd.AddCommand(busEqOnCmd)
|
||||||
|
busEqCmd.AddCommand(busEqModeCmd)
|
||||||
|
busEqCmd.AddCommand(busEqGainCmd)
|
||||||
|
busEqCmd.AddCommand(busEqFreqCmd)
|
||||||
|
busEqCmd.AddCommand(busEqQCmd)
|
||||||
|
busEqCmd.AddCommand(busEqTypeCmd)
|
||||||
|
|
||||||
|
busCmd.AddCommand(busCompCmd)
|
||||||
|
busCompCmd.AddCommand(busCompOnCmd)
|
||||||
}
|
}
|
||||||
|
|||||||
211
cmd/headamp.go
Normal file
211
cmd/headamp.go
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/charmbracelet/log"
|
||||||
|
"github.com/onyx-and-iris/xair-cli/internal/xair"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
// headampCmd represents the headamp command
|
||||||
|
var headampCmd = &cobra.Command{
|
||||||
|
Short: "Commands to control headamp gain and phantom power",
|
||||||
|
Long: `Commands to control the headamp gain and phantom power settings of the XAir mixer.
|
||||||
|
|
||||||
|
You can get or set the gain level for individual headamps, as well as enable or disable phantom power.`,
|
||||||
|
Use: "headamp",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
cmd.Help()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// headampGainCmd represents the headamp gain command
|
||||||
|
var headampGainCmd = &cobra.Command{
|
||||||
|
Use: "gain",
|
||||||
|
Short: "Get or set headamp gain level",
|
||||||
|
Long: `Get or set the gain level for a specified headamp index.
|
||||||
|
When setting gain, it will gradually increase from the current level to prevent
|
||||||
|
sudden jumps that could cause feedback or equipment damage.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
# Get gain level for headamp index 1
|
||||||
|
xair-cli headamp gain 1
|
||||||
|
# Set gain level for headamp index 1 to 3.5 dB (gradually over 5 seconds)
|
||||||
|
xair-cli headamp gain 1 3.5
|
||||||
|
# Set gain level for headamp index 1 to 3.5 dB over 10 seconds
|
||||||
|
xair-cli headamp gain 1 3.5 --duration 10s`,
|
||||||
|
Args: cobra.RangeArgs(1, 2),
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("Please provide a headamp index")
|
||||||
|
}
|
||||||
|
|
||||||
|
index := mustConvToInt(args[0])
|
||||||
|
|
||||||
|
if len(args) == 1 {
|
||||||
|
gain, err := client.HeadAmp.Gain(index)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting headamp gain level: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Headamp %d Gain: %.2f dB\n", index, gain)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide a gain level in dB")
|
||||||
|
}
|
||||||
|
|
||||||
|
targetLevel := mustConvToFloat64(args[1])
|
||||||
|
|
||||||
|
currentGain, err := client.HeadAmp.Gain(index)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting current headamp gain level: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
duration, err := cmd.Flags().GetDuration("duration")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting duration flag: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if currentGain == targetLevel {
|
||||||
|
cmd.Printf("Headamp %d Gain already at %.2f dB\n", index, targetLevel)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := gradualGainAdjust(client, cmd, index, currentGain, targetLevel, duration); err != nil {
|
||||||
|
return fmt.Errorf("Error adjusting headamp gain level: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Headamp %d Gain set to %.2f dB\n", index, targetLevel)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// gradualGainAdjust gradually adjusts gain from current to target over specified duration
|
||||||
|
func gradualGainAdjust(
|
||||||
|
client *xair.Client,
|
||||||
|
cmd *cobra.Command,
|
||||||
|
index int,
|
||||||
|
currentGain, targetGain float64,
|
||||||
|
duration time.Duration,
|
||||||
|
) error {
|
||||||
|
gainDiff := targetGain - currentGain
|
||||||
|
|
||||||
|
stepInterval := 100 * time.Millisecond
|
||||||
|
totalSteps := int(duration / stepInterval)
|
||||||
|
|
||||||
|
if totalSteps < 1 {
|
||||||
|
totalSteps = 1
|
||||||
|
stepInterval = duration
|
||||||
|
}
|
||||||
|
|
||||||
|
stepIncrement := gainDiff / float64(totalSteps)
|
||||||
|
|
||||||
|
log.Debugf("Adjusting Headamp %d gain from %.2f dB to %.2f dB over %v...\n",
|
||||||
|
index, currentGain, targetGain, duration)
|
||||||
|
|
||||||
|
for step := 1; step <= totalSteps; step++ {
|
||||||
|
newGain := currentGain + (stepIncrement * float64(step))
|
||||||
|
|
||||||
|
if step == totalSteps {
|
||||||
|
newGain = targetGain
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.HeadAmp.SetGain(index, newGain)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if step%10 == 0 || step == totalSteps {
|
||||||
|
log.Debugf(" Step %d/%d: %.2f dB\n", step, totalSteps, newGain)
|
||||||
|
}
|
||||||
|
|
||||||
|
if step < totalSteps {
|
||||||
|
time.Sleep(stepInterval)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// headampPhantomPowerCmd represents the headamp phantom power command
|
||||||
|
var headampPhantomPowerCmd = &cobra.Command{
|
||||||
|
Use: "phantom",
|
||||||
|
Short: "Get or set headamp phantom power status",
|
||||||
|
Long: `Get or set the phantom power status for a specified headamp index.
|
||||||
|
Examples:
|
||||||
|
# Get phantom power status for headamp index 1
|
||||||
|
xairctl headamp phantom 1
|
||||||
|
# Enable phantom power for headamp index 1
|
||||||
|
xairctl headamp phantom 1 on
|
||||||
|
# Disable phantom power for headamp index 1
|
||||||
|
xairctl headamp phantom 1 off`,
|
||||||
|
Args: cobra.RangeArgs(1, 2),
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("Please provide a headamp index")
|
||||||
|
}
|
||||||
|
|
||||||
|
index := mustConvToInt(args[0])
|
||||||
|
|
||||||
|
if len(args) == 1 {
|
||||||
|
enabled, err := client.HeadAmp.PhantomPower(index)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting headamp phantom power status: %w", err)
|
||||||
|
}
|
||||||
|
status := "disabled"
|
||||||
|
if enabled {
|
||||||
|
status = "enabled"
|
||||||
|
}
|
||||||
|
cmd.Printf("Headamp %d Phantom Power is %s\n", index, status)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide phantom power status: on or off")
|
||||||
|
}
|
||||||
|
|
||||||
|
var enable bool
|
||||||
|
switch args[1] {
|
||||||
|
case "on", "enable":
|
||||||
|
enable = true
|
||||||
|
case "off", "disable":
|
||||||
|
enable = false
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("Invalid phantom power status. Use 'on' or 'off'")
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.HeadAmp.SetPhantomPower(index, enable)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting headamp phantom power status: %w", err)
|
||||||
|
}
|
||||||
|
status := "disabled"
|
||||||
|
if enable {
|
||||||
|
status = "enabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Headamp %d Phantom Power %s successfully\n", index, status)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(headampCmd)
|
||||||
|
|
||||||
|
headampCmd.AddCommand(headampGainCmd)
|
||||||
|
headampGainCmd.Flags().DurationP("duration", "d", 5*time.Second, "Duration over which to gradually adjust gain")
|
||||||
|
|
||||||
|
headampCmd.AddCommand(headampPhantomPowerCmd)
|
||||||
|
}
|
||||||
52
cmd/main.go
52
cmd/main.go
@@ -1,6 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -33,21 +34,19 @@ If "false" or "0" is provided, the main output is unmuted.`,
|
|||||||
|
|
||||||
# Unmute the main output
|
# Unmute the main output
|
||||||
xair-cli main mute false`,
|
xair-cli main mute false`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
cmd.PrintErrln("OSC client not found in context")
|
return fmt.Errorf("OSC client not found in context")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
resp, err := client.Main.Mute()
|
resp, err := client.Main.Mute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting main LR mute status:", err)
|
return fmt.Errorf("Error getting main LR mute status: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
cmd.Printf("Main LR mute: %v\n", resp)
|
cmd.Printf("Main LR mute: %v\n", resp)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var muted bool
|
var muted bool
|
||||||
@@ -57,16 +56,16 @@ If "false" or "0" is provided, the main output is unmuted.`,
|
|||||||
case "false", "0":
|
case "false", "0":
|
||||||
muted = false
|
muted = false
|
||||||
default:
|
default:
|
||||||
cmd.PrintErrln("Invalid mute status. Use true/false or 1/0")
|
return fmt.Errorf("Invalid mute status. Use true/false or 1/0")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err := client.Main.SetMute(muted)
|
err := client.Main.SetMute(muted)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error setting main LR mute status:", err)
|
return fmt.Errorf("Error setting main LR mute status: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Println("Main LR mute status set successfully")
|
cmd.Println("Main LR mute status set successfully")
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,29 +82,28 @@ If a dB value is provided as an argument, the fader level is set to that value.`
|
|||||||
|
|
||||||
# Set the main LR fader level to -10.0 dB
|
# Set the main LR fader level to -10.0 dB
|
||||||
xair-cli main fader -- -10.0`,
|
xair-cli main fader -- -10.0`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
cmd.PrintErrln("OSC client not found in context")
|
return fmt.Errorf("OSC client not found in context")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
resp, err := client.Main.Fader()
|
resp, err := client.Main.Fader()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting main LR fader:", err)
|
return fmt.Errorf("Error getting main LR fader: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
cmd.Printf("Main LR fader: %.1f dB\n", resp)
|
cmd.Printf("Main LR fader: %.1f dB\n", resp)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err := client.Main.SetFader(mustConvToFloat64(args[0]))
|
err := client.Main.SetFader(mustConvToFloat64(args[0]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error setting main LR fader:", err)
|
return fmt.Errorf("Error setting main LR fader: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Println("Main LR fader set successfully")
|
cmd.Println("Main LR fader set successfully")
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +116,7 @@ This command will fade out the main output to the specified dB level.
|
|||||||
`,
|
`,
|
||||||
Use: "fadeout --duration [seconds] [target_db]",
|
Use: "fadeout --duration [seconds] [target_db]",
|
||||||
Example: ` # Fade out main output over 5 seconds
|
Example: ` # Fade out main output over 5 seconds
|
||||||
xair-cli main fadeout --duration 5 -- -90.0`,
|
xair-cli main fadeout --duration 5s -- -90.0`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
@@ -126,7 +124,7 @@ This command will fade out the main output to the specified dB level.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
duration, err := cmd.Flags().GetFloat64("duration")
|
duration, err := cmd.Flags().GetDuration("duration")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting duration flag:", err)
|
cmd.PrintErrln("Error getting duration flag:", err)
|
||||||
return
|
return
|
||||||
@@ -152,7 +150,7 @@ This command will fade out the main output to the specified dB level.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate delay per step to achieve exact duration
|
// Calculate delay per step to achieve exact duration
|
||||||
stepDelay := time.Duration(duration*1000/totalSteps) * time.Millisecond
|
stepDelay := time.Duration(duration.Seconds()*1000/totalSteps) * time.Millisecond
|
||||||
|
|
||||||
for currentFader > target {
|
for currentFader > target {
|
||||||
currentFader -= 1.0
|
currentFader -= 1.0
|
||||||
@@ -163,6 +161,7 @@ This command will fade out the main output to the specified dB level.
|
|||||||
}
|
}
|
||||||
time.Sleep(stepDelay)
|
time.Sleep(stepDelay)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Println("Main output faded out successfully")
|
cmd.Println("Main output faded out successfully")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -176,7 +175,7 @@ This command will fade in the main output to the specified dB level.
|
|||||||
`,
|
`,
|
||||||
Use: "fadein --duration [seconds] [target_db]",
|
Use: "fadein --duration [seconds] [target_db]",
|
||||||
Example: ` # Fade in main output over 5 seconds
|
Example: ` # Fade in main output over 5 seconds
|
||||||
xair-cli main fadein --duration 5 -- 0.0`,
|
xair-cli main fadein --duration 5s -- 0.0`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
@@ -184,7 +183,7 @@ This command will fade in the main output to the specified dB level.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
duration, err := cmd.Flags().GetFloat64("duration")
|
duration, err := cmd.Flags().GetDuration("duration")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting duration flag:", err)
|
cmd.PrintErrln("Error getting duration flag:", err)
|
||||||
return
|
return
|
||||||
@@ -209,7 +208,7 @@ This command will fade in the main output to the specified dB level.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate delay per step to achieve exact duration
|
// Calculate delay per step to achieve exact duration
|
||||||
stepDelay := time.Duration(duration*1000/totalSteps) * time.Millisecond
|
stepDelay := time.Duration(duration.Seconds()*1000/totalSteps) * time.Millisecond
|
||||||
|
|
||||||
for currentFader < target {
|
for currentFader < target {
|
||||||
currentFader += 1.0
|
currentFader += 1.0
|
||||||
@@ -220,6 +219,7 @@ This command will fade in the main output to the specified dB level.
|
|||||||
}
|
}
|
||||||
time.Sleep(stepDelay)
|
time.Sleep(stepDelay)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Println("Main output faded in successfully")
|
cmd.Println("Main output faded in successfully")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ func init() {
|
|||||||
|
|
||||||
mainCmd.AddCommand(mainFaderCmd)
|
mainCmd.AddCommand(mainFaderCmd)
|
||||||
mainCmd.AddCommand(mainFadeOutCmd)
|
mainCmd.AddCommand(mainFadeOutCmd)
|
||||||
mainFadeOutCmd.Flags().Float64P("duration", "d", 5, "Duration for fade out in seconds")
|
mainFadeOutCmd.Flags().DurationP("duration", "d", 5*time.Second, "Duration for fade out in seconds")
|
||||||
mainCmd.AddCommand(mainFadeInCmd)
|
mainCmd.AddCommand(mainFadeInCmd)
|
||||||
mainFadeInCmd.Flags().Float64P("duration", "d", 5, "Duration for fade in in seconds")
|
mainFadeInCmd.Flags().DurationP("duration", "d", 5*time.Second, "Duration for fade in in seconds")
|
||||||
}
|
}
|
||||||
|
|||||||
16
cmd/root.go
16
cmd/root.go
@@ -2,6 +2,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
@@ -11,6 +12,8 @@ import (
|
|||||||
"github.com/onyx-and-iris/xair-cli/internal/xair"
|
"github.com/onyx-and-iris/xair-cli/internal/xair"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var version string // Version of the CLI, set during build time
|
||||||
|
|
||||||
// rootCmd represents the base command when called without any subcommands.
|
// rootCmd represents the base command when called without any subcommands.
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "xair-cli",
|
Use: "xair-cli",
|
||||||
@@ -18,6 +21,7 @@ var rootCmd = &cobra.Command{
|
|||||||
Long: `xair-cli is a command-line tool that allows users to send OSC messages
|
Long: `xair-cli is a command-line tool that allows users to send OSC messages
|
||||||
to Behringer X Air mixers for remote control and configuration. It supports
|
to Behringer X Air mixers for remote control and configuration. It supports
|
||||||
various commands to manage mixer settings directly from the terminal.`,
|
various commands to manage mixer settings directly from the terminal.`,
|
||||||
|
Version: versionFromBuild(),
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
level, err := log.ParseLevel(viper.GetString("loglevel"))
|
level, err := log.ParseLevel(viper.GetString("loglevel"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -88,3 +92,15 @@ func init() {
|
|||||||
viper.BindPFlag("loglevel", rootCmd.PersistentFlags().Lookup("loglevel"))
|
viper.BindPFlag("loglevel", rootCmd.PersistentFlags().Lookup("loglevel"))
|
||||||
viper.BindPFlag("kind", rootCmd.PersistentFlags().Lookup("kind"))
|
viper.BindPFlag("kind", rootCmd.PersistentFlags().Lookup("kind"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func versionFromBuild() string {
|
||||||
|
if version == "" {
|
||||||
|
info, ok := debug.ReadBuildInfo()
|
||||||
|
if !ok {
|
||||||
|
return "(unable to read version)"
|
||||||
|
}
|
||||||
|
version = strings.Split(info.Main.Version, "-")[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
|||||||
578
cmd/strip.go
578
cmd/strip.go
@@ -1,6 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -32,16 +33,14 @@ If "false" or "0" is provided, the strip is unmuted.`,
|
|||||||
xair-cli strip mute 1 true
|
xair-cli strip mute 1 true
|
||||||
# Unmute strip 1
|
# Unmute strip 1
|
||||||
xair-cli strip mute 1 false`,
|
xair-cli strip mute 1 false`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
cmd.PrintErrln("OSC client not found in context")
|
return fmt.Errorf("OSC client not found in context")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
cmd.PrintErrln("Please provide a strip number")
|
return fmt.Errorf("Please provide a strip number")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stripIndex := mustConvToInt(args[0])
|
stripIndex := mustConvToInt(args[0])
|
||||||
@@ -49,11 +48,10 @@ If "false" or "0" is provided, the strip is unmuted.`,
|
|||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
resp, err := client.Strip.Mute(stripIndex)
|
resp, err := client.Strip.Mute(stripIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting strip mute status:", err)
|
return fmt.Errorf("Error getting strip mute status: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
cmd.Printf("Strip %d mute: %v\n", stripIndex, resp)
|
cmd.Printf("Strip %d mute: %v\n", stripIndex, resp)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var muted bool
|
var muted bool
|
||||||
@@ -63,20 +61,20 @@ If "false" or "0" is provided, the strip is unmuted.`,
|
|||||||
case "false", "0":
|
case "false", "0":
|
||||||
muted = false
|
muted = false
|
||||||
default:
|
default:
|
||||||
cmd.PrintErrln("Invalid mute status. Use true/false or 1/0")
|
return fmt.Errorf("Invalid mute status. Use true/false or 1/0")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err := client.Strip.SetMute(stripIndex, muted)
|
err := client.Strip.SetMute(stripIndex, muted)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error setting strip mute status:", err)
|
return fmt.Errorf("Error setting strip mute status: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if muted {
|
if muted {
|
||||||
cmd.Printf("Strip %d muted successfully\n", stripIndex)
|
cmd.Printf("Strip %d muted successfully\n", stripIndex)
|
||||||
} else {
|
} else {
|
||||||
cmd.Printf("Strip %d unmuted successfully\n", stripIndex)
|
cmd.Printf("Strip %d unmuted successfully\n", stripIndex)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,16 +91,14 @@ If a level argument (in dB) is provided, the strip fader is set to that level.`,
|
|||||||
|
|
||||||
# Set the fader level of strip 1 to -10.0 dB
|
# Set the fader level of strip 1 to -10.0 dB
|
||||||
xair-cli strip fader 1 -10.0`,
|
xair-cli strip fader 1 -10.0`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
cmd.PrintErrln("OSC client not found in context")
|
return fmt.Errorf("OSC client not found in context")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
cmd.PrintErrln("Please provide a strip number")
|
return fmt.Errorf("Please provide a strip number")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stripIndex := mustConvToInt(args[0])
|
stripIndex := mustConvToInt(args[0])
|
||||||
@@ -110,26 +106,25 @@ If a level argument (in dB) is provided, the strip fader is set to that level.`,
|
|||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
level, err := client.Strip.Fader(stripIndex)
|
level, err := client.Strip.Fader(stripIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting strip fader level:", err)
|
return fmt.Errorf("Error getting strip fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
cmd.Printf("Strip %d fader level: %.2f\n", stripIndex, level)
|
cmd.Printf("Strip %d fader level: %.2f\n", stripIndex, level)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 2 {
|
if len(args) < 2 {
|
||||||
cmd.PrintErrln("Please provide a fader level in dB")
|
return fmt.Errorf("Please provide a fader level in dB")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
level := mustConvToFloat64(args[1])
|
level := mustConvToFloat64(args[1])
|
||||||
|
|
||||||
err := client.Strip.SetFader(stripIndex, level)
|
err := client.Strip.SetFader(stripIndex, level)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error setting strip fader level:", err)
|
return fmt.Errorf("Error setting strip fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Printf("Strip %d fader set to %.2f dB\n", stripIndex, level)
|
cmd.Printf("Strip %d fader set to %.2f dB\n", stripIndex, level)
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,25 +134,22 @@ var stripFadeOutCmd = &cobra.Command{
|
|||||||
Long: "Fade out the strip over a specified duration in seconds.",
|
Long: "Fade out the strip over a specified duration in seconds.",
|
||||||
Use: "fadeout [strip number] --duration [seconds] [target level in dB]",
|
Use: "fadeout [strip number] --duration [seconds] [target level in dB]",
|
||||||
Example: ` # Fade out strip 1 over 5 seconds
|
Example: ` # Fade out strip 1 over 5 seconds
|
||||||
xair-cli strip fadeout 1 --duration 5.0 -- -90.0`,
|
xair-cli strip fadeout 1 --duration 5s -- -90.0`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
cmd.PrintErrln("OSC client not found in context")
|
return fmt.Errorf("OSC client not found in context")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
cmd.PrintErrln("Please provide strip number")
|
return fmt.Errorf("Please provide strip number")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stripIndex := mustConvToInt(args[0])
|
stripIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
duration, err := cmd.Flags().GetFloat64("duration")
|
duration, err := cmd.Flags().GetDuration("duration")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting duration flag:", err)
|
return fmt.Errorf("Error getting duration flag: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
target := -90.0
|
target := -90.0
|
||||||
@@ -167,29 +159,28 @@ var stripFadeOutCmd = &cobra.Command{
|
|||||||
|
|
||||||
currentFader, err := client.Strip.Fader(stripIndex)
|
currentFader, err := client.Strip.Fader(stripIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting current strip fader level:", err)
|
return fmt.Errorf("Error getting current strip fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
totalSteps := float64(currentFader - target)
|
totalSteps := float64(currentFader - target)
|
||||||
if totalSteps <= 0 {
|
if totalSteps <= 0 {
|
||||||
cmd.Println("Strip is already at or below target level")
|
cmd.Println("Strip is already at or below target level")
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
stepDelay := time.Duration(duration*1000/totalSteps) * time.Millisecond
|
stepDelay := time.Duration(duration.Seconds()*1000/totalSteps) * time.Millisecond
|
||||||
|
|
||||||
for currentFader > target {
|
for currentFader > target {
|
||||||
currentFader -= 1.0
|
currentFader -= 1.0
|
||||||
err := client.Strip.SetFader(stripIndex, currentFader)
|
err := client.Strip.SetFader(stripIndex, currentFader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error setting strip fader level:", err)
|
return fmt.Errorf("Error setting strip fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
time.Sleep(stepDelay)
|
time.Sleep(stepDelay)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Printf("Strip %d faded out to %.2f dB over %.2f seconds\n", stripIndex, target, duration)
|
cmd.Printf("Strip %d faded out to %.2f dB over %.2f seconds\n", stripIndex, target, duration.Seconds())
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,25 +190,22 @@ var stripFadeInCmd = &cobra.Command{
|
|||||||
Long: "Fade in the strip over a specified duration in seconds.",
|
Long: "Fade in the strip over a specified duration in seconds.",
|
||||||
Use: "fadein [strip number] --duration [seconds] [target level in dB]",
|
Use: "fadein [strip number] --duration [seconds] [target level in dB]",
|
||||||
Example: ` # Fade in strip 1 over 5 seconds
|
Example: ` # Fade in strip 1 over 5 seconds
|
||||||
xair-cli strip fadein 1 --duration 5.0 0`,
|
xair-cli strip fadein 1 --duration 5s 0`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
cmd.PrintErrln("OSC client not found in context")
|
return fmt.Errorf("OSC client not found in context")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
cmd.PrintErrln("Please provide strip number")
|
return fmt.Errorf("Please provide strip number")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stripIndex := mustConvToInt(args[0])
|
stripIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
duration, err := cmd.Flags().GetFloat64("duration")
|
duration, err := cmd.Flags().GetDuration("duration")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting duration flag:", err)
|
return fmt.Errorf("Error getting duration flag: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
target := 0.0
|
target := 0.0
|
||||||
@@ -227,29 +215,28 @@ var stripFadeInCmd = &cobra.Command{
|
|||||||
|
|
||||||
currentFader, err := client.Strip.Fader(stripIndex)
|
currentFader, err := client.Strip.Fader(stripIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting current strip fader level:", err)
|
return fmt.Errorf("Error getting current strip fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
totalSteps := float64(target - currentFader)
|
totalSteps := float64(target - currentFader)
|
||||||
if totalSteps <= 0 {
|
if totalSteps <= 0 {
|
||||||
cmd.Println("Strip is already at or above target level")
|
cmd.Println("Strip is already at or above target level")
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
stepDelay := time.Duration(duration*1000/totalSteps) * time.Millisecond
|
stepDelay := time.Duration(duration.Seconds()*1000/totalSteps) * time.Millisecond
|
||||||
|
|
||||||
for currentFader < target {
|
for currentFader < target {
|
||||||
currentFader += 1.0
|
currentFader += 1.0
|
||||||
err := client.Strip.SetFader(stripIndex, currentFader)
|
err := client.Strip.SetFader(stripIndex, currentFader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error setting strip fader level:", err)
|
return fmt.Errorf("Error setting strip fader level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
time.Sleep(stepDelay)
|
time.Sleep(stepDelay)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Printf("Strip %d faded in to %.2f dB over %.2f seconds\n", stripIndex, target, duration)
|
cmd.Printf("Strip %d faded in to %.2f dB over %.2f seconds\n", stripIndex, target, duration.Seconds())
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,16 +250,14 @@ var stripSendCmd = &cobra.Command{
|
|||||||
|
|
||||||
# Set the send level of strip 1 to bus 1 to -5.0 dB
|
# Set the send level of strip 1 to bus 1 to -5.0 dB
|
||||||
xair-cli strip send 1 1 -- -5.0`,
|
xair-cli strip send 1 1 -- -5.0`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
if client == nil {
|
if client == nil {
|
||||||
cmd.PrintErrln("OSC client not found in context")
|
return fmt.Errorf("OSC client not found in context")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 2 {
|
if len(args) < 2 {
|
||||||
cmd.PrintErrln("Please provide strip number and bus number")
|
return fmt.Errorf("Please provide strip number and bus number")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stripIndex, busIndex := func() (int, int) {
|
stripIndex, busIndex := func() (int, int) {
|
||||||
@@ -282,26 +267,463 @@ var stripSendCmd = &cobra.Command{
|
|||||||
if len(args) == 2 {
|
if len(args) == 2 {
|
||||||
currentLevel, err := client.Strip.SendLevel(stripIndex, busIndex)
|
currentLevel, err := client.Strip.SendLevel(stripIndex, busIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error getting strip send level:", err)
|
return fmt.Errorf("Error getting strip send level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
cmd.Printf("Strip %d send level to bus %d: %.2f dB\n", stripIndex, busIndex, currentLevel)
|
cmd.Printf("Strip %d send level to bus %d: %.2f dB\n", stripIndex, busIndex, currentLevel)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 3 {
|
if len(args) < 3 {
|
||||||
cmd.PrintErrln("Please provide a send level in dB")
|
return fmt.Errorf("Please provide a send level in dB")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
level := mustConvToFloat64(args[2])
|
level := mustConvToFloat64(args[2])
|
||||||
|
|
||||||
err := client.Strip.SetSendLevel(stripIndex, busIndex, level)
|
err := client.Strip.SetSendLevel(stripIndex, busIndex, level)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.PrintErrln("Error setting strip send level:", err)
|
return fmt.Errorf("Error setting strip send level: %w", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
cmd.Printf("Strip %d send level to bus %d set to %.2f dB\n", stripIndex, busIndex, level)
|
cmd.Printf("Strip %d send level to bus %d set to %.2f dB\n", stripIndex, busIndex, level)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripNameCmd represents the strip name command.
|
||||||
|
var stripNameCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the name of a strip",
|
||||||
|
Long: `Get or set the name of a specific strip.
|
||||||
|
|
||||||
|
If no name argument is provided, the current strip name is retrieved.
|
||||||
|
If a name argument is provided, the strip name is set to that value.`,
|
||||||
|
Use: "name [strip number] [name]",
|
||||||
|
Example: ` # Get the current name of strip 1
|
||||||
|
xair-cli strip name 1
|
||||||
|
|
||||||
|
# Set the name of strip 1 to "Guitar"
|
||||||
|
xair-cli strip name 1 "Guitar"`,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("Please provide a strip number")
|
||||||
|
}
|
||||||
|
|
||||||
|
stripIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
|
if len(args) == 1 {
|
||||||
|
name, err := client.Strip.Name(stripIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting strip name: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d name: %s\n", stripIndex, name)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
name := args[1]
|
||||||
|
|
||||||
|
err := client.Strip.SetName(stripIndex, name)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting strip name: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d name set to: %s\n", stripIndex, name)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripGateCmd represents the strip Gate command.
|
||||||
|
var stripGateCmd = &cobra.Command{
|
||||||
|
Short: "Commands to control the Gate of individual strips.",
|
||||||
|
Long: `Commands to control the Gate of individual strips, including turning the Gate on or off.`,
|
||||||
|
Use: "gate",
|
||||||
|
Run: func(cmd *cobra.Command, _ []string) {
|
||||||
|
cmd.Help()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripGateOnCmd represents the strip Gate on command.
|
||||||
|
var stripGateOnCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the Gate on/off status of a strip",
|
||||||
|
Long: `Get or set the Gate on/off status of a specific strip.
|
||||||
|
|
||||||
|
If no status argument is provided, the current Gate status is retrieved.
|
||||||
|
If "true" or "1" is provided as an argument, the Gate is turned on.
|
||||||
|
If "false" or "0" is provided, the Gate is turned off.`,
|
||||||
|
Use: "on [strip number] [true|false]",
|
||||||
|
Example: ` # Get the current Gate status of strip 1
|
||||||
|
xair-cli strip gate on 1
|
||||||
|
|
||||||
|
# Turn on Gate for strip 1
|
||||||
|
xair-cli strip gate on 1 true
|
||||||
|
# Turn off Gate for strip 1
|
||||||
|
xair-cli strip gate on 1 false`,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("Please provide a strip number")
|
||||||
|
}
|
||||||
|
|
||||||
|
stripIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
|
if len(args) == 1 {
|
||||||
|
on, err := client.Strip.Gate.On(stripIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting strip Gate on status: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d Gate on: %v\n", stripIndex, on)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var on bool
|
||||||
|
switch args[1] {
|
||||||
|
case "true", "1":
|
||||||
|
on = true
|
||||||
|
case "false", "0":
|
||||||
|
on = false
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("Invalid Gate status. Use true/false or 1/0")
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.Strip.Gate.SetOn(stripIndex, on)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting strip Gate on status: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if on {
|
||||||
|
cmd.Printf("Strip %d Gate turned on successfully\n", stripIndex)
|
||||||
|
} else {
|
||||||
|
cmd.Printf("Strip %d Gate turned off successfully\n", stripIndex)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripEqCmd represents the strip EQ command.
|
||||||
|
var stripEqCmd = &cobra.Command{
|
||||||
|
Short: "Commands to control the EQ of individual strips.",
|
||||||
|
Long: `Commands to control the EQ of individual strips, including turning the EQ on or off.`,
|
||||||
|
Use: "eq",
|
||||||
|
Run: func(cmd *cobra.Command, _ []string) {
|
||||||
|
cmd.Help()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripEqOnCmd represents the strip EQ on command.
|
||||||
|
var stripEqOnCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the EQ on/off status of a strip",
|
||||||
|
Long: `Get or set the EQ on/off status of a specific strip.
|
||||||
|
|
||||||
|
If no status argument is provided, the current EQ status is retrieved.
|
||||||
|
If "true" or "1" is provided as an argument, the EQ is turned on.
|
||||||
|
If "false" or "0" is provided, the EQ is turned off.`,
|
||||||
|
Use: "on [strip number] [true|false]",
|
||||||
|
Example: ` # Get the current EQ status of strip 1
|
||||||
|
xair-cli strip eq on 1
|
||||||
|
|
||||||
|
# Turn on EQ for strip 1
|
||||||
|
xair-cli strip eq on 1 true
|
||||||
|
# Turn off EQ for strip 1
|
||||||
|
xair-cli strip eq on 1 false`,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("Please provide a strip number")
|
||||||
|
}
|
||||||
|
|
||||||
|
stripIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
|
if len(args) == 1 {
|
||||||
|
on, err := client.Strip.Eq.On(stripIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting strip EQ on status: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d EQ on: %v\n", stripIndex, on)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var on bool
|
||||||
|
switch args[1] {
|
||||||
|
case "true", "1":
|
||||||
|
on = true
|
||||||
|
case "false", "0":
|
||||||
|
on = false
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("Invalid EQ status. Use true/false or 1/0")
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.Strip.Eq.SetOn(stripIndex, on)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting strip EQ on status: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if on {
|
||||||
|
cmd.Printf("Strip %d EQ turned on successfully\n", stripIndex)
|
||||||
|
} else {
|
||||||
|
cmd.Printf("Strip %d EQ turned off successfully\n", stripIndex)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripEqGainCmd represents the strip EQ Gain command.
|
||||||
|
var stripEqGainCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the EQ band gain for a strip",
|
||||||
|
Long: "Get or set the EQ band gain for a specific strip and band.",
|
||||||
|
Use: "gain [strip number] [band number] [gain in dB]",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide strip number and band number")
|
||||||
|
}
|
||||||
|
|
||||||
|
stripIndex, bandIndex := func() (int, int) {
|
||||||
|
return mustConvToInt(args[0]), mustConvToInt(args[1])
|
||||||
|
}()
|
||||||
|
|
||||||
|
if len(args) == 2 {
|
||||||
|
currentGain, err := client.Strip.Eq.Gain(stripIndex, bandIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting strip EQ band gain: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d EQ band %d gain: %.2f dB\n", stripIndex, bandIndex, currentGain)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 3 {
|
||||||
|
return fmt.Errorf("Please provide a gain in dB")
|
||||||
|
}
|
||||||
|
|
||||||
|
gain := mustConvToFloat64(args[2])
|
||||||
|
|
||||||
|
err := client.Strip.Eq.SetGain(stripIndex, bandIndex, gain)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting strip EQ band gain: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Strip %d EQ band %d gain set to %.2f dB\n", stripIndex, bandIndex, gain)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripEqFreqCmd represents the strip EQ Frequency command.
|
||||||
|
var stripEqFreqCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the EQ band frequency for a strip",
|
||||||
|
Long: "Get or set the EQ band frequency for a specific strip and band.",
|
||||||
|
Use: "freq [strip number] [band number] [frequency in Hz]",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide strip number and band number")
|
||||||
|
}
|
||||||
|
|
||||||
|
stripIndex, bandIndex := func() (int, int) {
|
||||||
|
return mustConvToInt(args[0]), mustConvToInt(args[1])
|
||||||
|
}()
|
||||||
|
|
||||||
|
if len(args) == 2 {
|
||||||
|
currentFreq, err := client.Strip.Eq.Frequency(stripIndex, bandIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting strip EQ band frequency: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d EQ band %d frequency: %.2f Hz\n", stripIndex, bandIndex, currentFreq)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 3 {
|
||||||
|
return fmt.Errorf("Please provide a frequency in Hz")
|
||||||
|
}
|
||||||
|
|
||||||
|
freq := mustConvToFloat64(args[2])
|
||||||
|
|
||||||
|
err := client.Strip.Eq.SetFrequency(stripIndex, bandIndex, freq)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting strip EQ band frequency: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Strip %d EQ band %d frequency set to %.2f Hz\n", stripIndex, bandIndex, freq)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripEqQCmd represents the strip EQ Q command.
|
||||||
|
var stripEqQCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the EQ band Q factor for a strip",
|
||||||
|
Long: "Get or set the EQ band Q factor for a specific strip and band.",
|
||||||
|
Use: "q [strip number] [band number] [Q factor]",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide strip number and band number")
|
||||||
|
}
|
||||||
|
|
||||||
|
stripIndex, bandIndex := func() (int, int) {
|
||||||
|
return mustConvToInt(args[0]), mustConvToInt(args[1])
|
||||||
|
}()
|
||||||
|
|
||||||
|
if len(args) == 2 {
|
||||||
|
currentQ, err := client.Strip.Eq.Q(stripIndex, bandIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting strip EQ band Q factor: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d EQ band %d Q factor: %.2f\n", stripIndex, bandIndex, currentQ)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 3 {
|
||||||
|
return fmt.Errorf("Please provide a Q factor")
|
||||||
|
}
|
||||||
|
|
||||||
|
q := mustConvToFloat64(args[2])
|
||||||
|
|
||||||
|
err := client.Strip.Eq.SetQ(stripIndex, bandIndex, q)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting strip EQ band Q factor: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Strip %d EQ band %d Q factor set to %.2f\n", stripIndex, bandIndex, q)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripEqTypeCmd represents the strip EQ Type command.
|
||||||
|
var stripEqTypeCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the EQ band type for a strip",
|
||||||
|
Long: "Get or set the EQ band type for a specific strip and band.",
|
||||||
|
Use: "type [strip number] [band number] [type]",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
return fmt.Errorf("Please provide strip number and band number")
|
||||||
|
}
|
||||||
|
|
||||||
|
stripIndex, bandIndex := func() (int, int) {
|
||||||
|
return mustConvToInt(args[0]), mustConvToInt(args[1])
|
||||||
|
}()
|
||||||
|
|
||||||
|
eqTypeNames := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
|
||||||
|
|
||||||
|
if len(args) == 2 {
|
||||||
|
currentType, err := client.Strip.Eq.Type(stripIndex, bandIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting strip EQ band type: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d EQ band %d type: %s\n", stripIndex, bandIndex, eqTypeNames[currentType])
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 3 {
|
||||||
|
return fmt.Errorf("Please provide a type")
|
||||||
|
}
|
||||||
|
|
||||||
|
eqType := indexOf(eqTypeNames, args[2])
|
||||||
|
if eqType == -1 {
|
||||||
|
return fmt.Errorf("Invalid EQ band type. Valid types are: %v", eqTypeNames)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.Strip.Eq.SetType(stripIndex, bandIndex, eqType)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting strip EQ band type: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Printf("Strip %d EQ band %d type set to %s\n", stripIndex, bandIndex, eqTypeNames[eqType])
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripCompCmd represents the strip Compressor command.
|
||||||
|
var stripCompCmd = &cobra.Command{
|
||||||
|
Short: "Commands to control the Compressor of individual strips.",
|
||||||
|
Long: `Commands to control the Compressor of individual strips, including turning the Compressor on or off.`,
|
||||||
|
Use: "comp",
|
||||||
|
Run: func(cmd *cobra.Command, _ []string) {
|
||||||
|
cmd.Help()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripCompOnCmd represents the strip Compressor on command.
|
||||||
|
var stripCompOnCmd = &cobra.Command{
|
||||||
|
Short: "Get or set the Compressor on/off status of a strip",
|
||||||
|
Long: `Get or set the Compressor on/off status of a specific strip.
|
||||||
|
|
||||||
|
If no status argument is provided, the current Compressor status is retrieved.
|
||||||
|
If "true" or "1" is provided as an argument, the Compressor is turned on.
|
||||||
|
If "false" or "0" is provided, the Compressor is turned off.`,
|
||||||
|
Use: "on [strip number] [true|false]",
|
||||||
|
Example: ` # Get the current Compressor status of strip 1
|
||||||
|
xair-cli strip comp on 1
|
||||||
|
|
||||||
|
# Turn on Compressor for strip 1
|
||||||
|
xair-cli strip comp on 1 true
|
||||||
|
# Turn off Compressor for strip 1
|
||||||
|
xair-cli strip comp on 1 false`,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
return fmt.Errorf("OSC client not found in context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 1 {
|
||||||
|
return fmt.Errorf("Please provide a strip number")
|
||||||
|
}
|
||||||
|
|
||||||
|
stripIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
|
if len(args) == 1 {
|
||||||
|
on, err := client.Strip.Comp.On(stripIndex)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting strip Compressor on status: %w", err)
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d Compressor on: %v\n", stripIndex, on)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var on bool
|
||||||
|
switch args[1] {
|
||||||
|
case "true", "1":
|
||||||
|
on = true
|
||||||
|
case "false", "0":
|
||||||
|
on = false
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("Invalid Compressor status. Use true/false or 1/0")
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.Strip.Comp.SetOn(stripIndex, on)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error setting strip Compressor on status: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if on {
|
||||||
|
cmd.Printf("Strip %d Compressor turned on successfully\n", stripIndex)
|
||||||
|
} else {
|
||||||
|
cmd.Printf("Strip %d Compressor turned off successfully\n", stripIndex)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,12 +731,24 @@ func init() {
|
|||||||
rootCmd.AddCommand(stripCmd)
|
rootCmd.AddCommand(stripCmd)
|
||||||
|
|
||||||
stripCmd.AddCommand(stripMuteCmd)
|
stripCmd.AddCommand(stripMuteCmd)
|
||||||
|
|
||||||
stripCmd.AddCommand(stripFaderCmd)
|
stripCmd.AddCommand(stripFaderCmd)
|
||||||
stripCmd.AddCommand(stripFadeOutCmd)
|
stripCmd.AddCommand(stripFadeOutCmd)
|
||||||
stripFadeOutCmd.Flags().Float64P("duration", "d", 5.0, "Duration of the fade out in seconds")
|
stripFadeOutCmd.Flags().DurationP("duration", "d", 5*time.Second, "Duration of the fade out in seconds")
|
||||||
stripCmd.AddCommand(stripFadeInCmd)
|
stripCmd.AddCommand(stripFadeInCmd)
|
||||||
stripFadeInCmd.Flags().Float64P("duration", "d", 5.0, "Duration of the fade in in seconds")
|
stripFadeInCmd.Flags().DurationP("duration", "d", 5*time.Second, "Duration of the fade in in seconds")
|
||||||
|
|
||||||
stripCmd.AddCommand(stripSendCmd)
|
stripCmd.AddCommand(stripSendCmd)
|
||||||
|
stripCmd.AddCommand(stripNameCmd)
|
||||||
|
|
||||||
|
stripCmd.AddCommand(stripGateCmd)
|
||||||
|
stripGateCmd.AddCommand(stripGateOnCmd)
|
||||||
|
|
||||||
|
stripCmd.AddCommand(stripEqCmd)
|
||||||
|
stripEqCmd.AddCommand(stripEqOnCmd)
|
||||||
|
stripEqCmd.AddCommand(stripEqGainCmd)
|
||||||
|
stripEqCmd.AddCommand(stripEqFreqCmd)
|
||||||
|
stripEqCmd.AddCommand(stripEqQCmd)
|
||||||
|
stripEqCmd.AddCommand(stripEqTypeCmd)
|
||||||
|
|
||||||
|
stripCmd.AddCommand(stripCompCmd)
|
||||||
|
stripCompCmd.AddCommand(stripCompOnCmd)
|
||||||
}
|
}
|
||||||
|
|||||||
10
cmd/util.go
10
cmd/util.go
@@ -21,3 +21,13 @@ func mustConvToInt(intStr string) int {
|
|||||||
}
|
}
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// generic indexOf returns the index of elem in slice, or -1 if not found.
|
||||||
|
func indexOf[T comparable](slice []T, elem T) int {
|
||||||
|
for i, v := range slice {
|
||||||
|
if v == elem {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package xair
|
package xair
|
||||||
|
|
||||||
var xairAddressMap = map[string]string{
|
var xairAddressMap = map[string]string{
|
||||||
"bus": "/bus/%01d",
|
"strip": "/ch/%02d",
|
||||||
|
"bus": "/bus/%01d",
|
||||||
|
"headamp": "/headamp/%02d",
|
||||||
}
|
}
|
||||||
|
|
||||||
var x32AddressMap = map[string]string{
|
var x32AddressMap = map[string]string{
|
||||||
"bus": "/bus/%02d",
|
"strip": "/ch/%02d",
|
||||||
|
"bus": "/bus/%02d",
|
||||||
|
"headamp": "/headamp/%02d",
|
||||||
}
|
}
|
||||||
|
|
||||||
func addressMapForMixerKind(kind MixerKind) map[string]string {
|
func addressMapForMixerKind(kind MixerKind) map[string]string {
|
||||||
|
|||||||
@@ -3,19 +3,24 @@ package xair
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
type Bus struct {
|
type Bus struct {
|
||||||
client Client
|
baseAddress string
|
||||||
|
client *Client
|
||||||
|
Eq *Eq
|
||||||
|
Comp *Comp
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBus(c Client) *Bus {
|
func NewBus(c *Client) *Bus {
|
||||||
return &Bus{
|
return &Bus{
|
||||||
client: c,
|
baseAddress: c.addressMap["bus"],
|
||||||
|
client: c,
|
||||||
|
Eq: newEqForBus(c),
|
||||||
|
Comp: newCompForBus(c),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mute requests the current mute status for a bus
|
// Mute requests the current mute status for a bus
|
||||||
func (b *Bus) Mute(bus int) (bool, error) {
|
func (b *Bus) Mute(bus int) (bool, error) {
|
||||||
formatter := b.client.addressMap["bus"]
|
address := fmt.Sprintf(b.baseAddress, bus) + "/mix/on"
|
||||||
address := fmt.Sprintf(formatter, bus) + "/mix/on"
|
|
||||||
err := b.client.SendMessage(address)
|
err := b.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -31,8 +36,7 @@ func (b *Bus) Mute(bus int) (bool, error) {
|
|||||||
|
|
||||||
// SetMute sets the mute status for a specific bus (1-based indexing)
|
// SetMute sets the mute status for a specific bus (1-based indexing)
|
||||||
func (b *Bus) SetMute(bus int, muted bool) error {
|
func (b *Bus) SetMute(bus int, muted bool) error {
|
||||||
formatter := b.client.addressMap["bus"]
|
address := fmt.Sprintf(b.baseAddress, bus) + "/mix/on"
|
||||||
address := fmt.Sprintf(formatter, bus) + "/mix/on"
|
|
||||||
var value int32
|
var value int32
|
||||||
if !muted {
|
if !muted {
|
||||||
value = 1
|
value = 1
|
||||||
@@ -42,8 +46,7 @@ func (b *Bus) SetMute(bus int, muted bool) error {
|
|||||||
|
|
||||||
// Fader requests the current fader level for a bus
|
// Fader requests the current fader level for a bus
|
||||||
func (b *Bus) Fader(bus int) (float64, error) {
|
func (b *Bus) Fader(bus int) (float64, error) {
|
||||||
formatter := b.client.addressMap["bus"]
|
address := fmt.Sprintf(b.baseAddress, bus) + "/mix/fader"
|
||||||
address := fmt.Sprintf(formatter, bus) + "/mix/fader"
|
|
||||||
err := b.client.SendMessage(address)
|
err := b.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -60,7 +63,28 @@ func (b *Bus) Fader(bus int) (float64, error) {
|
|||||||
|
|
||||||
// SetFader sets the fader level for a specific bus (1-based indexing)
|
// SetFader sets the fader level for a specific bus (1-based indexing)
|
||||||
func (b *Bus) SetFader(bus int, level float64) error {
|
func (b *Bus) SetFader(bus int, level float64) error {
|
||||||
formatter := b.client.addressMap["bus"]
|
address := fmt.Sprintf(b.baseAddress, bus) + "/mix/fader"
|
||||||
address := fmt.Sprintf(formatter, bus) + "/mix/fader"
|
|
||||||
return b.client.SendMessage(address, float32(mustDbInto(level)))
|
return b.client.SendMessage(address, float32(mustDbInto(level)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name requests the name for a specific bus
|
||||||
|
func (b *Bus) Name(bus int) (string, error) {
|
||||||
|
address := fmt.Sprintf(b.baseAddress, bus) + "/config/name"
|
||||||
|
err := b.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to send bus name request: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-b.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(string)
|
||||||
|
if !ok {
|
||||||
|
return "", fmt.Errorf("unexpected argument type for bus name value")
|
||||||
|
}
|
||||||
|
return val, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the name for a specific bus
|
||||||
|
func (b *Bus) SetName(bus int, name string) error {
|
||||||
|
address := fmt.Sprintf(b.baseAddress, bus) + "/config/name"
|
||||||
|
return b.client.SendMessage(address, name)
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ type parser interface {
|
|||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
engine
|
engine
|
||||||
Main *Main
|
Main *Main
|
||||||
Strip *Strip
|
Strip *Strip
|
||||||
Bus *Bus
|
Bus *Bus
|
||||||
|
HeadAmp *HeadAmp
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient creates a new XAirClient instance
|
// NewClient creates a new XAirClient instance
|
||||||
@@ -57,9 +58,10 @@ func NewClient(mixerIP string, mixerPort int, opts ...Option) (*Client, error) {
|
|||||||
c := &Client{
|
c := &Client{
|
||||||
engine: *e,
|
engine: *e,
|
||||||
}
|
}
|
||||||
c.Main = newMain(*c)
|
c.Main = newMain(c)
|
||||||
c.Strip = NewStrip(*c)
|
c.Strip = NewStrip(c)
|
||||||
c.Bus = NewBus(*c)
|
c.Bus = NewBus(c)
|
||||||
|
c.HeadAmp = NewHeadAmp(c)
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|||||||
50
internal/xair/comp.go
Normal file
50
internal/xair/comp.go
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package xair
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type Comp struct {
|
||||||
|
client *Client
|
||||||
|
baseAddress string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Factory function to create Comp instance for Strip
|
||||||
|
func newCompForStrip(c *Client) *Comp {
|
||||||
|
return &Comp{
|
||||||
|
client: c,
|
||||||
|
baseAddress: c.addressMap["strip"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Factory function to create Comp instance for Bus
|
||||||
|
func newCompForBus(c *Client) *Comp {
|
||||||
|
return &Comp{
|
||||||
|
client: c,
|
||||||
|
baseAddress: c.addressMap["bus"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// On retrieves the on/off status of the Compressor for a specific strip or bus (1-based indexing).
|
||||||
|
func (c *Comp) On(index int) (bool, error) {
|
||||||
|
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/on"
|
||||||
|
err := c.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-c.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(int32)
|
||||||
|
if !ok {
|
||||||
|
return false, fmt.Errorf("unexpected argument type for Compressor on value")
|
||||||
|
}
|
||||||
|
return val != 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOn sets the on/off status of the Compressor for a specific strip or bus (1-based indexing).
|
||||||
|
func (c *Comp) SetOn(index int, on bool) error {
|
||||||
|
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/on"
|
||||||
|
var value int32
|
||||||
|
if on {
|
||||||
|
value = 1
|
||||||
|
}
|
||||||
|
return c.client.SendMessage(address, value)
|
||||||
|
}
|
||||||
158
internal/xair/eq.go
Normal file
158
internal/xair/eq.go
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
package xair
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type Eq struct {
|
||||||
|
client *Client
|
||||||
|
baseAddress string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Factory function to create Eq instance for Strip
|
||||||
|
func newEqForStrip(c *Client) *Eq {
|
||||||
|
return &Eq{
|
||||||
|
client: c,
|
||||||
|
baseAddress: c.addressMap["strip"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Factory function to create Eq instance for Bus
|
||||||
|
func newEqForBus(c *Client) *Eq {
|
||||||
|
return &Eq{
|
||||||
|
client: c,
|
||||||
|
baseAddress: c.addressMap["bus"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// On retrieves the on/off status of the EQ for a specific strip or bus (1-based indexing).
|
||||||
|
func (e *Eq) On(index int) (bool, error) {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + "/eq/on"
|
||||||
|
err := e.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-e.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(int32)
|
||||||
|
if !ok {
|
||||||
|
return false, fmt.Errorf("unexpected argument type for EQ on value")
|
||||||
|
}
|
||||||
|
return val != 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOn sets the on/off status of the EQ for a specific strip or bus (1-based indexing).
|
||||||
|
func (e *Eq) SetOn(index int, on bool) error {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + "/eq/on"
|
||||||
|
var value int32
|
||||||
|
if on {
|
||||||
|
value = 1
|
||||||
|
}
|
||||||
|
return e.client.SendMessage(address, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Eq) Mode(index int) (int, error) {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + "/eq/mode"
|
||||||
|
err := e.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-e.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(int32)
|
||||||
|
if !ok {
|
||||||
|
return 0, fmt.Errorf("unexpected argument type for EQ mode value")
|
||||||
|
}
|
||||||
|
return int(val), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Eq) SetMode(index int, mode int) error {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + "/eq/mode"
|
||||||
|
return e.client.SendMessage(address, int32(mode))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gain retrieves the gain for a specific EQ band on a strip or bus (1-based indexing).
|
||||||
|
func (e *Eq) Gain(index int, band int) (float64, error) {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/g", band)
|
||||||
|
err := e.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-e.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(float32)
|
||||||
|
if !ok {
|
||||||
|
return 0, fmt.Errorf("unexpected argument type for EQ gain value")
|
||||||
|
}
|
||||||
|
return linGet(-15, 15, float64(val)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetGain sets the gain for a specific EQ band on a strip or bus (1-based indexing).
|
||||||
|
func (e *Eq) SetGain(index int, band int, gain float64) error {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/g", band)
|
||||||
|
return e.client.SendMessage(address, float32(linSet(-15, 15, gain)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Frequency retrieves the frequency for a specific EQ band on a strip or bus (1-based indexing).
|
||||||
|
func (e *Eq) Frequency(index int, band int) (float64, error) {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/f", band)
|
||||||
|
err := e.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-e.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(float32)
|
||||||
|
if !ok {
|
||||||
|
return 0, fmt.Errorf("unexpected argument type for EQ frequency value")
|
||||||
|
}
|
||||||
|
return logGet(20, 20000, float64(val)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetFrequency sets the frequency for a specific EQ band on a strip or bus (1-based indexing).
|
||||||
|
func (e *Eq) SetFrequency(index int, band int, frequency float64) error {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/f", band)
|
||||||
|
return e.client.SendMessage(address, float32(logSet(20, 20000, frequency)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Q retrieves the Q factor for a specific EQ band on a strip or bus (1-based indexing).
|
||||||
|
func (e *Eq) Q(index int, band int) (float64, error) {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/q", band)
|
||||||
|
err := e.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-e.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(float32)
|
||||||
|
if !ok {
|
||||||
|
return 0, fmt.Errorf("unexpected argument type for EQ Q value")
|
||||||
|
}
|
||||||
|
return logGet(0.3, 10, 1.0-float64(val)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetQ sets the Q factor for a specific EQ band on a strip or bus (1-based indexing).
|
||||||
|
func (e *Eq) SetQ(index int, band int, q float64) error {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/q", band)
|
||||||
|
return e.client.SendMessage(address, float32(1.0-logSet(0.3, 10, q)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type retrieves the type for a specific EQ band on a strip or bus (1-based indexing).
|
||||||
|
func (e *Eq) Type(index int, band int) (int, error) {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
|
||||||
|
err := e.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-e.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(int32)
|
||||||
|
if !ok {
|
||||||
|
return 0, fmt.Errorf("unexpected argument type for EQ type value")
|
||||||
|
}
|
||||||
|
return int(val), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetType sets the type for a specific EQ band on a strip or bus (1-based indexing).
|
||||||
|
func (e *Eq) SetType(index int, band int, eqType int) error {
|
||||||
|
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
|
||||||
|
return e.client.SendMessage(address, int32(eqType))
|
||||||
|
}
|
||||||
38
internal/xair/gate.go
Normal file
38
internal/xair/gate.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package xair
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type Gate struct {
|
||||||
|
client *Client
|
||||||
|
baseAddress string
|
||||||
|
}
|
||||||
|
|
||||||
|
func newGate(c *Client) *Gate {
|
||||||
|
return &Gate{client: c, baseAddress: c.addressMap["strip"]}
|
||||||
|
}
|
||||||
|
|
||||||
|
// On retrieves the on/off status of the Gate for a specific strip (1-based indexing).
|
||||||
|
func (g *Gate) On(index int) (bool, error) {
|
||||||
|
address := fmt.Sprintf(g.baseAddress, index) + "/gate/on"
|
||||||
|
err := g.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-g.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(int32)
|
||||||
|
if !ok {
|
||||||
|
return false, fmt.Errorf("unexpected argument type for Gate on value")
|
||||||
|
}
|
||||||
|
return val != 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOn sets the on/off status of the Gate for a specific strip (1-based indexing).
|
||||||
|
func (g *Gate) SetOn(index int, on bool) error {
|
||||||
|
address := fmt.Sprintf(g.baseAddress, index) + "/gate/on"
|
||||||
|
var value int32
|
||||||
|
if on {
|
||||||
|
value = 1
|
||||||
|
}
|
||||||
|
return g.client.SendMessage(address, value)
|
||||||
|
}
|
||||||
67
internal/xair/headamp.go
Normal file
67
internal/xair/headamp.go
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
package xair
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type HeadAmp struct {
|
||||||
|
baseAddress string
|
||||||
|
client *Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewHeadAmp(c *Client) *HeadAmp {
|
||||||
|
return &HeadAmp{
|
||||||
|
baseAddress: c.addressMap["headamp"],
|
||||||
|
client: c,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gain gets the gain level for the specified headamp index.
|
||||||
|
func (h *HeadAmp) Gain(index int) (float64, error) {
|
||||||
|
address := fmt.Sprintf(h.baseAddress, index) + "/gain"
|
||||||
|
err := h.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-h.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(float32)
|
||||||
|
if !ok {
|
||||||
|
return 0, fmt.Errorf("unexpected argument type for headamp gain value")
|
||||||
|
}
|
||||||
|
|
||||||
|
return linGet(-12, 60, float64(val)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetGain sets the gain level for the specified headamp index.
|
||||||
|
func (h *HeadAmp) SetGain(index int, level float64) error {
|
||||||
|
address := fmt.Sprintf(h.baseAddress, index) + "/gain"
|
||||||
|
return h.client.SendMessage(address, float32(linSet(-12, 60, level)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhantomPower gets the phantom power status for the specified headamp index.
|
||||||
|
func (h *HeadAmp) PhantomPower(index int) (bool, error) {
|
||||||
|
address := fmt.Sprintf(h.baseAddress, index) + "/phantom"
|
||||||
|
err := h.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-h.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(int32)
|
||||||
|
if !ok {
|
||||||
|
return false, fmt.Errorf("unexpected argument type for phantom power value")
|
||||||
|
}
|
||||||
|
|
||||||
|
return val != 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPhantomPower sets the phantom power status for the specified headamp index.
|
||||||
|
func (h *HeadAmp) SetPhantomPower(index int, enabled bool) error {
|
||||||
|
address := fmt.Sprintf(h.baseAddress, index) + "/phantom"
|
||||||
|
var val int32
|
||||||
|
if enabled {
|
||||||
|
val = 1
|
||||||
|
} else {
|
||||||
|
val = 0
|
||||||
|
}
|
||||||
|
return h.client.SendMessage(address, val)
|
||||||
|
}
|
||||||
@@ -3,10 +3,10 @@ package xair
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
type Main struct {
|
type Main struct {
|
||||||
client Client
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMain(c Client) *Main {
|
func newMain(c *Client) *Main {
|
||||||
return &Main{
|
return &Main{
|
||||||
client: c,
|
client: c,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,26 @@ package xair
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
type Strip struct {
|
type Strip struct {
|
||||||
client Client
|
baseAddress string
|
||||||
|
client *Client
|
||||||
|
Gate *Gate
|
||||||
|
Eq *Eq
|
||||||
|
Comp *Comp
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStrip(c Client) *Strip {
|
func NewStrip(c *Client) *Strip {
|
||||||
return &Strip{
|
return &Strip{
|
||||||
client: c,
|
baseAddress: c.addressMap["strip"],
|
||||||
|
client: c,
|
||||||
|
Gate: newGate(c),
|
||||||
|
Eq: newEqForStrip(c),
|
||||||
|
Comp: newCompForStrip(c),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mute gets the mute status of the specified strip (1-based indexing).
|
// Mute gets the mute status of the specified strip (1-based indexing).
|
||||||
func (s *Strip) Mute(strip int) (bool, error) {
|
func (s *Strip) Mute(index int) (bool, error) {
|
||||||
address := fmt.Sprintf("/ch/%02d/mix/on", strip)
|
address := fmt.Sprintf(s.baseAddress, index) + "/mix/on"
|
||||||
err := s.client.SendMessage(address)
|
err := s.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -30,7 +38,7 @@ func (s *Strip) Mute(strip int) (bool, error) {
|
|||||||
|
|
||||||
// SetMute sets the mute status of the specified strip (1-based indexing).
|
// SetMute sets the mute status of the specified strip (1-based indexing).
|
||||||
func (s *Strip) SetMute(strip int, muted bool) error {
|
func (s *Strip) SetMute(strip int, muted bool) error {
|
||||||
address := fmt.Sprintf("/ch/%02d/mix/on", strip)
|
address := fmt.Sprintf(s.baseAddress, strip) + "/mix/on"
|
||||||
var value int32 = 0
|
var value int32 = 0
|
||||||
if !muted {
|
if !muted {
|
||||||
value = 1
|
value = 1
|
||||||
@@ -40,7 +48,7 @@ func (s *Strip) SetMute(strip int, muted bool) error {
|
|||||||
|
|
||||||
// Fader gets the fader level of the specified strip (1-based indexing).
|
// Fader gets the fader level of the specified strip (1-based indexing).
|
||||||
func (s *Strip) Fader(strip int) (float64, error) {
|
func (s *Strip) Fader(strip int) (float64, error) {
|
||||||
address := fmt.Sprintf("/ch/%02d/mix/fader", strip)
|
address := fmt.Sprintf(s.baseAddress, strip) + "/mix/fader"
|
||||||
err := s.client.SendMessage(address)
|
err := s.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -57,35 +65,13 @@ func (s *Strip) Fader(strip int) (float64, error) {
|
|||||||
|
|
||||||
// SetFader sets the fader level of the specified strip (1-based indexing).
|
// SetFader sets the fader level of the specified strip (1-based indexing).
|
||||||
func (s *Strip) SetFader(strip int, level float64) error {
|
func (s *Strip) SetFader(strip int, level float64) error {
|
||||||
address := fmt.Sprintf("/ch/%02d/mix/fader", strip)
|
address := fmt.Sprintf(s.baseAddress, strip) + "/mix/fader"
|
||||||
return s.client.SendMessage(address, float32(mustDbInto(level)))
|
return s.client.SendMessage(address, float32(mustDbInto(level)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// MicGain requests the phantom gain for a specific strip (1-based indexing).
|
|
||||||
func (s *Strip) MicGain(strip int) (float64, error) {
|
|
||||||
address := fmt.Sprintf("/ch/%02d/mix/gain", strip)
|
|
||||||
err := s.client.SendMessage(address)
|
|
||||||
if err != nil {
|
|
||||||
return 0, fmt.Errorf("failed to send strip gain request: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
resp := <-s.client.respChan
|
|
||||||
val, ok := resp.Arguments[0].(float32)
|
|
||||||
if !ok {
|
|
||||||
return 0, fmt.Errorf("unexpected argument type for strip gain value")
|
|
||||||
}
|
|
||||||
return mustDbFrom(float64(val)), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMicGain sets the phantom gain for a specific strip (1-based indexing).
|
|
||||||
func (s *Strip) SetMicGain(strip int, gain float32) error {
|
|
||||||
address := fmt.Sprintf("/ch/%02d/mix/gain", strip)
|
|
||||||
return s.client.SendMessage(address, gain)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Name requests the name for a specific strip
|
// Name requests the name for a specific strip
|
||||||
func (s *Strip) Name(strip int) (string, error) {
|
func (s *Strip) Name(strip int) (string, error) {
|
||||||
address := fmt.Sprintf("/ch/%02d/config/name", strip)
|
address := fmt.Sprintf(s.baseAddress, strip) + "/config/name"
|
||||||
err := s.client.SendMessage(address)
|
err := s.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to send strip name request: %v", err)
|
return "", fmt.Errorf("failed to send strip name request: %v", err)
|
||||||
@@ -101,13 +87,13 @@ func (s *Strip) Name(strip int) (string, error) {
|
|||||||
|
|
||||||
// SetName sets the name for a specific strip
|
// SetName sets the name for a specific strip
|
||||||
func (s *Strip) SetName(strip int, name string) error {
|
func (s *Strip) SetName(strip int, name string) error {
|
||||||
address := fmt.Sprintf("/ch/%02d/config/name", strip)
|
address := fmt.Sprintf(s.baseAddress, strip) + "/config/name"
|
||||||
return s.client.SendMessage(address, name)
|
return s.client.SendMessage(address, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Color requests the color for a specific strip
|
// Color requests the color for a specific strip
|
||||||
func (s *Strip) Color(strip int) (int32, error) {
|
func (s *Strip) Color(strip int) (int32, error) {
|
||||||
address := fmt.Sprintf("/ch/%02d/config/color", strip)
|
address := fmt.Sprintf(s.baseAddress, strip) + "/config/color"
|
||||||
err := s.client.SendMessage(address)
|
err := s.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("failed to send strip color request: %v", err)
|
return 0, fmt.Errorf("failed to send strip color request: %v", err)
|
||||||
@@ -123,13 +109,13 @@ func (s *Strip) Color(strip int) (int32, error) {
|
|||||||
|
|
||||||
// SetColor sets the color for a specific strip (0-15)
|
// SetColor sets the color for a specific strip (0-15)
|
||||||
func (s *Strip) SetColor(strip int, color int32) error {
|
func (s *Strip) SetColor(strip int, color int32) error {
|
||||||
address := fmt.Sprintf("/ch/%02d/config/color", strip)
|
address := fmt.Sprintf(s.baseAddress, strip) + "/config/color"
|
||||||
return s.client.SendMessage(address, color)
|
return s.client.SendMessage(address, color)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sends requests the sends level for a mixbus.
|
// Sends requests the sends level for a mixbus.
|
||||||
func (s *Strip) SendLevel(strip int, bus int) (float64, error) {
|
func (s *Strip) SendLevel(strip int, bus int) (float64, error) {
|
||||||
address := fmt.Sprintf("/ch/%02d/mix/%02d/level", strip, bus)
|
address := fmt.Sprintf(s.baseAddress, strip) + fmt.Sprintf("/mix/%02d/level", bus)
|
||||||
err := s.client.SendMessage(address)
|
err := s.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
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)
|
||||||
@@ -145,6 +131,6 @@ func (s *Strip) SendLevel(strip int, bus int) (float64, error) {
|
|||||||
|
|
||||||
// SetSendLevel sets the sends level for a mixbus.
|
// SetSendLevel sets the sends level for a mixbus.
|
||||||
func (s *Strip) SetSendLevel(strip int, bus int, level float64) error {
|
func (s *Strip) SetSendLevel(strip int, bus int, level float64) error {
|
||||||
address := fmt.Sprintf("/ch/%02d/mix/%02d/level", strip, bus)
|
address := fmt.Sprintf(s.baseAddress, strip) + fmt.Sprintf("/mix/%02d/level", bus)
|
||||||
return s.client.SendMessage(address, float32(mustDbInto(level)))
|
return s.client.SendMessage(address, float32(mustDbInto(level)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,22 @@ package xair
|
|||||||
|
|
||||||
import "math"
|
import "math"
|
||||||
|
|
||||||
|
func linGet(min float64, max float64, value float64) float64 {
|
||||||
|
return min + (max-min)*value
|
||||||
|
}
|
||||||
|
|
||||||
|
func linSet(min float64, max float64, value float64) float64 {
|
||||||
|
return (value - min) / (max - min)
|
||||||
|
}
|
||||||
|
|
||||||
|
func logGet(min float64, max float64, value float64) float64 {
|
||||||
|
return min * math.Exp(math.Log(max/min)*value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func logSet(min float64, max float64, value float64) float64 {
|
||||||
|
return math.Log(value/min) / math.Log(max/min)
|
||||||
|
}
|
||||||
|
|
||||||
func mustDbInto(db float64) float64 {
|
func mustDbInto(db float64) float64 {
|
||||||
switch {
|
switch {
|
||||||
case db >= 10:
|
case db >= 10:
|
||||||
|
|||||||
Reference in New Issue
Block a user