-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuiltin_caches.go
32 lines (26 loc) · 971 Bytes
/
builtin_caches.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package gotes
// This file contains some internal cache values that are used in wave
// functions. Generally, they are all caches of "pure wave functions"
// that are used with frequency to optimize performance.
var (
pianoWaveCache = MakeCache(BasicPianoFn, DefaultCacheSize)
sinWaveCache = MakeCache(BasicSinFn, DefaultCacheSize)
squareWaveCache = MakeCache(BasicSquareFn, DefaultCacheSize)
triangleWaveCache = MakeCache(BasicTriangleFn, DefaultCacheSize)
sawWaveCache = MakeCache(BasicSawFn, DefaultCacheSize)
)
func lookupPiano(t float64) float64 {
return CacheInterpolateLookup(pianoWaveCache, t)
}
func lookupSin(t float64) float64 {
return CacheDirectLookup(sinWaveCache, t)
}
func lookupSquare(t float64) float64 {
return CacheDirectLookup(squareWaveCache, t)
}
func lookupTriangle(t float64) float64 {
return CacheDirectLookup(triangleWaveCache, t)
}
func lookupSaw(t float64) float64 {
return CacheDirectLookup(sawWaveCache, t)
}