1.3.11 • Published 2 months ago

@logue/reverb v1.3.11

Weekly downloads
7
License
MIT
Repository
github
Last release
2 months ago

Reverb.js

jsdelivr CDN NPM Downloads Open in unpkg npm version Open in Gitpod Twitter Follow

Append reverb effect to audio source.

This script is originally a spin out of sf2synth.js's reverb effect.

Sample

Syntax

const reverb = new Reverb(ctx, {
  /**
   * Randam noise algorythm
   * @see {@link https://github.com/thi-ng/umbrella/tree/develop/packages/random}
   */
  randomAlgorithm: SYSTEM;
  /**
   * IR (Inpulse Response) colord noise algorithm (BLUE, GREEN, PINK, RED, VIOLET, WHITE)
   * @see {@link https://github.com/thi-ng/umbrella/tree/develop/packages/colored-noise}
   */
  noise: Noise.WHITE,
  /** IR source noise scale */
  scale: 1;
  /** Number of IR source noise peaks */
  peaks: 2;
  /** Amount of IR decay. 0~100 */
  decay: 5,
  /** Delay time o IR. (NOT delay effect) 0~100 [sec] */
  delay: 0,
  /** Filter frequency. 20~5000 [Hz] */
  filterFreq: 2200,
  /** Filter Q. 0~10 */
  filterQ: 1,
  /**
   * Filter type. 'bandpass' etc.
   * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode/type}
   */
  filterType: 'lowpass',
  /** Dry (Original Sound) and Wet (Effected sound) raito. 0~1 */
  mix: 0.5,
  /** Reverse IR. */
  reverse: false,
  /** Time length of IR. 0~50 [sec] */
  time: 3,
});

Usage

// Setup Audio Context
const ctx = new window.AudioContext();

// iOS fix.
document.addEventListener('touchstart', initAudioContext);
function initAudioContext() {
  document.removeEventListener('touchstart', initAudioContext);
  // wake up AudioContext
  const emptySource = ctx.createBufferSource();
  emptySource.start();
  emptySource.stop();
}

// Setup Reverb Class
const reverb = new Reverb(ctx, {});

// put Audio data to audio buffer source
const sourceNode = ctx.createBufferSource();
sourceNode.buffer = [AudioBuffer];

// Connect Reverb
reverb.connect(sourceNode);
sourceNode.connect(ctx.destination);

// fire
sourceNode.play();

CDN Usage

Not really intended for use with a CDN.

The dependent libraries @thi.ng/colored-noise, @thi.ng/random and @thi.ng/transducers need to be loaded separately.

Reference

License

©2019-2024 by Logue. Licensed under the MIT License.

1.3.11

2 months ago

1.3.10

3 months ago

1.3.9

7 months ago

1.3.7

10 months ago

1.2.18

1 year ago

1.3.5

12 months ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.16

1 year ago

1.2.12

2 years ago

1.2.13

1 year ago

1.2.14

1 year ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.10

2 years ago

1.2.11

2 years ago

1.2.6

2 years ago

1.2.0

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.5.4

2 years ago

0.5.5

2 years ago

0.5.3

2 years ago

0.5.2

3 years ago

0.5.0

3 years ago

0.5.1

3 years ago

0.4.6

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.2

3 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.1.0

5 years ago