4 Commits

Author SHA1 Message Date
056ebc9116 add strip comp mode + strip gate subcommands 2026-02-04 07:31:00 +00:00
ce955deb38 add bus comp mode 2026-02-04 07:30:44 +00:00
6e3953e946 print hold to 2dp 2026-02-04 05:27:48 +00:00
86ff40952b implement {Comp} threshold, ratio, attack, hold, release, makeup and mix methods
add new compressor subcommands to strip/bus command groups
2026-02-04 05:22:47 +00:00
6 changed files with 1278 additions and 0 deletions

View File

@@ -568,6 +568,341 @@ var busCompOnCmd = &cobra.Command{
},
}
// busCompModeCmd represents the bus Compressor mode command.
var busCompModeCmd = &cobra.Command{
Short: "Get or set the bus Compressor mode",
Long: `Get or set the Compressor 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])
if len(args) == 1 {
mode, err := client.Bus.Comp.Mode(busIndex)
if err != nil {
return fmt.Errorf("Error getting bus Compressor mode: %w", err)
}
cmd.Printf("Bus %d Compressor mode: %s\n", busIndex, mode)
return nil
}
mode := args[1]
if !contains([]string{"comp", "exp"}, mode) {
return fmt.Errorf("Invalid mode value. Valid values are: comp, exp")
}
err := client.Bus.Comp.SetMode(busIndex, mode)
if err != nil {
return fmt.Errorf("Error setting bus Compressor mode: %w", err)
}
cmd.Printf("Bus %d Compressor mode set to %s\n", busIndex, mode)
return nil
},
}
// 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: %.2f 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 %.2f 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 +924,12 @@ func init() {
busCmd.AddCommand(busCompCmd)
busCompCmd.AddCommand(busCompOnCmd)
busCompCmd.AddCommand(busCompModeCmd)
busCompCmd.AddCommand(busCompThresholdCmd)
busCompCmd.AddCommand(busCompRatioCmd)
busCompCmd.AddCommand(busCompMixCmd)
busCompCmd.AddCommand(busCompMakeUpCmd)
busCompCmd.AddCommand(busCompAttackCmd)
busCompCmd.AddCommand(busCompHoldCmd)
busCompCmd.AddCommand(busCompReleaseCmd)
}

View File

@@ -404,6 +404,249 @@ If "false" or "0" is provided, the Gate is turned off.`,
},
}
// stripGateModeCmd represents the strip Gate Mode command.
var stripGateModeCmd = &cobra.Command{
Short: "Get or set the Gate mode for a strip",
Long: "Get or set the Gate mode for a specific strip.",
Use: "mode [strip 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 a strip number")
}
stripIndex := mustConvToInt(args[0])
if len(args) == 1 {
currentMode, err := client.Strip.Gate.Mode(stripIndex)
if err != nil {
return fmt.Errorf("Error getting strip Gate mode: %w", err)
}
cmd.Printf("Strip %d Gate mode: %s\n", stripIndex, currentMode)
return nil
}
if len(args) < 2 {
return fmt.Errorf("Please provide a mode")
}
mode := args[1]
possibleModes := []string{"exp2", "exp3", "exp4", "gate", "duck"}
if !contains(possibleModes, mode) {
return fmt.Errorf("Invalid mode value. Valid values are: %v", possibleModes)
}
err := client.Strip.Gate.SetMode(stripIndex, mode)
if err != nil {
return fmt.Errorf("Error setting strip Gate mode: %w", err)
}
cmd.Printf("Strip %d Gate mode set to %s\n", stripIndex, mode)
return nil
},
}
// stripGateThresholdCmd represents the strip Gate Threshold command.
var stripGateThresholdCmd = &cobra.Command{
Short: "Get or set the Gate threshold for a strip",
Long: "Get or set the Gate 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.Gate.Threshold(stripIndex)
if err != nil {
return fmt.Errorf("Error getting strip Gate threshold: %w", err)
}
cmd.Printf("Strip %d Gate 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.Gate.SetThreshold(stripIndex, threshold)
if err != nil {
return fmt.Errorf("Error setting strip Gate threshold: %w", err)
}
cmd.Printf("Strip %d Gate threshold set to %.2f dB\n", stripIndex, threshold)
return nil
},
}
// stripGateRangeCmd represents the strip Gate Range command.
var stripGateRangeCmd = &cobra.Command{
Short: "Get or set the Gate range for a strip",
Long: "Get or set the Gate range for a specific strip.",
Use: "range [strip number] [range 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 {
currentRange, err := client.Strip.Gate.Range(stripIndex)
if err != nil {
return fmt.Errorf("Error getting strip Gate range: %w", err)
}
cmd.Printf("Strip %d Gate range: %.2f dB\n", stripIndex, currentRange)
return nil
}
if len(args) < 2 {
return fmt.Errorf("Please provide a range in dB")
}
rangeDb := mustConvToFloat64(args[1])
err := client.Strip.Gate.SetRange(stripIndex, rangeDb)
if err != nil {
return fmt.Errorf("Error setting strip Gate range: %w", err)
}
cmd.Printf("Strip %d Gate range set to %.2f dB\n", stripIndex, rangeDb)
return nil
},
}
// stripGateAttackCmd represents the strip Gate Attack command.
var stripGateAttackCmd = &cobra.Command{
Short: "Get or set the Gate attack time for a strip",
Long: "Get or set the Gate 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.Gate.Attack(stripIndex)
if err != nil {
return fmt.Errorf("Error getting strip Gate attack time: %w", err)
}
cmd.Printf("Strip %d Gate 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.Gate.SetAttack(stripIndex, attack)
if err != nil {
return fmt.Errorf("Error setting strip Gate attack time: %w", err)
}
cmd.Printf("Strip %d Gate attack time set to %.2f ms\n", stripIndex, attack)
return nil
},
}
// stripGateHoldCmd represents the strip Gate Hold command.
var stripGateHoldCmd = &cobra.Command{
Short: "Get or set the Gate hold time for a strip",
Long: "Get or set the Gate 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.Gate.Hold(stripIndex)
if err != nil {
return fmt.Errorf("Error getting strip Gate hold time: %w", err)
}
cmd.Printf("Strip %d Gate 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.Gate.SetHold(stripIndex, hold)
if err != nil {
return fmt.Errorf("Error setting strip Gate hold time: %w", err)
}
cmd.Printf("Strip %d Gate hold time set to %.2f ms\n", stripIndex, hold)
return nil
},
}
// stripGateReleaseCmd represents the strip Gate Release command.
var stripGateReleaseCmd = &cobra.Command{
Short: "Get or set the Gate release time for a strip",
Long: "Get or set the Gate 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.Gate.Release(stripIndex)
if err != nil {
return fmt.Errorf("Error getting strip Gate release time: %w", err)
}
cmd.Printf("Strip %d Gate 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.Gate.SetRelease(stripIndex, release)
if err != nil {
return fmt.Errorf("Error setting strip Gate release time: %w", err)
}
cmd.Printf("Strip %d Gate release time set to %.2f ms\n", stripIndex, release)
return nil
},
}
// stripEqCmd represents the strip EQ command.
var stripEqCmd = &cobra.Command{
Short: "Commands to control the EQ of individual strips.",
@@ -727,6 +970,349 @@ If "false" or "0" is provided, the Compressor is turned off.`,
},
}
// stripCompModeCmd represents the strip Compressor Mode command.
var stripCompModeCmd = &cobra.Command{
Short: "Get or set the Compressor mode for a strip",
Long: "Get or set the Compressor mode for a specific strip.",
Use: "mode [strip 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 a strip number")
}
stripIndex := mustConvToInt(args[0])
if len(args) == 1 {
currentMode, err := client.Strip.Comp.Mode(stripIndex)
if err != nil {
return fmt.Errorf("Error getting strip Compressor mode: %w", err)
}
cmd.Printf("Strip %d Compressor mode: %s\n", stripIndex, currentMode)
return nil
}
if len(args) < 2 {
return fmt.Errorf("Please provide a mode")
}
mode := args[1]
if !contains([]string{"comp", "exp"}, mode) {
return fmt.Errorf("Invalid mode value. Valid values are: comp, exp")
}
err := client.Strip.Comp.SetMode(stripIndex, mode)
if err != nil {
return fmt.Errorf("Error setting strip Compressor mode: %w", err)
}
cmd.Printf("Strip %d Compressor mode set to %s\n", stripIndex, mode)
return nil
},
}
// 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)
@@ -741,6 +1327,12 @@ func init() {
stripCmd.AddCommand(stripGateCmd)
stripGateCmd.AddCommand(stripGateOnCmd)
stripGateCmd.AddCommand(stripGateModeCmd)
stripGateCmd.AddCommand(stripGateThresholdCmd)
stripGateCmd.AddCommand(stripGateRangeCmd)
stripGateCmd.AddCommand(stripGateAttackCmd)
stripGateCmd.AddCommand(stripGateHoldCmd)
stripGateCmd.AddCommand(stripGateReleaseCmd)
stripCmd.AddCommand(stripEqCmd)
stripEqCmd.AddCommand(stripEqOnCmd)
@@ -751,4 +1343,12 @@ func init() {
stripCmd.AddCommand(stripCompCmd)
stripCompCmd.AddCommand(stripCompOnCmd)
stripCompCmd.AddCommand(stripCompModeCmd)
stripCompCmd.AddCommand(stripCompThresholdCmd)
stripCompCmd.AddCommand(stripCompRatioCmd)
stripCompCmd.AddCommand(stripCompMixCmd)
stripCompCmd.AddCommand(stripCompMakeUpCmd)
stripCompCmd.AddCommand(stripCompAttackCmd)
stripCompCmd.AddCommand(stripCompHoldCmd)
stripCompCmd.AddCommand(stripCompReleaseCmd)
}

View File

@@ -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
}

View File

@@ -48,3 +48,187 @@ func (c *Comp) SetOn(index int, on bool) error {
}
return c.client.SendMessage(address, value)
}
// Mode retrieves the current mode of the Compressor for a specific strip or bus (1-based indexing).
func (c *Comp) Mode(index int) (string, error) {
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mode"
err := c.client.SendMessage(address)
if err != nil {
return "", err
}
possibleModes := []string{"comp", "exp"}
resp := <-c.client.respChan
val, ok := resp.Arguments[0].(int32)
if !ok {
return "", fmt.Errorf("unexpected argument type for Compressor mode value")
}
return possibleModes[val], nil
}
// SetMode sets the mode of the Compressor for a specific strip or bus (1-based indexing).
func (c *Comp) SetMode(index int, mode string) error {
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mode"
possibleModes := []string{"comp", "exp"}
return c.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
}
// 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)))
}

View File

@@ -36,3 +36,139 @@ func (g *Gate) SetOn(index int, on bool) error {
}
return g.client.SendMessage(address, value)
}
// Mode retrieves the current mode of the Gate for a specific strip (1-based indexing).
func (g *Gate) Mode(index int) (string, error) {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/mode"
err := g.client.SendMessage(address)
if err != nil {
return "", err
}
possibleModes := []string{"exp2", "exp3", "exp4", "gate", "duck"}
resp := <-g.client.respChan
val, ok := resp.Arguments[0].(int32)
if !ok {
return "", fmt.Errorf("unexpected argument type for Gate mode value")
}
return possibleModes[val], nil
}
// SetMode sets the mode of the Gate for a specific strip (1-based indexing).
func (g *Gate) SetMode(index int, mode string) error {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/mode"
possibleModes := []string{"exp2", "exp3", "exp4", "gate", "duck"}
return g.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
}
// Threshold retrieves the threshold value of the Gate for a specific strip (1-based indexing).
func (g *Gate) Threshold(index int) (float64, error) {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/thr"
err := g.client.SendMessage(address)
if err != nil {
return 0, err
}
resp := <-g.client.respChan
val, ok := resp.Arguments[0].(float32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for Gate threshold value")
}
return linGet(-80, 0, float64(val)), nil
}
// SetThreshold sets the threshold value of the Gate for a specific strip (1-based indexing).
func (g *Gate) SetThreshold(index int, threshold float64) error {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/thr"
return g.client.SendMessage(address, float32(linSet(-80, 0, threshold)))
}
// Range retrieves the range value of the Gate for a specific strip (1-based indexing).
func (g *Gate) Range(index int) (float64, error) {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/range"
err := g.client.SendMessage(address)
if err != nil {
return 0, err
}
resp := <-g.client.respChan
val, ok := resp.Arguments[0].(float32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for Gate range value")
}
return linGet(3, 60, float64(val)), nil
}
// SetRange sets the range value of the Gate for a specific strip (1-based indexing).
func (g *Gate) SetRange(index int, rangeVal float64) error {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/range"
return g.client.SendMessage(address, float32(linSet(3, 60, rangeVal)))
}
// Attack retrieves the attack time of the Gate for a specific strip (1-based indexing).
func (g *Gate) Attack(index int) (float64, error) {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/attack"
err := g.client.SendMessage(address)
if err != nil {
return 0, err
}
resp := <-g.client.respChan
val, ok := resp.Arguments[0].(float32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for Gate attack value")
}
return linGet(0, 120, float64(val)), nil
}
// SetAttack sets the attack time of the Gate for a specific strip (1-based indexing).
func (g *Gate) SetAttack(index int, attack float64) error {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/attack"
return g.client.SendMessage(address, float32(linSet(0, 120, attack)))
}
// Hold retrieves the hold time of the Gate for a specific strip (1-based indexing).
func (g *Gate) Hold(index int) (float64, error) {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/hold"
err := g.client.SendMessage(address)
if err != nil {
return 0, err
}
resp := <-g.client.respChan
val, ok := resp.Arguments[0].(float32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for Gate hold value")
}
return logGet(0.02, 2000, float64(val)), nil
}
// SetHold sets the hold time of the Gate for a specific strip (1-based indexing).
func (g *Gate) SetHold(index int, hold float64) error {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/hold"
return g.client.SendMessage(address, float32(logSet(0.02, 2000, hold)))
}
// Release retrieves the release time of the Gate for a specific strip (1-based indexing).
func (g *Gate) Release(index int) (float64, error) {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/release"
err := g.client.SendMessage(address)
if err != nil {
return 0, err
}
resp := <-g.client.respChan
val, ok := resp.Arguments[0].(float32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for Gate release value")
}
return logGet(5, 4000, float64(val)), nil
}
// SetRelease sets the release time of the Gate for a specific strip (1-based indexing).
func (g *Gate) SetRelease(index int, release float64) error {
address := fmt.Sprintf(g.baseAddress, index) + "/gate/release"
return g.client.SendMessage(address, float32(logSet(5, 4000, release)))
}

View File

@@ -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
}