Skip to content

Commit

Permalink
Feat: PolyBLEP oscillator (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
danigb authored Jul 27, 2024
1 parent c65e4d4 commit 5a0a49c
Show file tree
Hide file tree
Showing 20 changed files with 874 additions and 19 deletions.
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ Collection of synth modules implemented as AudioWorklets.
```ts
import {
registerSynthletOnce,
createAdsr,
createWavetableOscillator,
createVca,
createStateVariableFilter
createPolyblepOscillator,
} from "synthlet";

const audioContext = new AudioContext();
await registerSynthletOnce(audioContext);

// Simplest synth: Oscillator -> Filter -> Amplifier
const osc = createWavetableOscillator(audioContext);
const filter = createStateVariableFilter(audioContext);
const vca = createVca(audioContext);
const osc = createPolyblepOscillator(audioContext, { type: "saw", frequency: 440 });
const filter = createStateVariableFilter(audioContext, { type: "lowpass", frequency: 4000 });
const vca = createVca(audioContext, { attack: 0.1, release: 0.5 });

osc.connect(filter).connect(vca).connect(audioContext.destination);

Expand All @@ -44,7 +45,21 @@ npm i @synthlet/adsr

## Documentation

- [ADSR](/packages/adsr)
#### Oscillators

- [PolyblepOscillator](/packages/polyblep-oscilllator)
- [WavetableOscillator](/packages/wavetable-oscilllator)
- [Noise](/packages/noise)

#### Envelopes

- [ADSR](/packages/adsr)

#### Modulators

- [StateVariableFilter](/packages/state-variable-filter)
- [WavetableOscillator](/packages/wavetable-oscilllator)

## References

- https://github.com/BillyDM/awesome-audio-dsp
- https://paulbatchelor.github.io/sndkit/algos/
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/adsr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export function createAdsr(
audioContext: AudioContext,
params?: Partial<AdsrParams>
): AudioWorkletNode {
return createWorkletNode(audioContext, { mode: "generator" });
return createWorkletNode(audioContext, { mode: "generator" }, params);
}

function createWorkletNode(
Expand Down
4 changes: 1 addition & 3 deletions packages/noise/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
> Noise generator module for [synthlet](https://github.com/danigb/synthlet)
```ts
import { registerNoiseWorkletOnce, createWhiteNoise } from "@synthlet/adsr";
import { registerNoiseWorkletOnce, createWhiteNoise } from "@synthlet/noise";

const audioContext = new AudioContext();

await registerNoiseWorkletOnce(audioContext);

// Create a VCA (Voltage Controlled Amplifier)
const noise = createWhiteNoise();
// Connect the noise to the output
noise.connect(audioContext.destination);
```

Expand Down
22 changes: 22 additions & 0 deletions packages/polyblep-oscillator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# @synthlet/polyblep-oscillator

> An Oscillator module implemented with PolyBLEP algorithm for [synthlet](https://github.com/danigb/synthlet)
An oscillator implemented using the PolyBLEP (Polynomial Band-limited Step Functions -Valimaki et. al 2010) algorithm.

```js
import {} from "@synthlet/polyblep-oscillator";
```

## Install

```bash
npm i @synthlet/polyblep-oscillator
```

## References

- https://paulbatchelor.github.io/sndkit/blep/
- https://www.martin-finke.de/articles/audio-plugins-018-polyblep-oscillator/
- https://www.metafunction.co.uk/post/all-about-digital-oscillators-part-2-blits-bleps
- https://github.com/cmajor-lang/cmajor/blob/main/standard_library/std_library_oscillators.cmajor
36 changes: 36 additions & 0 deletions packages/polyblep-oscillator/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@synthlet/polyblep-oscillator",
"version": "0.1.0",
"description": "PolyBLEP Oscillator module for synthlet",
"keywords": [
"modular",
"synthesizer",
"poly-blep",
"oscillator",
"synthlet"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"author": "[email protected]",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@types/jest": "^29.5.11",
"jest": "^29.7.0",
"ts-jest": "^29.1.1"
},
"jest": {
"preset": "ts-jest"
},
"scripts": {
"worklet": "esbuild src/worklet.ts --bundle --minify | sed -e 's/^/export const PROCESSOR = \\`/' -e 's/$/\\`;/' > src/processor.ts",
"lib": "tsup src/index.ts --sourcemap --dts --format esm,cjs",
"build": "npm run worklet && npm run lib"
}
}
Loading

0 comments on commit 5a0a49c

Please sign in to comment.