diff options
| author | julian laplace <julescarbon@gmail.com> | 2023-05-09 19:26:47 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2023-05-09 19:26:47 +0200 |
| commit | d13f2873d53f615b2d497ab1e6d0fc12159a804a (patch) | |
| tree | fdd0e6e11f57537d1236bfa3cf361adbcf0d77a3 /src/relabi/index.js | |
| parent | 72b3b1fff01bcd20b3a79144d02455dfc9d6367a (diff) | |
add controls
Diffstat (limited to 'src/relabi/index.js')
| -rw-r--r-- | src/relabi/index.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/relabi/index.js b/src/relabi/index.js index 89e4ce9..8e23d2a 100644 --- a/src/relabi/index.js +++ b/src/relabi/index.js @@ -10,7 +10,7 @@ const TWO_PI = 2 * Math.PI; /** * Wave functions */ -const WAVE_FUNCTIONS = { +const WAVE_SHAPES = { sine: Math.cos, triangle: (time) => (4 / TWO_PI) * @@ -33,10 +33,10 @@ export default class Relabi { this.updateTime = 1; this.steps = 50; this.waves = waves || [ - { type: "triangle", frequency: randrange(0.5, 1.5) }, - { type: "triangle", frequency: randrange(0.75, 2.25) }, - { type: "triangle", frequency: randrange(1, 3) }, - { type: "triangle", frequency: randrange(2, 4) }, + { shape: "triangle", frequency: randrange(0.5, 1.5) }, + { shape: "triangle", frequency: randrange(0.75, 2.25) }, + { shape: "triangle", frequency: randrange(1, 3) }, + { shape: "triangle", frequency: randrange(2, 4) }, ]; this.bounds = bounds; this.previousValue = null; @@ -91,7 +91,7 @@ export default class Relabi { // Compute the wave functions for this event for (index = 0; index < waveCount; index += 1) { const wave = this.waves[index]; - value += WAVE_FUNCTIONS[wave.type](timeOffset * wave.frequency); + value += WAVE_SHAPES[wave.shape](timeOffset * wave.frequency); } // Scale to [-1, 1] |
