migrate CLI component to Kong

This commit is contained in:
2026-02-05 03:36:22 +00:00
parent 49cf3ff49e
commit 128f0c1df6
20 changed files with 1624 additions and 3040 deletions

View File

@@ -74,8 +74,8 @@ func (c *Client) StartListening() {
log.Debugf("Started listening on %s...", c.engine.conn.LocalAddr().String())
}
// Stop stops the client and closes the connection
func (c *Client) Stop() {
// Close stops the client and closes the connection
func (c *Client) Close() {
close(c.engine.done)
if c.engine.conn != nil {
c.engine.conn.Close()
@@ -102,10 +102,10 @@ func (c *Client) ReceiveMessage(timeout time.Duration) (*osc.Message, error) {
}
// RequestInfo requests mixer information
func (c *Client) RequestInfo() (error, InfoResponse) {
func (c *Client) RequestInfo() (InfoResponse, error) {
err := c.SendMessage("/xinfo")
if err != nil {
return err, InfoResponse{}
return InfoResponse{}, err
}
val := <-c.respChan
@@ -115,7 +115,7 @@ func (c *Client) RequestInfo() (error, InfoResponse) {
info.Name = val.Arguments[1].(string)
info.Model = val.Arguments[2].(string)
}
return nil, info
return info, nil
}
// KeepAlive sends keep-alive message (required for multi-client usage)

View File

@@ -189,8 +189,8 @@ func (c *Comp) SetRelease(index int, release float64) error {
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) {
// Makeup retrieves the makeup 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 {
@@ -200,15 +200,15 @@ func (c *Comp) MakeUp(index int) (float64, error) {
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 0, fmt.Errorf("unexpected argument type for Compressor makeup 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 {
// SetMakeup sets the makeup 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)))
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).

View File

@@ -49,24 +49,27 @@ func (e *Eq) SetOn(index int, on bool) error {
return e.client.SendMessage(address, value)
}
func (e *Eq) Mode(index int) (int, error) {
func (e *Eq) Mode(index int) (string, error) {
address := fmt.Sprintf(e.baseAddress, index) + "/eq/mode"
err := e.client.SendMessage(address)
if err != nil {
return 0, err
return "", err
}
possibleModes := []string{"peq", "geq", "teq"}
resp := <-e.client.respChan
val, ok := resp.Arguments[0].(int32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for EQ mode value")
return "", fmt.Errorf("unexpected argument type for EQ mode value")
}
return int(val), nil
return possibleModes[val], nil
}
func (e *Eq) SetMode(index int, mode int) error {
func (e *Eq) SetMode(index int, mode string) error {
address := fmt.Sprintf(e.baseAddress, index) + "/eq/mode"
return e.client.SendMessage(address, int32(mode))
possibleModes := []string{"peq", "geq", "teq"}
return e.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
}
// Gain retrieves the gain for a specific EQ band on a strip or bus (1-based indexing).
@@ -136,23 +139,26 @@ func (e *Eq) SetQ(index int, band int, q float64) error {
}
// Type retrieves the type for a specific EQ band on a strip or bus (1-based indexing).
func (e *Eq) Type(index int, band int) (int, error) {
func (e *Eq) Type(index int, band int) (string, error) {
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
err := e.client.SendMessage(address)
if err != nil {
return 0, err
return "", err
}
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
resp := <-e.client.respChan
val, ok := resp.Arguments[0].(int32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for EQ type value")
return "", fmt.Errorf("unexpected argument type for EQ type value")
}
return int(val), nil
return possibleTypes[val], nil
}
// SetType sets the type for a specific EQ band on a strip or bus (1-based indexing).
func (e *Eq) SetType(index int, band int, eqType int) error {
func (e *Eq) SetType(index int, band int, eqType string) error {
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
return e.client.SendMessage(address, int32(eqType))
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
return e.client.SendMessage(address, int32(indexOf(possibleTypes, eqType)))
}