mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
sawtooth wave
This commit is contained in:
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user