sawtooth wave

This commit is contained in:
legop3
2026-01-31 12:30:21 -05:00
parent 43dc3df901
commit 92ab763b27
4 changed files with 5 additions and 1 deletions
BIN
View File
Binary file not shown.
Vendored
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+5 -1
View File
@@ -144,7 +144,7 @@ func synthChord(writer *bufio.Writer, freqs []float64, rate, channels int, durat
env := envelope(sampleIndex, attackFrames, steadyFrames, releaseFrames)
sample := 0.0
for j := range freqs {
sample += math.Sin(phase[j])
sample += sawFromPhase(phase[j])
phase[j] += increment[j]
if phase[j] > twoPi {
phase[j] -= twoPi
@@ -181,3 +181,7 @@ func envelope(sampleIndex, attackFrames, steadyFrames, releaseFrames int) float6
}
return 1.0
}
func sawFromPhase(phase float64) float64 {
return 2.0*(phase/twoPi) - 1.0
}