mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-17 10:00:46 -04:00
sine and saw volumes
This commit is contained in:
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -71,6 +71,8 @@ type HornConfig struct {
|
|||||||
SampleRate int `yaml:"sampleRate" json:"-"`
|
SampleRate int `yaml:"sampleRate" json:"-"`
|
||||||
Channels int `yaml:"channels" json:"-"`
|
Channels int `yaml:"channels" json:"-"`
|
||||||
Device string `yaml:"device" json:"-"`
|
Device string `yaml:"device" json:"-"`
|
||||||
|
SineGain float64 `yaml:"sineGain" json:"-"`
|
||||||
|
SawGain float64 `yaml:"sawGain" json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MediaConfig struct {
|
type MediaConfig struct {
|
||||||
@@ -174,6 +176,8 @@ func LoadConfig(path string) (*Config, error) {
|
|||||||
Volume: 0.25,
|
Volume: 0.25,
|
||||||
SampleRate: 48000,
|
SampleRate: 48000,
|
||||||
Channels: 1,
|
Channels: 1,
|
||||||
|
SineGain: 1.0,
|
||||||
|
SawGain: 0.7,
|
||||||
},
|
},
|
||||||
NightVision: NightVisionConfig{
|
NightVision: NightVisionConfig{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
@@ -320,6 +324,12 @@ func validateHornConfig(cfg *HornConfig) {
|
|||||||
if cfg.Channels <= 0 {
|
if cfg.Channels <= 0 {
|
||||||
cfg.Channels = 1
|
cfg.Channels = 1
|
||||||
}
|
}
|
||||||
|
if cfg.SineGain <= 0 {
|
||||||
|
cfg.SineGain = 1.0
|
||||||
|
}
|
||||||
|
if cfg.SawGain <= 0 {
|
||||||
|
cfg.SawGain = 0.7
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateNightVisionConfig(cfg *NightVisionConfig) error {
|
func validateNightVisionConfig(cfg *NightVisionConfig) error {
|
||||||
|
|||||||
@@ -162,6 +162,11 @@ func (h *HornSynth) synthLoop(writer *bufio.Writer, waveform string, freqs []flo
|
|||||||
framesPerChunk := 512
|
framesPerChunk := 512
|
||||||
buf := make([]byte, framesPerChunk*channels*2)
|
buf := make([]byte, framesPerChunk*channels*2)
|
||||||
scale := volume / float64(len(freqs))
|
scale := volume / float64(len(freqs))
|
||||||
|
if waveform == "sine" {
|
||||||
|
scale *= h.cfg.SineGain
|
||||||
|
} else {
|
||||||
|
scale *= h.cfg.SawGain
|
||||||
|
}
|
||||||
|
|
||||||
stopRequested := false
|
stopRequested := false
|
||||||
releaseStart := -1
|
releaseStart := -1
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ horn:
|
|||||||
volume: 0.25
|
volume: 0.25
|
||||||
sampleRate: 48000
|
sampleRate: 48000
|
||||||
channels: 1
|
channels: 1
|
||||||
|
sineGain: 1.0
|
||||||
|
sawGain: 0.7
|
||||||
nightVision:
|
nightVision:
|
||||||
enabled: true
|
enabled: true
|
||||||
gpioPin: 22
|
gpioPin: 22
|
||||||
|
|||||||
Reference in New Issue
Block a user