sine and saw volumes

This commit is contained in:
legop3
2026-01-31 15:45:36 -05:00
parent 5916520b1a
commit 92c9ae4834
6 changed files with 17 additions and 0 deletions
BIN
View File
Binary file not shown.
Vendored
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+10
View File
@@ -71,6 +71,8 @@ type HornConfig struct {
SampleRate int `yaml:"sampleRate" json:"-"`
Channels int `yaml:"channels" json:"-"`
Device string `yaml:"device" json:"-"`
SineGain float64 `yaml:"sineGain" json:"-"`
SawGain float64 `yaml:"sawGain" json:"-"`
}
type MediaConfig struct {
@@ -174,6 +176,8 @@ func LoadConfig(path string) (*Config, error) {
Volume: 0.25,
SampleRate: 48000,
Channels: 1,
SineGain: 1.0,
SawGain: 0.7,
},
NightVision: NightVisionConfig{
Enabled: true,
@@ -320,6 +324,12 @@ func validateHornConfig(cfg *HornConfig) {
if cfg.Channels <= 0 {
cfg.Channels = 1
}
if cfg.SineGain <= 0 {
cfg.SineGain = 1.0
}
if cfg.SawGain <= 0 {
cfg.SawGain = 0.7
}
}
func validateNightVisionConfig(cfg *NightVisionConfig) error {
+5
View File
@@ -162,6 +162,11 @@ func (h *HornSynth) synthLoop(writer *bufio.Writer, waveform string, freqs []flo
framesPerChunk := 512
buf := make([]byte, framesPerChunk*channels*2)
scale := volume / float64(len(freqs))
if waveform == "sine" {
scale *= h.cfg.SineGain
} else {
scale *= h.cfg.SawGain
}
stopRequested := false
releaseStart := -1
+2
View File
@@ -50,6 +50,8 @@ horn:
volume: 0.25
sampleRate: 48000
channels: 1
sineGain: 1.0
sawGain: 0.7
nightVision:
enabled: true
gpioPin: 22