aperiodic-oscillator
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

aperiodic-oscillator

Non-periodic replacement for OscillatorNode from Web Audio API

Examples

// Standard Web Audio API
const context = new AudioContext();
const saw = new OscillatorNode(context, {type: 'sawtooth'});

// Unison oscillator consisting of five voices spread ±6.9 Hz in frequency.
const supersaw = new UnisonOscillator(context, {
  type: 'sawtooth',
  numberOfVoices: 5,
  spread: 6.9,
});

// Construct an inharmonic timbre
const ns = [...Array(129).keys()];
ns.shift();
const spectrum = ns.map(n => n ** 1.5);
const amplitudes = ns.map(n => 0.3 * n ** -1.5);
const maxNumberOfVoices = 7;
const tolerance = 0.1; // In cents
const timbre = new AperiodicWave(
  context,
  spectrum,
  amplitudes,
  maxNumberOfVoices,
  tolerance
);

// Aperiodic oscillator with an inharmonic timbre
const tine = new AperiodicOscillator(context, {aperiodicWave: timbre});

Installation

npm i

Documentation

Documentation is hosted at the project Github pages.

To generate documentation locally run:

npm run doc

Package Sidebar

Install

npm i aperiodic-oscillator

Weekly Downloads

14

Version

0.1.1

License

MIT

Unpacked Size

42.9 kB

Total Files

9

Last publish

Collaborators

  • frostburn