mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-02-04 07:27:47 +00:00
add strip send command
This commit is contained in:
parent
ad7c910180
commit
a0663350f8
69
cmd/strip.go
69
cmd/strip.go
@ -18,7 +18,7 @@ var stripCmd = &cobra.Command{
|
|||||||
|
|
||||||
// stripMuteCmd represents the strip mute command.
|
// stripMuteCmd represents the strip mute command.
|
||||||
var stripMuteCmd = &cobra.Command{
|
var stripMuteCmd = &cobra.Command{
|
||||||
Use: "mute",
|
Use: "mute [strip number] [true|false]",
|
||||||
Short: "Get or set the mute status of a strip",
|
Short: "Get or set the mute status of a strip",
|
||||||
Long: `Get or set the mute status of a specific strip.
|
Long: `Get or set the mute status of a specific strip.
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ For example:
|
|||||||
|
|
||||||
// stripFaderCmd represents the strip fader command.
|
// stripFaderCmd represents the strip fader command.
|
||||||
var stripFaderCmd = &cobra.Command{
|
var stripFaderCmd = &cobra.Command{
|
||||||
Use: "fader",
|
Use: "fader [strip number] [level in dB]",
|
||||||
Short: "Get or set the fader level of a strip",
|
Short: "Get or set the fader level of a strip",
|
||||||
Long: `Get or set the fader level of a specific strip.
|
Long: `Get or set the fader level of a specific strip.
|
||||||
|
|
||||||
@ -141,13 +141,13 @@ For example:
|
|||||||
|
|
||||||
// stripFadeOutCmd represents the strip fade out command.
|
// stripFadeOutCmd represents the strip fade out command.
|
||||||
var stripFadeOutCmd = &cobra.Command{
|
var stripFadeOutCmd = &cobra.Command{
|
||||||
Use: "fadeout",
|
Use: "fadeout [strip number] --duration [seconds] [target level in dB]",
|
||||||
Short: "Fade out the strip over a specified duration",
|
Short: "Fade out the strip over a specified duration",
|
||||||
Long: `Fade out the strip over a specified duration in seconds.
|
Long: `Fade out the strip over a specified duration in seconds.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
# Fade out strip 1 over 5 seconds
|
# Fade out strip 1 over 5 seconds
|
||||||
xair-cli strip fadeout 1 --duration 5.0
|
xair-cli strip fadeout 1 --duration 5.0 -- -90.0
|
||||||
`,
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
@ -204,13 +204,13 @@ For example:
|
|||||||
|
|
||||||
// stripFadeInCmd represents the strip fade in command.
|
// stripFadeInCmd represents the strip fade in command.
|
||||||
var stripFadeInCmd = &cobra.Command{
|
var stripFadeInCmd = &cobra.Command{
|
||||||
Use: "fadein",
|
Use: "fadein [strip number] --duration [seconds] [target level in dB]",
|
||||||
Short: "Fade in the strip over a specified duration",
|
Short: "Fade in the strip over a specified duration",
|
||||||
Long: `Fade in the strip over a specified duration in seconds.
|
Long: `Fade in the strip over a specified duration in seconds.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
# Fade in strip 1 over 5 seconds
|
# Fade in strip 1 over 5 seconds
|
||||||
xair-cli strip fadein 1 --duration 5.0
|
xair-cli strip fadein 1 --duration 5.0 0
|
||||||
`,
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
client := ClientFromContext(cmd.Context())
|
client := ClientFromContext(cmd.Context())
|
||||||
@ -265,6 +265,61 @@ For example:
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stripSendCmd represents the strip send command.
|
||||||
|
var stripSendCmd = &cobra.Command{
|
||||||
|
Use: "send [strip number] [bus number] [level in dB]",
|
||||||
|
Short: "Commands to get or set strip send levels",
|
||||||
|
Long: `Commands to get or set the send levels for individual strips.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
# Get the send level of strip 1 to bus 1
|
||||||
|
xair-cli strip send 1 1
|
||||||
|
|
||||||
|
# Set the send level of strip 1 to bus 1 to -5.0 dB
|
||||||
|
xair-cli strip send 1 1 -- -5.0
|
||||||
|
`,
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
client := ClientFromContext(cmd.Context())
|
||||||
|
if client == nil {
|
||||||
|
cmd.PrintErrln("OSC client not found in context")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 2 {
|
||||||
|
cmd.PrintErrln("Please provide strip number and bus number")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
stripIndex, busIndex := func() (int, int) {
|
||||||
|
return mustConvToInt(args[0]), mustConvToInt(args[1])
|
||||||
|
}()
|
||||||
|
|
||||||
|
if len(args) == 2 {
|
||||||
|
currentLevel, err := client.Strip.SendLevel(stripIndex, busIndex)
|
||||||
|
if err != nil {
|
||||||
|
cmd.PrintErrln("Error getting strip send level:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d send level to bus %d: %.2f dB\n", stripIndex, busIndex, currentLevel)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) < 3 {
|
||||||
|
cmd.PrintErrln("Please provide a send level in dB")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
level := mustConvToFloat64(args[2])
|
||||||
|
|
||||||
|
err := client.Strip.SetSendLevel(stripIndex, busIndex, level)
|
||||||
|
if err != nil {
|
||||||
|
cmd.PrintErrln("Error setting strip send level:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d send level to bus %d set to %.2f dB\n", stripIndex, busIndex, level)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(stripCmd)
|
rootCmd.AddCommand(stripCmd)
|
||||||
|
|
||||||
@ -275,4 +330,6 @@ func init() {
|
|||||||
stripFadeOutCmd.Flags().Float64P("duration", "d", 5.0, "Duration of the fade out in seconds")
|
stripFadeOutCmd.Flags().Float64P("duration", "d", 5.0, "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().Float64P("duration", "d", 5.0, "Duration of the fade in in seconds")
|
||||||
|
|
||||||
|
stripCmd.AddCommand(stripSendCmd)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,3 +126,25 @@ func (s *Strip) SetColor(strip int, color int32) error {
|
|||||||
address := fmt.Sprintf("/ch/%02d/config/color", strip)
|
address := fmt.Sprintf("/ch/%02d/config/color", strip)
|
||||||
return s.client.SendMessage(address, color)
|
return s.client.SendMessage(address, color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sends requests the sends level for a mixbus.
|
||||||
|
func (s *Strip) SendLevel(strip int, bus int) (float64, error) {
|
||||||
|
address := fmt.Sprintf("/ch/%02d/mix/%02d/level", strip, bus)
|
||||||
|
err := s.client.SendMessage(address)
|
||||||
|
if err != nil {
|
||||||
|
return 0, fmt.Errorf("failed to send strip send level request: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := <-s.client.respChan
|
||||||
|
val, ok := resp.Arguments[0].(float32)
|
||||||
|
if !ok {
|
||||||
|
return 0, fmt.Errorf("unexpected argument type for strip send level value")
|
||||||
|
}
|
||||||
|
return mustDbFrom(float64(val)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSendLevel sets the sends level for a mixbus.
|
||||||
|
func (s *Strip) SetSendLevel(strip int, bus int, level float64) error {
|
||||||
|
address := fmt.Sprintf("/ch/%02d/mix/%02d/level", strip, bus)
|
||||||
|
return s.client.SendMessage(address, float32(mustDbInto(level)))
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user