Skip to content

Commit

Permalink
Make DAX RX gain configurable
Browse files Browse the repository at this point in the history
0-100, default is 50 (which is the same as FlexDAX).

It may be more desirable to tweak this with the new low-bandwidth mode
than it was when everything was float.
  • Loading branch information
arodland committed Jan 26, 2023
1 parent 13142b8 commit 892763d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var cfg struct {
LogLevel string
PacketBuffer int
HighBandwidth bool
Gain int
}

var audioCfg struct {
Expand All @@ -60,6 +61,7 @@ func init() {
flag.StringVar(&cfg.LogLevel, "log-level", "info", "minimum level of messages to log to console (trace, debug, info, warn, error)")
flag.IntVar(&cfg.PacketBuffer, "packet-buffer", 3, "Buffer n (max 6) packets against reordering and loss")
flag.BoolVar(&cfg.HighBandwidth, "high-bw", false, "Use high-bandwidth DAX transport (48kHz float32, 4x bandwidth)")
flag.IntVar(&cfg.Gain, "gain", 50, "DAX gain setting (0-100)")
}

var fc *flexclient.FlexClient
Expand Down Expand Up @@ -145,7 +147,7 @@ func enableDax() {
RXStreamID = res.Message
log.Info().Str("stream_id", RXStreamID).Msg("Enabled RX DAX stream")

fc.SendAndWait(fmt.Sprintf("audio stream 0x%s slice %s gain %d", RXStreamID, SliceIdx, 50))
fc.SendAndWait(fmt.Sprintf("audio stream 0x%s slice %s gain %d", RXStreamID, SliceIdx, cfg.Gain))

if cfg.TX {
res = fc.SendAndWait("stream create type=dax_tx" + cfg.DaxCh)
Expand Down Expand Up @@ -359,6 +361,10 @@ func main() {
log.Fatal().Msgf("-packet-buffer must be between 0 and 14")
}

if cfg.Gain < 0 || cfg.Gain > 100 {
log.Fatal().Msg("-gain must be between 0 and 100")
}

fc, err = flexclient.NewFlexClient(cfg.RadioIP)
if err != nil {
log.Fatal().Err(err).Msg("NewFlexClient failed")
Expand Down

0 comments on commit 892763d

Please sign in to comment.