automated snapshot

This commit is contained in:
sumi
2025-12-15 22:29:06 -06:00
parent 80b59f4e82
commit 73c0471d54
3 changed files with 195 additions and 110 deletions

28
signals.go Normal file
View File

@@ -0,0 +1,28 @@
package main
import (
"math"
)
type Signal interface {
Eval(t float64) float64
}
type Const struct{ V float64 }
func (s Const) Eval(t float64) float64 { return s.V }
type Sine struct {
Amp, Freq, Phase, Bias float64
}
func (s Sine) Eval(t float64) float64 {
return s.Bias + s.Amp*math.Sin(2*math.Pi*s.Freq*t+s.Phase)
}
type Saw struct {
Min, Max, Period float64
}
func (s Saw) Eval(t float64) float64 {
u := math.Mod(t, s.Period) / s.Period // 0..1
return s.Min + (s.Max-s.Min)*u
}