Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danigb committed Sep 3, 2024
1 parent 386c9d4 commit 279b976
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
23 changes: 9 additions & 14 deletions packages/noise/src/__snapshots__/test.ts.snap
Original file line number Diff line number Diff line change
@@ -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",
},
]
`;
15 changes: 8 additions & 7 deletions packages/noise/src/test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { NoiseType } from "./dsp";

describe("NoiseWorkletNode", () => {
let NoiseWorklet: any;

Expand All @@ -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", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`ProcessorNode has parameter descriptors 1`] = `
"automationRate": "k-rate",
"defaultValue": 1000,
"maxValue": 20000,
"minValue": 16,
"minValue": 20,
"name": "frequency",
},
{
Expand Down
6 changes: 4 additions & 2 deletions site/content/docs/(sources)/noise.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Expand Down

0 comments on commit 279b976

Please sign in to comment.