Experimental changes, switched to toml instead of yaml. Hopefully everyone will like this as much as I do.

This commit is contained in:
Storm Dragon
2025-12-10 20:52:37 -05:00
parent bb80b13c36
commit dd425563ba
6 changed files with 31 additions and 18 deletions
+8 -8
View File
@@ -33,7 +33,7 @@ Barnard includes real-time voice effects that can be applied to your outgoing mi
### Controls ### Controls
- **F12 key**: Cycle through voice effects (configurable hotkey) - **F12 key**: Cycle through voice effects (configurable hotkey)
- **Configuration**: Your selected effect is saved in `~/.barnard.yaml` - **Configuration**: Your selected effect is saved in `~/.barnard.toml`
### How It Works ### How It Works
Voice effects are applied to your outgoing audio in real-time, after noise suppression and automatic gain control. The effects use various digital signal processing techniques including delay lines, pitch shifting with cubic interpolation, and ring modulation. Voice effects are applied to your outgoing audio in real-time, after noise suppression and automatic gain control. The effects use various digital signal processing techniques including delay lines, pitch shifting with cubic interpolation, and ring modulation.
@@ -52,12 +52,12 @@ Barnard includes real-time noise suppression for microphone input to filter out
- **F9 key**: Toggle noise suppression on/off (configurable hotkey) - **F9 key**: Toggle noise suppression on/off (configurable hotkey)
- **Command line**: Use `--noise-suppression` flag to enable at startup - **Command line**: Use `--noise-suppression` flag to enable at startup
- **FIFO command**: Send `noise` command to toggle during runtime - **FIFO command**: Send `noise` command to toggle during runtime
- **Configuration**: Set `noisesuppressionenabled` and `noisesuppressionthreshold` in `~/.barnard.yaml` - **Configuration**: Set `noisesuppressionenabled` and `noisesuppressionthreshold` in `~/.barnard.toml`
### Configuration Example ### Configuration Example
```yaml ```toml
noisesuppressionenabled: true noisesuppressionenabled = true
noisesuppressionthreshold: 0.02 noisesuppressionthreshold = 0.02
``` ```
The noise suppression algorithm uses a combination of high-pass filtering and noise gating to reduce unwanted background sounds while preserving voice quality. The noise suppression algorithm uses a combination of high-pass filtering and noise gating to reduce unwanted background sounds while preserving voice quality.
@@ -124,8 +124,8 @@ Our thanks go out to Tim Cooper for the massive amount of work put into this cli
## Config ## Config
By default, the file $HOME/.barnard.yaml will hold the configuration for Barnard. By default, the file $HOME/.barnard.toml will hold the configuration for Barnard.
You can have barnard read another file by using the -c option, like `./barnard -c ~/.anotherbarnard.yaml`. You can have barnard read another file by using the -c option, like `./barnard -c ~/.anotherbarnard.toml`.
It will be created automatically if it doesn't exist. It will be created automatically if it doesn't exist.
If you modify the config file while Barnard is running, your changes may be overwritten. If you modify the config file while Barnard is running, your changes may be overwritten.
@@ -169,7 +169,7 @@ If Jim's volume is set to 0.1, and larry's volume is set to 0.9, lowering the ch
You can change the volume for a user once that user has spoken at least once during a session. You can change the volume for a user once that user has spoken at least once during a session.
Attempts to change the volume of a user who has not spoken will be ignored. Attempts to change the volume of a user who has not spoken will be ignored.
If you are unable to hear a user speaking, you can edit the .barnard.yaml file in your home directory, after closing Barnard, and set the volume parameter to 1.0 for a particular user. If you are unable to hear a user speaking, you can edit the .barnard.toml file in your home directory, after closing Barnard, and set the volume parameter to 1.0 for a particular user.
### Technical ### Technical
+4 -4
View File
@@ -3,7 +3,7 @@ package config
import ( import (
"fmt" "fmt"
"git.stormux.org/storm/barnard/uiterm" "git.stormux.org/storm/barnard/uiterm"
"gopkg.in/yaml.v2" "github.com/pelletier/go-toml/v2"
"git.stormux.org/storm/barnard/gumble/gumble" "git.stormux.org/storm/barnard/gumble/gumble"
"io/ioutil" "io/ioutil"
"os" "os"
@@ -46,7 +46,7 @@ type eUser struct {
func (c *Config) SaveConfig() { func (c *Config) SaveConfig() {
var data []byte var data []byte
data, err := yaml.Marshal(c.config) data, err := toml.Marshal(c.config)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -85,7 +85,7 @@ func (c *Config) LoadConfig() {
var data []byte var data []byte
data = readFile(c.fn) data = readFile(c.fn)
if data != nil { if data != nil {
err := yaml.UnmarshalStrict(data, &jc) err := toml.Unmarshal(data, &jc)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "Error parsing \"%s\".\n%s\n", c.fn, err.Error()) fmt.Fprintf(os.Stderr, "Error parsing \"%s\".\n%s\n", c.fn, err.Error())
os.Exit(1) os.Exit(1)
@@ -114,7 +114,7 @@ func (c *Config) LoadConfig() {
jc.Username = &username jc.Username = &username
} }
if c.config.NotifyCommand == nil { if c.config.NotifyCommand == nil {
ncmd := string("") ncmd := string("/usr/share/barnard/barnard-sound.sh \"%event\" \"%who\" \"%what\"")
jc.NotifyCommand = &ncmd jc.NotifyCommand = &ncmd
} }
if c.config.NoiseSuppressionEnabled == nil { if c.config.NoiseSuppressionEnabled == nil {
+1 -1
View File
@@ -7,7 +7,7 @@ require (
github.com/golang/protobuf v1.5.3 github.com/golang/protobuf v1.5.3
github.com/kennygrant/sanitize v1.2.4 github.com/kennygrant/sanitize v1.2.4
github.com/nsf/termbox-go v1.1.1 github.com/nsf/termbox-go v1.1.1
gopkg.in/yaml.v2 v2.4.0 github.com/pelletier/go-toml/v2 v2.2.4
) )
require ( require (
+2 -4
View File
@@ -11,6 +11,8 @@ github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/Qd
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/nsf/termbox-go v1.1.1 h1:nksUPLCb73Q++DwbYUBEglYBRPZyoXJdrj5L+TkjyZY= github.com/nsf/termbox-go v1.1.1 h1:nksUPLCb73Q++DwbYUBEglYBRPZyoXJdrj5L+TkjyZY=
github.com/nsf/termbox-go v1.1.1/go.mod h1:T0cTdVuOwf7pHQNtfhnEbzHbcNyCEcVU4YPpouCbVxo= github.com/nsf/termbox-go v1.1.1/go.mod h1:T0cTdVuOwf7pHQNtfhnEbzHbcNyCEcVU4YPpouCbVxo=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
@@ -18,7 +20,3 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+1 -1
View File
@@ -108,7 +108,7 @@ func main() {
password := flag.String("password", "", "the password of the server") password := flag.String("password", "", "the password of the server")
insecure := flag.Bool("insecure", false, "skip server certificate verification") insecure := flag.Bool("insecure", false, "skip server certificate verification")
certificate := flag.String("certificate", "", "PEM encoded certificate and private key") certificate := flag.String("certificate", "", "PEM encoded certificate and private key")
cfgfn := flag.String("config", "~/.barnard.yaml", "Path to YAML formatted configuration file") cfgfn := flag.String("config", "~/.barnard.toml", "Path to TOML formatted configuration file")
list_devices := flag.Bool("list_devices", false, "do not connect; instead, list available audio devices and exit") list_devices := flag.Bool("list_devices", false, "do not connect; instead, list available audio devices and exit")
fifo := flag.String("fifo", "", "path of a FIFO from which to read commands") fifo := flag.String("fifo", "", "path of a FIFO from which to read commands")
serverSet := false serverSet := false
+15
View File
@@ -0,0 +1,15 @@
package uiterm
// MarshalText implements the encoding.TextMarshaler interface for Key
// This allows TOML to serialize Key values as strings
func (i Key) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface for Key
// This allows TOML to deserialize strings back into Key values
func (i *Key) UnmarshalText(data []byte) error {
var err error
*i, err = KeyString(string(data))
return err
}