From d13f2873d53f615b2d497ab1e6d0fc12159a804a Mon Sep 17 00:00:00 2001 From: julian laplace Date: Tue, 9 May 2023 19:26:47 +0200 Subject: add controls --- src/relabi/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/relabi/index.js') 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] -- cgit v1.2.3-70-g09d2