mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-02-03 23:17:47 +00:00
add strip/bus name commands
This commit is contained in:
parent
4c4d52c74e
commit
d894cc1317
46
cmd/bus.go
46
cmd/bus.go
@ -223,6 +223,50 @@ var busFadeInCmd = &cobra.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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`,
|
||||||
|
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) < 1 {
|
||||||
|
cmd.PrintErrln("Please provide bus number")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
busIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
|
if len(args) == 1 {
|
||||||
|
name, err := client.Bus.Name(busIndex)
|
||||||
|
if err != nil {
|
||||||
|
cmd.PrintErrln("Error getting bus name:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd.Printf("Bus %d name: %s\n", busIndex, name)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
newName := args[1]
|
||||||
|
err := client.Bus.SetName(busIndex, newName)
|
||||||
|
if err != nil {
|
||||||
|
cmd.PrintErrln("Error setting bus name:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd.Printf("Bus %d name set to: %s\n", busIndex, newName)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(busCmd)
|
rootCmd.AddCommand(busCmd)
|
||||||
|
|
||||||
@ -233,4 +277,6 @@ func init() {
|
|||||||
busFadeOutCmd.Flags().Float64P("duration", "d", 5.0, "Duration for fade out in seconds")
|
busFadeOutCmd.Flags().Float64P("duration", "d", 5.0, "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().Float64P("duration", "d", 5.0, "Duration for fade in in seconds")
|
||||||
|
|
||||||
|
busCmd.AddCommand(busNameCmd)
|
||||||
}
|
}
|
||||||
|
|||||||
50
cmd/strip.go
50
cmd/strip.go
@ -305,6 +305,54 @@ var stripSendCmd = &cobra.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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"`,
|
||||||
|
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) < 1 {
|
||||||
|
cmd.PrintErrln("Please provide a strip number")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
stripIndex := mustConvToInt(args[0])
|
||||||
|
|
||||||
|
if len(args) == 1 {
|
||||||
|
name, err := client.Strip.Name(stripIndex)
|
||||||
|
if err != nil {
|
||||||
|
cmd.PrintErrln("Error getting strip name:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d name: %s\n", stripIndex, name)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
name := args[1]
|
||||||
|
|
||||||
|
err := client.Strip.SetName(stripIndex, name)
|
||||||
|
if err != nil {
|
||||||
|
cmd.PrintErrln("Error setting strip name:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd.Printf("Strip %d name set to: %s\n", stripIndex, name)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(stripCmd)
|
rootCmd.AddCommand(stripCmd)
|
||||||
|
|
||||||
@ -317,4 +365,6 @@ func init() {
|
|||||||
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)
|
stripCmd.AddCommand(stripSendCmd)
|
||||||
|
|
||||||
|
stripCmd.AddCommand(stripNameCmd)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,14 @@ package xair
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
type Bus struct {
|
type Bus struct {
|
||||||
client Client
|
baseAddress string
|
||||||
|
client Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBus(c Client) *Bus {
|
func NewBus(c Client) *Bus {
|
||||||
return &Bus{
|
return &Bus{
|
||||||
client: c,
|
baseAddress: c.addressMap["bus"],
|
||||||
|
client: c,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,8 +33,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 +43,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 +60,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)
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user