From 279b976aac3388a1a12009cc914d146f069a1ca1 Mon Sep 17 00:00:00 2001 From: danigb Date: Tue, 3 Sep 2024 20:42:40 +0200 Subject: [PATCH] fix: tests --- packages/noise/src/__snapshots__/test.ts.snap | 23 ++++++++----------- packages/noise/src/test.ts | 15 ++++++------ .../src/__snapshots__/worklet.test.ts.snap | 2 +- site/content/docs/(sources)/noise.mdx | 6 +++-- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/packages/noise/src/__snapshots__/test.ts.snap b/packages/noise/src/__snapshots__/test.ts.snap index dcdc826..071d918 100644 --- a/packages/noise/src/__snapshots__/test.ts.snap +++ b/packages/noise/src/__snapshots__/test.ts.snap @@ -1,18 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`NoiseWorkletNode has parameter descriptors 1`] = `[]`; - -exports[`NoiseWorkletNode is generates audio 1`] = ` -Float32Array [ - -0.800000011920929, - -0.6000000238418579, - -0.4000000059604645, - -0.20000000298023224, - 0, - 0.20000000298023224, - 0.4000000059604645, - 0.6000000238418579, - 0.800000011920929, - 1, +exports[`NoiseWorkletNode has parameter descriptors 1`] = ` +[ + { + "automationRate": "k-rate", + "defaultValue": 0, + "maxValue": 100, + "minValue": 0, + "name": "type", + }, ] `; diff --git a/packages/noise/src/test.ts b/packages/noise/src/test.ts index df44374..a2991c1 100644 --- a/packages/noise/src/test.ts +++ b/packages/noise/src/test.ts @@ -1,3 +1,5 @@ +import { NoiseType } from "./dsp"; + describe("NoiseWorkletNode", () => { let NoiseWorklet: any; @@ -14,14 +16,13 @@ describe("NoiseWorkletNode", () => { }); it("is generates audio", () => { - let i = 0; - Math.random = () => { - i++; - return i / 10; - }; const node = new NoiseWorklet(); - const output = runProcessMono(node, 10); - expect(output).toMatchSnapshot(); + let output = runProcessMono(node, 10, { type: [NoiseType.WHITE_RND] }); + let sum = output.reduce((sum, value) => sum + value, 0); + expect(sum).not.toBe(0); + output = runProcessMono(node, 10, { type: [NoiseType.PINK_TRAMMEL] }); + sum = output.reduce((sum, value) => sum + value, 0); + expect(sum).not.toBe(0); }); it("has parameter descriptors", () => { diff --git a/packages/state-variable-filter/src/__snapshots__/worklet.test.ts.snap b/packages/state-variable-filter/src/__snapshots__/worklet.test.ts.snap index db29664..a6cf73c 100644 --- a/packages/state-variable-filter/src/__snapshots__/worklet.test.ts.snap +++ b/packages/state-variable-filter/src/__snapshots__/worklet.test.ts.snap @@ -13,7 +13,7 @@ exports[`ProcessorNode has parameter descriptors 1`] = ` "automationRate": "k-rate", "defaultValue": 1000, "maxValue": 20000, - "minValue": 16, + "minValue": 20, "name": "frequency", }, { diff --git a/site/content/docs/(sources)/noise.mdx b/site/content/docs/(sources)/noise.mdx index 3c9e2e3..422b71b 100644 --- a/site/content/docs/(sources)/noise.mdx +++ b/site/content/docs/(sources)/noise.mdx @@ -3,9 +3,11 @@ title: Noise description: Noise --- +`@synthlet/noise` + import { NoiseExample } from "../../../examples/NoiseExample"; -A Noise generator. Currently only white and pink noise are supported. +A Noise generator. Currently white and pink noise are supported. ```ts import { registerNoiseWorkletOnce, createNoiseNode, NoiseType } from "synthlet"; @@ -19,7 +21,7 @@ const noise = createNoiseNode(audioContext, { noise.connect(audioContext.destination); // Change the algorithm -noise.type.value = NoiseType.PINK_COOPER; +noise.type.value = NoiseType.PINK_TRAMMEL; ``` ## Example