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
}
