Skip to content

danigb/synthlet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1dd1d60 Â· Jan 22, 2025

History

37 Commits
Jul 4, 2024
Oct 13, 2023
Sep 1, 2024
Jan 22, 2025
Sep 7, 2024
Jan 22, 2025
Sep 4, 2024
Jan 22, 2025
Jul 4, 2024
Oct 7, 2024
Jan 22, 2025
Sep 30, 2024
Jul 4, 2024
Jul 4, 2024

Repository files navigation

Synthlet

npm version

Collection of synth modules implemented as AudioWorklets.

import {
  registerAllWorklets,
  AdsrAmp,
  Svf,
  SvfType,
  PolyblepOscillator
} from "synthlet";

const ac = new AudioContext();
await registerAllWorklets(ac);

// Simplest synth: Oscillator -> Filter -> Amplifier
const osc = PolyblepOscillator(ac, { frequency: 440 });
const filter = Svf(ac, {
  type: SvfType.LowPass
  frequency: 4000,
});
const amp = AdsrAmp(ac, { attack: 0.1, release: 0.5 });
osc.connect(filter).connect(amp).connect(ac.destination);

// Change parameters
osc.frequency.value = 1200;

// Start sound
amp.gate.value = 1;

// Stop sound
vca.gate.value = 0;

Install

Install synthlet to install all modules:

npm i synthlet

Or each module individually:

npm i @synthlet/adsr

Documentation

Documentation and examples are here

Why?

Mostly, because I want to learn dsp.

Is it a good idea to write dsp in Typescript?

Probably not, but I've seen a talk at WAC 2022 about it that made me think it is possible (thanks to JS engine optimizations).

Should I use it?

Just for fun and curiosity. If you want to make music, Tone.js is probably the way to go.

If you want to deploy dsp modules to web in production, currently Faust and Cmajor or Elementary Audio are better alternatives.

References

This library wouldn't be possible with all the people writing books, blog posts and awesome libraries... and making music! Thanks to all 💚

Books

Blogs and papers

Synthesis open source repositories

Other

License

MIT License