Skip to content

Commit

Permalink
Add in a --gain flag for fm(1)
Browse files Browse the repository at this point in the history
This comes in hot a lot of times, the default ought to be a bit lower.
  • Loading branch information
paultag committed Jul 16, 2023
1 parent 815ea50 commit 72ef728
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fm/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ var rootCmd = &cobra.Command{
return err
}

gain, err := cmd.Flags().GetFloat32("gain")
if err != nil {
return err
}

downsample, err := cmd.Flags().GetUint("downsample")
if err != nil {
return err
Expand Down Expand Up @@ -117,6 +122,9 @@ var rootCmd = &cobra.Command{
if i == 0 {
panic("zero read")
}
for j := 0; j < i; j++ {
buf[j] *= gain
}
if err := speaker.Write(buf[:i]); err != nil {
return err
}
Expand All @@ -140,6 +148,7 @@ func init() {
flags.String("bandwidth", "broadcast", "Bandwidth for the fm signal [broadcast|narrowband|<hz>]")
flags.Uint("downsample", 8, "Samples to downsample for audio playback")
flags.String("sink-name", "", "pulseaudio sink name")
flags.Float32("gain", 0.75, "amount of gain on the signal")

cli.RegisterSDRFlags(rootCmd)
}
Expand Down

0 comments on commit 72ef728

Please sign in to comment.