feat(05-01): wire waveform resolution into NewLayer at construction time
- NewLayer resolves WaveformPresetHarmonics when cfg.WaveformType != WaveformCustom
- Preset harmonics stored in Layer.Config so AdvanceSample uses them unchanged
- WaveformCustom path preserves existing hand-tuned harmonics (backward compatible)
- TestNewLayerResolvesWaveformPreset: verifies preset fills harmonics on construction
- TestNewLayerPreservesCustomHarmonics: verifies hand-tuned harmonics are untouched
- TestSineRegressionVsCustomHarmonics: verifies WaveformSine == {Ratio:1,Amp:1.0}
- All 41 synth tests pass, encode tests unaffected
This commit is contained in:
@@ -20,7 +20,11 @@ type Layer struct {
|
||||
}
|
||||
|
||||
// NewLayer creates a Layer for the given config using the specified sample rate and EMA time constant (tau in seconds).
|
||||
// If cfg.WaveformType is not WaveformCustom, harmonics are resolved from the preset at construction time.
|
||||
func NewLayer(cfg FreqConfig, sampleRate int, tau float64) *Layer {
|
||||
if cfg.WaveformType != WaveformCustom {
|
||||
cfg.Harmonics = WaveformPresetHarmonics(cfg.WaveformType, cfg.BaseHz, sampleRate)
|
||||
}
|
||||
return &Layer{
|
||||
Config: cfg,
|
||||
Osc: NewOscillator(cfg.BaseHz, sampleRate),
|
||||
|
||||
Reference in New Issue
Block a user