|
|
|
@@ -15,9 +15,12 @@ type Config struct { |
|
|
|
} |
|
|
|
|
|
|
|
type AudioConfig struct { |
|
|
|
InputPath string `json:"inputPath"` |
|
|
|
SampleRate int `json:"sampleRate"` |
|
|
|
Gain float64 `json:"gain"` |
|
|
|
InputPath string `json:"inputPath"` |
|
|
|
SampleRate int `json:"sampleRate"` |
|
|
|
Gain float64 `json:"gain"` |
|
|
|
ToneLeftHz float64 `json:"toneLeftHz"` |
|
|
|
ToneRightHz float64 `json:"toneRightHz"` |
|
|
|
ToneAmplitude float64 `json:"toneAmplitude"` |
|
|
|
} |
|
|
|
|
|
|
|
type RDSConfig struct { |
|
|
|
@@ -50,7 +53,7 @@ type ControlConfig struct { |
|
|
|
|
|
|
|
func Default() Config { |
|
|
|
return Config{ |
|
|
|
Audio: AudioConfig{SampleRate: 48000, Gain: 1.0}, |
|
|
|
Audio: AudioConfig{SampleRate: 48000, Gain: 1.0, ToneLeftHz: 1000, ToneRightHz: 1600, ToneAmplitude: 0.4}, |
|
|
|
RDS: RDSConfig{Enabled: true, PI: "1234", PS: "FMRTX", RadioText: "fm-rds-tx", PTY: 0}, |
|
|
|
FM: FMConfig{FrequencyMHz: 100.0, StereoEnabled: true, PilotLevel: 0.1, RDSInjection: 0.03, OutputDrive: 0.5, CompositeRateHz: 228000}, |
|
|
|
Backend: BackendConfig{Kind: "file", OutputPath: "build/out/composite.f32"}, |
|
|
|
@@ -80,6 +83,12 @@ func (c Config) Validate() error { |
|
|
|
if c.Audio.Gain < 0 || c.Audio.Gain > 4 { |
|
|
|
return fmt.Errorf("audio.gain out of range") |
|
|
|
} |
|
|
|
if c.Audio.ToneLeftHz <= 0 || c.Audio.ToneRightHz <= 0 { |
|
|
|
return fmt.Errorf("audio tone frequencies must be positive") |
|
|
|
} |
|
|
|
if c.Audio.ToneAmplitude < 0 || c.Audio.ToneAmplitude > 1 { |
|
|
|
return fmt.Errorf("audio.toneAmplitude out of range") |
|
|
|
} |
|
|
|
if c.FM.FrequencyMHz < 65 || c.FM.FrequencyMHz > 110 { |
|
|
|
return fmt.Errorf("fm.frequencyMHz out of range") |
|
|
|
} |
|
|
|
|