3.0.1 • Published 4 years ago

speex-resampler v3.0.1

Weekly downloads
30
License
MIT
Repository
github
Last release
4 years ago

Speex Resampler

This lib exposes the Speex resampler to Javascript with WebAssembly. It doesn't have any dependancy and support NodeJS or a WebContext. Typescript typings are also provided.

From speex creator, the design goals of the resampler are:

  • Very fast algorithm
  • SIMD-friendly algorithm
  • Low memory requirement
  • Good perceptual quality (and not best SNR)

How to use

await SpeexResampler.initPromise; // will be resolved once the WASM module has been compiled, before this you cannot call the SpeexResampler processChunk method

const channels = 2; // minimum is 1, no maximum
const inRate = 44100; // frequency in Hz for the input chunk
const outRate = 44000; // frequency in Hz for the target chunk
const quality = 7; // number from 1 to 10, default to 7, 1 is fast but of bad quality, 10 is slow but best quality
// you need a new resampler for every audio stream you want to resample
// it keeps data from previous calls to improve the resampling
const resampler = new SpeexResampler(
  channels,
  audioTest.inRate,
  audioTest.outRate,
  audioTest.quality // optionnal
);

const pcmData = Buffer.from(/* interleaved PCM data in signed 16bits int */);
const res = await resampler.processChunk(pcmData);
// res is also a buffer with interleaved signed 16 bits PCM data

You can look at the src/test.ts for more information.

Test music by https://www.bensound.com

3.0.1

4 years ago

3.0.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago