mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
sine and saw volumes
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -50,6 +50,8 @@ horn:
|
||||
volume: 0.25
|
||||
sampleRate: 48000
|
||||
channels: 1
|
||||
sineGain: 1.0
|
||||
sawGain: 0.7
|
||||
nightVision:
|
||||
enabled: true
|
||||
gpioPin: 22
|
||||
|
||||
Reference in New Issue
Block a user