mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-02-04 07:27:47 +00:00
implement {Comp} threshold, ratio, attack, hold, release, makeup and mix methods
add new compressor subcommands to strip/bus command groups
This commit is contained in:
parent
2590a43c18
commit
86ff40952b
301
cmd/bus.go
301
cmd/bus.go
@ -568,6 +568,300 @@ var busCompOnCmd = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
// busCompThresholdCmd represents the bus Compressor threshold command.
|
||||
var busCompThresholdCmd = &cobra.Command{
|
||||
Short: "Get or set the bus Compressor threshold",
|
||||
Long: `Get or set the Compressor threshold (in dB) for a specific bus.`,
|
||||
Use: "threshold [bus number] [threshold 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) < 1 {
|
||||
return fmt.Errorf("Please provide bus number")
|
||||
}
|
||||
|
||||
busIndex := mustConvToInt(args[0])
|
||||
|
||||
if len(args) == 1 {
|
||||
threshold, err := client.Bus.Comp.Threshold(busIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting bus Compressor threshold: %w", err)
|
||||
}
|
||||
cmd.Printf("Bus %d Compressor threshold: %.1f dB\n", busIndex, threshold)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide bus number and threshold (in dB)")
|
||||
}
|
||||
|
||||
threshold := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Bus.Comp.SetThreshold(busIndex, threshold)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting bus Compressor threshold: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Bus %d Compressor threshold set to %.1f dB\n", busIndex, threshold)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// busCompRatioCmd represents the bus Compressor ratio command.
|
||||
var busCompRatioCmd = &cobra.Command{
|
||||
Short: "Get or set the bus Compressor ratio",
|
||||
Long: `Get or set the Compressor ratio for a specific bus.`,
|
||||
Use: "ratio [bus number] [ratio]",
|
||||
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 {
|
||||
ratio, err := client.Bus.Comp.Ratio(busIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting bus Compressor ratio: %w", err)
|
||||
}
|
||||
cmd.Printf("Bus %d Compressor ratio: %.2f\n", busIndex, ratio)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide bus number and ratio")
|
||||
}
|
||||
|
||||
ratio := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Bus.Comp.SetRatio(busIndex, ratio)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting bus Compressor ratio: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Bus %d Compressor ratio set to %.2f\n", busIndex, ratio)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// busMixCmd represents the bus Compressor mix command.
|
||||
var busCompMixCmd = &cobra.Command{
|
||||
Short: "Get or set the bus Compressor mix",
|
||||
Long: `Get or set the Compressor mix (0-100%) for a specific bus.`,
|
||||
Use: "mix [bus number] [mix percentage]",
|
||||
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 {
|
||||
mix, err := client.Bus.Comp.Mix(busIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting bus Compressor mix: %w", err)
|
||||
}
|
||||
cmd.Printf("Bus %d Compressor mix: %.1f%%\n", busIndex, mix)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide bus number and mix percentage")
|
||||
}
|
||||
|
||||
mix := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Bus.Comp.SetMix(busIndex, mix)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting bus Compressor mix: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Bus %d Compressor mix set to %.1f%%\n", busIndex, mix)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// busMakeUpCmd represents the bus Compressor make-up gain command.
|
||||
var busCompMakeUpCmd = &cobra.Command{
|
||||
Short: "Get or set the bus Compressor make-up gain",
|
||||
Long: `Get or set the Compressor make-up gain (in dB) for a specific bus.`,
|
||||
Use: "makeup [bus number] [make-up 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) < 1 {
|
||||
return fmt.Errorf("Please provide bus number")
|
||||
}
|
||||
|
||||
busIndex := mustConvToInt(args[0])
|
||||
|
||||
if len(args) == 1 {
|
||||
makeUp, err := client.Bus.Comp.MakeUp(busIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting bus Compressor make-up gain: %w", err)
|
||||
}
|
||||
cmd.Printf("Bus %d Compressor make-up gain: %.1f dB\n", busIndex, makeUp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide bus number and make-up gain (in dB)")
|
||||
}
|
||||
|
||||
makeUp := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Bus.Comp.SetMakeUp(busIndex, makeUp)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting bus Compressor make-up gain: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Bus %d Compressor make-up gain set to %.1f dB\n", busIndex, makeUp)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// busAttackCmd represents the bus Compressor attack time command.
|
||||
var busCompAttackCmd = &cobra.Command{
|
||||
Short: "Get or set the bus Compressor attack time",
|
||||
Long: `Get or set the Compressor attack time (in milliseconds) for a specific bus.`,
|
||||
Use: "attack [bus number] [attack time in ms]",
|
||||
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 {
|
||||
attack, err := client.Bus.Comp.Attack(busIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting bus Compressor attack time: %w", err)
|
||||
}
|
||||
cmd.Printf("Bus %d Compressor attack time: %.1f ms\n", busIndex, attack)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide bus number and attack time (in ms)")
|
||||
}
|
||||
|
||||
attack := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Bus.Comp.SetAttack(busIndex, attack)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting bus Compressor attack time: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Bus %d Compressor attack time set to %.1f ms\n", busIndex, attack)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// busHoldCmd represents the bus Compressor hold time command.
|
||||
var busCompHoldCmd = &cobra.Command{
|
||||
Short: "Get or set the bus Compressor hold time",
|
||||
Long: `Get or set the Compressor hold time (in milliseconds) for a specific bus.`,
|
||||
Use: "hold [bus number] [hold time in ms]",
|
||||
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 {
|
||||
hold, err := client.Bus.Comp.Hold(busIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting bus Compressor hold time: %w", err)
|
||||
}
|
||||
cmd.Printf("Bus %d Compressor hold time: %.1f ms\n", busIndex, hold)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide bus number and hold time (in ms)")
|
||||
}
|
||||
|
||||
hold := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Bus.Comp.SetHold(busIndex, hold)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting bus Compressor hold time: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Bus %d Compressor hold time set to %.1f ms\n", busIndex, hold)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// busReleaseCmd represents the bus Compressor release time command.
|
||||
var busCompReleaseCmd = &cobra.Command{
|
||||
Short: "Get or set the bus Compressor release time",
|
||||
Long: `Get or set the Compressor release time (in milliseconds) for a specific bus.`,
|
||||
Use: "release [bus number] [release time in ms]",
|
||||
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 {
|
||||
release, err := client.Bus.Comp.Release(busIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting bus Compressor release time: %w", err)
|
||||
}
|
||||
cmd.Printf("Bus %d Compressor release time: %.1f ms\n", busIndex, release)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide bus number and release time (in ms)")
|
||||
}
|
||||
|
||||
release := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Bus.Comp.SetRelease(busIndex, release)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting bus Compressor release time: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Bus %d Compressor release time set to %.1f ms\n", busIndex, release)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(busCmd)
|
||||
|
||||
@ -589,4 +883,11 @@ func init() {
|
||||
|
||||
busCmd.AddCommand(busCompCmd)
|
||||
busCompCmd.AddCommand(busCompOnCmd)
|
||||
busCompCmd.AddCommand(busCompThresholdCmd)
|
||||
busCompCmd.AddCommand(busCompRatioCmd)
|
||||
busCompCmd.AddCommand(busCompMixCmd)
|
||||
busCompCmd.AddCommand(busCompMakeUpCmd)
|
||||
busCompCmd.AddCommand(busCompAttackCmd)
|
||||
busCompCmd.AddCommand(busCompHoldCmd)
|
||||
busCompCmd.AddCommand(busCompReleaseCmd)
|
||||
}
|
||||
|
||||
305
cmd/strip.go
305
cmd/strip.go
@ -727,6 +727,304 @@ If "false" or "0" is provided, the Compressor is turned off.`,
|
||||
},
|
||||
}
|
||||
|
||||
// stripCompThresholdCmd represents the strip Compressor Threshold command.
|
||||
var stripCompThresholdCmd = &cobra.Command{
|
||||
Short: "Get or set the Compressor threshold for a strip",
|
||||
Long: "Get or set the Compressor threshold for a specific strip.",
|
||||
Use: "threshold [strip number] [threshold 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) < 1 {
|
||||
return fmt.Errorf("Please provide a strip number")
|
||||
}
|
||||
|
||||
stripIndex := mustConvToInt(args[0])
|
||||
|
||||
if len(args) == 1 {
|
||||
currentThreshold, err := client.Strip.Comp.Threshold(stripIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting strip Compressor threshold: %w", err)
|
||||
}
|
||||
cmd.Printf("Strip %d Compressor threshold: %.2f dB\n", stripIndex, currentThreshold)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide a threshold in dB")
|
||||
}
|
||||
|
||||
threshold := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Strip.Comp.SetThreshold(stripIndex, threshold)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting strip Compressor threshold: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Strip %d Compressor threshold set to %.2f dB\n", stripIndex, threshold)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// stripCompRatioCmd represents the strip Compressor Ratio command.
|
||||
var stripCompRatioCmd = &cobra.Command{
|
||||
Short: "Get or set the Compressor ratio for a strip",
|
||||
Long: "Get or set the Compressor ratio for a specific strip.",
|
||||
Use: "ratio [strip number] [ratio]",
|
||||
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 {
|
||||
currentRatio, err := client.Strip.Comp.Ratio(stripIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting strip Compressor ratio: %w", err)
|
||||
}
|
||||
cmd.Printf("Strip %d Compressor ratio: %.2f\n", stripIndex, currentRatio)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide a ratio")
|
||||
}
|
||||
|
||||
ratio := mustConvToFloat64(args[1])
|
||||
possibleValues := []float64{1.1, 1.3, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.0, 10, 20, 100}
|
||||
if !contains(possibleValues, ratio) {
|
||||
return fmt.Errorf("Invalid ratio value. Valid values are: %v", possibleValues)
|
||||
}
|
||||
|
||||
err := client.Strip.Comp.SetRatio(stripIndex, ratio)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting strip Compressor ratio: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Strip %d Compressor ratio set to %.2f\n", stripIndex, ratio)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// stripCompMixCmd represents the strip Compressor Mix command.
|
||||
var stripCompMixCmd = &cobra.Command{
|
||||
Short: "Get or set the Compressor mix for a strip",
|
||||
Long: "Get or set the Compressor mix for a specific strip.",
|
||||
Use: "mix [strip number] [mix percentage]",
|
||||
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 {
|
||||
currentMix, err := client.Strip.Comp.Mix(stripIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting strip Compressor mix: %w", err)
|
||||
}
|
||||
cmd.Printf("Strip %d Compressor mix: %.2f%%\n", stripIndex, currentMix)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide a mix percentage")
|
||||
}
|
||||
|
||||
mix := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Strip.Comp.SetMix(stripIndex, mix)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting strip Compressor mix: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Strip %d Compressor mix set to %.2f%%\n", stripIndex, mix)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// stripCompMakeUpCmd represents the strip Compressor Make-Up Gain command.
|
||||
var stripCompMakeUpCmd = &cobra.Command{
|
||||
Short: "Get or set the Compressor make-up gain for a strip",
|
||||
Long: "Get or set the Compressor make-up gain for a specific strip.",
|
||||
Use: "makeup [strip number] [make-up 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) < 1 {
|
||||
return fmt.Errorf("Please provide a strip number")
|
||||
}
|
||||
|
||||
stripIndex := mustConvToInt(args[0])
|
||||
|
||||
if len(args) == 1 {
|
||||
currentMakeUp, err := client.Strip.Comp.MakeUp(stripIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting strip Compressor make-up gain: %w", err)
|
||||
}
|
||||
cmd.Printf("Strip %d Compressor make-up gain: %.2f dB\n", stripIndex, currentMakeUp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide a make-up gain in dB")
|
||||
}
|
||||
|
||||
makeUp := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Strip.Comp.SetMakeUp(stripIndex, makeUp)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting strip Compressor make-up gain: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Strip %d Compressor make-up gain set to %.2f dB\n", stripIndex, makeUp)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// stripCompAttackCmd represents the strip Compressor Attack command.
|
||||
var stripCompAttackCmd = &cobra.Command{
|
||||
Short: "Get or set the Compressor attack time for a strip",
|
||||
Long: "Get or set the Compressor attack time for a specific strip.",
|
||||
Use: "attack [strip number] [attack time in ms]",
|
||||
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 {
|
||||
currentAttack, err := client.Strip.Comp.Attack(stripIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting strip Compressor attack time: %w", err)
|
||||
}
|
||||
cmd.Printf("Strip %d Compressor attack time: %.2f ms\n", stripIndex, currentAttack)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide an attack time in ms")
|
||||
}
|
||||
|
||||
attack := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Strip.Comp.SetAttack(stripIndex, attack)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting strip Compressor attack time: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Strip %d Compressor attack time set to %.2f ms\n", stripIndex, attack)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// stripCompHoldCmd represents the strip Compressor Hold command.
|
||||
var stripCompHoldCmd = &cobra.Command{
|
||||
Short: "Get or set the Compressor hold time for a strip",
|
||||
Long: "Get or set the Compressor hold time for a specific strip.",
|
||||
Use: "hold [strip number] [hold time in ms]",
|
||||
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 {
|
||||
currentHold, err := client.Strip.Comp.Hold(stripIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting strip Compressor hold time: %w", err)
|
||||
}
|
||||
cmd.Printf("Strip %d Compressor hold time: %.2f ms\n", stripIndex, currentHold)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide a hold time in ms")
|
||||
}
|
||||
|
||||
hold := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Strip.Comp.SetHold(stripIndex, hold)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting strip Compressor hold time: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Strip %d Compressor hold time set to %.2f ms\n", stripIndex, hold)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// stripCompReleaseCmd represents the strip Compressor Release command.
|
||||
var stripCompReleaseCmd = &cobra.Command{
|
||||
Short: "Get or set the Compressor release time for a strip",
|
||||
Long: "Get or set the Compressor release time for a specific strip.",
|
||||
Use: "release [strip number] [release time in ms]",
|
||||
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 {
|
||||
currentRelease, err := client.Strip.Comp.Release(stripIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting strip Compressor release time: %w", err)
|
||||
}
|
||||
cmd.Printf("Strip %d Compressor release time: %.2f ms\n", stripIndex, currentRelease)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) < 2 {
|
||||
return fmt.Errorf("Please provide a release time in ms")
|
||||
}
|
||||
|
||||
release := mustConvToFloat64(args[1])
|
||||
|
||||
err := client.Strip.Comp.SetRelease(stripIndex, release)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting strip Compressor release time: %w", err)
|
||||
}
|
||||
|
||||
cmd.Printf("Strip %d Compressor release time set to %.2f ms\n", stripIndex, release)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(stripCmd)
|
||||
|
||||
@ -751,4 +1049,11 @@ func init() {
|
||||
|
||||
stripCmd.AddCommand(stripCompCmd)
|
||||
stripCompCmd.AddCommand(stripCompOnCmd)
|
||||
stripCompCmd.AddCommand(stripCompThresholdCmd)
|
||||
stripCompCmd.AddCommand(stripCompRatioCmd)
|
||||
stripCompCmd.AddCommand(stripCompMixCmd)
|
||||
stripCompCmd.AddCommand(stripCompMakeUpCmd)
|
||||
stripCompCmd.AddCommand(stripCompAttackCmd)
|
||||
stripCompCmd.AddCommand(stripCompHoldCmd)
|
||||
stripCompCmd.AddCommand(stripCompReleaseCmd)
|
||||
}
|
||||
|
||||
@ -31,3 +31,8 @@ func indexOf[T comparable](slice []T, elem T) int {
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// generic contains checks if elem is in slice.
|
||||
func contains[T comparable](slice []T, elem T) bool {
|
||||
return indexOf(slice, elem) != -1
|
||||
}
|
||||
|
||||
@ -48,3 +48,162 @@ func (c *Comp) SetOn(index int, on bool) error {
|
||||
}
|
||||
return c.client.SendMessage(address, value)
|
||||
}
|
||||
|
||||
// Threshold retrieves the threshold value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Threshold(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/thr"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
resp := <-c.client.respChan
|
||||
val, ok := resp.Arguments[0].(float32)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("unexpected argument type for Compressor threshold value")
|
||||
}
|
||||
return linGet(-60, 0, float64(val)), nil
|
||||
}
|
||||
|
||||
// SetThreshold sets the threshold value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetThreshold(index int, threshold float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/thr"
|
||||
return c.client.SendMessage(address, float32(linSet(-60, 0, threshold)))
|
||||
}
|
||||
|
||||
// Ratio retrieves the ratio value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Ratio(index int) (float32, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/ratio"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
possibleValues := []float32{1.1, 1.3, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.0, 10, 20, 100}
|
||||
|
||||
resp := <-c.client.respChan
|
||||
val, ok := resp.Arguments[0].(int32)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("unexpected argument type for Compressor ratio value")
|
||||
}
|
||||
|
||||
return possibleValues[val], nil
|
||||
}
|
||||
|
||||
// SetRatio sets the ratio value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetRatio(index int, ratio float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/ratio"
|
||||
possibleValues := []float32{1.1, 1.3, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.0, 10, 20, 100}
|
||||
|
||||
return c.client.SendMessage(address, int32(indexOf(possibleValues, float32(ratio))))
|
||||
}
|
||||
|
||||
// Attack retrieves the attack time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Attack(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/attack"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
resp := <-c.client.respChan
|
||||
val, ok := resp.Arguments[0].(float32)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("unexpected argument type for Compressor attack value")
|
||||
}
|
||||
return linGet(0, 120, float64(val)), nil
|
||||
}
|
||||
|
||||
// SetAttack sets the attack time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetAttack(index int, attack float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/attack"
|
||||
return c.client.SendMessage(address, float32(linSet(0, 120, attack)))
|
||||
}
|
||||
|
||||
// Hold retrieves the hold time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Hold(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/hold"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
resp := <-c.client.respChan
|
||||
val, ok := resp.Arguments[0].(float32)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("unexpected argument type for Compressor hold value")
|
||||
}
|
||||
return logGet(0.02, 2000, float64(val)), nil
|
||||
}
|
||||
|
||||
// SetHold sets the hold time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetHold(index int, hold float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/hold"
|
||||
return c.client.SendMessage(address, float32(logSet(0.02, 2000, hold)))
|
||||
}
|
||||
|
||||
// Release retrieves the release time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Release(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/release"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
resp := <-c.client.respChan
|
||||
val, ok := resp.Arguments[0].(float32)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("unexpected argument type for Compressor release value")
|
||||
}
|
||||
return logGet(4, 4000, float64(val)), nil
|
||||
}
|
||||
|
||||
// SetRelease sets the release time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetRelease(index int, release float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/release"
|
||||
return c.client.SendMessage(address, float32(logSet(4, 4000, release)))
|
||||
}
|
||||
|
||||
// MakeUp retrieves the make-up gain of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) MakeUp(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mgain"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
resp := <-c.client.respChan
|
||||
val, ok := resp.Arguments[0].(float32)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("unexpected argument type for Compressor make-up gain value")
|
||||
}
|
||||
return linGet(0, 24, float64(val)), nil
|
||||
}
|
||||
|
||||
// SetMakeUp sets the make-up gain of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetMakeUp(index int, makeUp float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mgain"
|
||||
return c.client.SendMessage(address, float32(linSet(0, 24, makeUp)))
|
||||
}
|
||||
|
||||
// Mix retrieves the mix value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Mix(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mix"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
resp := <-c.client.respChan
|
||||
val, ok := resp.Arguments[0].(float32)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("unexpected argument type for Compressor mix value")
|
||||
}
|
||||
return linGet(0, 100, float64(val)), nil
|
||||
}
|
||||
|
||||
// SetMix sets the mix value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetMix(index int, mix float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mix"
|
||||
return c.client.SendMessage(address, float32(linSet(0, 100, mix)))
|
||||
}
|
||||
|
||||
@ -56,3 +56,13 @@ func toFixed(num float64, precision int) float64 {
|
||||
output := math.Pow(10, float64(precision))
|
||||
return float64(math.Round(num*output)) / output
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user