mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-04-08 18:03:37 +00:00
enable revive linter
- add package comments - fix redeclaration of built-in min/max - add comments to exported types - remove unused parameters
This commit is contained in:
@@ -2,6 +2,7 @@ package xair
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Bus represents the bus parameters of the mixer.
|
||||
type Bus struct {
|
||||
client *client
|
||||
baseAddress string
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Package xair provides a client for controlling XAir and X32 mixers using OSC messages.
|
||||
package xair
|
||||
|
||||
import (
|
||||
@@ -9,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// XAirClient is a client for controlling XAir mixers.
|
||||
type XAirClient struct {
|
||||
type XAirClient struct { // nolint: revive
|
||||
client
|
||||
Main *Main
|
||||
Strip *Strip
|
||||
@@ -40,7 +41,7 @@ func NewXAirClient(mixerIP string, mixerPort int, opts ...EngineOption) (*XAirCl
|
||||
}
|
||||
|
||||
// X32Client is a client for controlling X32 mixers.
|
||||
type X32Client struct {
|
||||
type X32Client struct { // nolint: revive
|
||||
client
|
||||
Main *Main
|
||||
MainMono *Main
|
||||
@@ -79,7 +80,7 @@ type client struct {
|
||||
Info InfoResponse
|
||||
}
|
||||
|
||||
// Start begins listening for messages in a goroutine.
|
||||
// StartListening begins listening for messages in a goroutine.
|
||||
func (c *client) StartListening() {
|
||||
go c.receiveLoop()
|
||||
log.Debugf("Started listening on %s...", c.engine.conn.LocalAddr().String())
|
||||
|
||||
@@ -2,6 +2,7 @@ package xair
|
||||
|
||||
import "fmt"
|
||||
|
||||
// DCA represents the DCA group parameters of the mixer.
|
||||
type DCA struct {
|
||||
client *client
|
||||
baseAddress string
|
||||
|
||||
@@ -55,6 +55,7 @@ func (e *Eq) SetOn(index int, on bool) error {
|
||||
return e.client.SendMessage(address, value)
|
||||
}
|
||||
|
||||
// Mode retrieves the EQ mode for a specific strip or bus (1-based indexing).
|
||||
func (e *Eq) Mode(index int) (string, error) {
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/mode"
|
||||
err := e.client.SendMessage(address)
|
||||
@@ -75,6 +76,7 @@ func (e *Eq) Mode(index int) (string, error) {
|
||||
return possibleModes[val], nil
|
||||
}
|
||||
|
||||
// SetMode sets the EQ mode for a specific strip or bus (1-based indexing).
|
||||
func (e *Eq) SetMode(index int, mode string) error {
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/mode"
|
||||
possibleModes := []string{"peq", "geq", "teq"}
|
||||
|
||||
@@ -2,6 +2,7 @@ package xair
|
||||
|
||||
import "fmt"
|
||||
|
||||
// HeadAmp represents the headphone amplifier parameters of the mixer.
|
||||
type HeadAmp struct {
|
||||
client *client
|
||||
baseAddress string
|
||||
|
||||
@@ -2,6 +2,7 @@ package xair
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Main represents the main output parameters of the mixer.
|
||||
type Main struct {
|
||||
client *client
|
||||
baseAddress string
|
||||
@@ -11,7 +12,7 @@ type Main struct {
|
||||
|
||||
// newMainStereo creates a new Main instance for stereo main output.
|
||||
func newMainStereo(c *client) *Main {
|
||||
addressFunc := func(fmtString string, args ...any) string {
|
||||
addressFunc := func(fmtString string, _ ...any) string {
|
||||
return fmtString
|
||||
}
|
||||
|
||||
@@ -25,7 +26,7 @@ func newMainStereo(c *client) *Main {
|
||||
|
||||
// newMainMono creates a new MainMono instance for mono main output (X32 only).
|
||||
func newMainMono(c *client) *Main {
|
||||
addressFunc := func(fmtString string, args ...any) string {
|
||||
addressFunc := func(fmtString string, _ ...any) string {
|
||||
return fmtString
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package xair
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Matrix represents the matrix parameters of the mixer.
|
||||
type Matrix struct {
|
||||
client *client
|
||||
baseAddress string
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package xair
|
||||
|
||||
// InfoResponse represents the response from the /info OSC address, containing details about the X-Air device.
|
||||
type InfoResponse struct {
|
||||
Host string
|
||||
Name string
|
||||
|
||||
@@ -2,6 +2,7 @@ package xair
|
||||
|
||||
import "time"
|
||||
|
||||
// EngineOption defines a functional option for configuring the engine.
|
||||
type EngineOption func(*engine)
|
||||
|
||||
// WithTimeout sets the timeout duration for OSC message responses.
|
||||
@@ -11,6 +12,7 @@ func WithTimeout(timeout time.Duration) EngineOption {
|
||||
}
|
||||
}
|
||||
|
||||
// CompOption defines a functional option for configuring Comp parameters.
|
||||
type CompOption func(*Comp)
|
||||
|
||||
// WithCompAddressFunc allows customization of the OSC address formatting for Comp parameters.
|
||||
@@ -20,6 +22,7 @@ func WithCompAddressFunc(f func(fmtString string, args ...any) string) CompOptio
|
||||
}
|
||||
}
|
||||
|
||||
// EqOption defines a functional option for configuring Eq parameters.
|
||||
type EqOption func(*Eq)
|
||||
|
||||
// WithEqAddressFunc allows customization of the OSC address formatting for Eq parameters.
|
||||
@@ -29,6 +32,7 @@ func WithEqAddressFunc(f func(fmtString string, args ...any) string) EqOption {
|
||||
}
|
||||
}
|
||||
|
||||
// GateOption defines a functional option for configuring Gate parameters.
|
||||
type GateOption func(*Gate)
|
||||
|
||||
// WithGateAddressFunc allows customization of the OSC address formatting for Gate parameters.
|
||||
|
||||
@@ -16,7 +16,7 @@ func newParser() *xairParser {
|
||||
return &xairParser{}
|
||||
}
|
||||
|
||||
// parseOSCMessage parses raw bytes into an OSC message with improved error handling.
|
||||
// Parse parses raw bytes into an OSC message with improved error handling.
|
||||
func (p *xairParser) Parse(data []byte) (*osc.Message, error) {
|
||||
log.Debug("=== PARSING OSC MESSAGE BEGIN ===")
|
||||
defer log.Debug("=== PARSING OSC MESSAGE END ===")
|
||||
|
||||
@@ -2,6 +2,7 @@ package xair
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Snapshot represents a snapshot of the mixer's state, allowing for saving and recalling settings.
|
||||
type Snapshot struct {
|
||||
client *client
|
||||
baseAddress string
|
||||
|
||||
@@ -2,6 +2,7 @@ package xair
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Strip represents an input channel strip on the mixer.
|
||||
type Strip struct {
|
||||
client *client
|
||||
baseAddress string
|
||||
@@ -43,7 +44,7 @@ func (s *Strip) Mute(index int) (bool, error) {
|
||||
// SetMute sets the mute status of the specified strip (1-based indexing).
|
||||
func (s *Strip) SetMute(strip int, muted bool) error {
|
||||
address := fmt.Sprintf(s.baseAddress, strip) + "/mix/on"
|
||||
var value int32 = 0
|
||||
var value int32
|
||||
if !muted {
|
||||
value = 1
|
||||
}
|
||||
|
||||
@@ -2,20 +2,20 @@ package xair
|
||||
|
||||
import "math"
|
||||
|
||||
func linGet(min, max, value float64) float64 {
|
||||
return min + (max-min)*value
|
||||
func linGet(minVal, maxVal, value float64) float64 {
|
||||
return minVal + (maxVal-minVal)*value
|
||||
}
|
||||
|
||||
func linSet(min, max, value float64) float64 {
|
||||
return (value - min) / (max - min)
|
||||
func linSet(minVal, maxVal, value float64) float64 {
|
||||
return (value - minVal) / (maxVal - minVal)
|
||||
}
|
||||
|
||||
func logGet(min, max, value float64) float64 {
|
||||
return min * math.Exp(math.Log(max/min)*value)
|
||||
func logGet(minVal, maxVal, value float64) float64 {
|
||||
return minVal * math.Exp(math.Log(maxVal/minVal)*value)
|
||||
}
|
||||
|
||||
func logSet(min, max, value float64) float64 {
|
||||
return math.Log(value/min) / math.Log(max/min)
|
||||
func logSet(minVal, maxVal, value float64) float64 {
|
||||
return math.Log(value/minVal) / math.Log(maxVal/minVal)
|
||||
}
|
||||
|
||||
func mustDbInto(db float64) float64 {
|
||||
|
||||
Reference in New Issue
Block a user