Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geekuillaume/node-speex-resampler
An implementation of Speex audio resampler on NodeJS with N-API
https://github.com/geekuillaume/node-speex-resampler
Last synced: 25 days ago
JSON representation
An implementation of Speex audio resampler on NodeJS with N-API
- Host: GitHub
- URL: https://github.com/geekuillaume/node-speex-resampler
- Owner: geekuillaume
- License: mit
- Created: 2020-01-08T14:59:40.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-12T10:12:05.000Z (over 1 year ago)
- Last Synced: 2024-12-05T21:33:54.200Z (about 1 month ago)
- Language: TypeScript
- Size: 4.58 MB
- Stars: 16
- Watchers: 3
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Speex Resampler
This lib exposes the [Speex resampler](https://speex.org/docs/manual/speex-manual/node7.html) 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
```js
await SpeexResampler.initPromise; // will be resolved once the WASM module has been compiled, before this you cannot call the SpeexResampler processChunk methodconst 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