From 5f49444cf7a681569823e0633551a56683636dd5 Mon Sep 17 00:00:00 2001 From: julian laplace Date: Tue, 9 May 2023 23:22:32 +0200 Subject: improving chaos --- src/relabi/index.js | 3 ++- src/ui/App.jsx | 8 ++++---- src/ui/Controls.jsx | 15 +++++++++++---- 3 files changed, 17 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/relabi/index.js b/src/relabi/index.js index 9e649f2..b77a83f 100644 --- a/src/relabi/index.js +++ b/src/relabi/index.js @@ -22,6 +22,7 @@ const WAVE_SHAPES = { square: (time) => (time % TWO_PI < Math.PI ? 1 : -1), saw: (time) => (time % TWO_PI) / Math.PI - 1, reverse_saw: (time) => 1 - (time % TWO_PI) / Math.PI, + noise: (time) => Math.random() * Math.random() * 2 - 1, }; /** @@ -94,7 +95,7 @@ export default class Relabi { const waveOffset = (wave.offset || 0) + (wave.frequency * this.settings.speed) / this.steps + - previousWaveValue * this.settings.feedback; + previousWaveValue * this.settings.chaos; const waveValue = WAVE_SHAPES[wave.shape](waveOffset); value += waveValue * wave.weight; diff --git a/src/ui/App.jsx b/src/ui/App.jsx index db3d762..a8edc0f 100644 --- a/src/ui/App.jsx +++ b/src/ui/App.jsx @@ -20,13 +20,13 @@ export default function App() { const relabiGenerator = new Relabi({ settings: { speed: 1.0, - feedback: 0.2, + chaos: 0.2, }, waves: [ - { shape: "sine", frequency: 0.75, weight: 1 }, + { shape: "sine", frequency: 0.5, weight: 1 }, { shape: "sine", frequency: 1.0, weight: 1 }, - { shape: "sine", frequency: 1.617, weight: 1 }, - { shape: "sine", frequency: 3.141, weight: 1 }, + { shape: "sine", frequency: 1.5, weight: 1 }, + { shape: "sine", frequency: 2.0, weight: 1 }, ], bounds: [ { diff --git a/src/ui/Controls.jsx b/src/ui/Controls.jsx index 3bc1c2e..e8dca45 100644 --- a/src/ui/Controls.jsx +++ b/src/ui/Controls.jsx @@ -10,7 +10,14 @@ import Slider from "rc-slider"; import TooltipSlider, { handleRender } from "./TooltipSlider.tsx"; import "rc-slider/assets/index.css"; -const WAVE_SHAPE_NAMES = ["sine", "triangle", "saw", "reverse_saw", "square"]; +const WAVE_SHAPE_NAMES = [ + "sine", + "triangle", + "saw", + "reverse_saw", + "square", + "noise", +]; export default function Controls({ relabi }) { /** @@ -130,7 +137,7 @@ export default function Controls({ relabi }) { type="settings" index="speed" onChange={onChange} - min={-2} + min={-3} max={3} step={0.01} defaultValue={Math.log(relabi.settings.speed)} @@ -145,12 +152,12 @@ export default function Controls({ relabi }) { -- cgit v1.2.3-70-g09d2