rochars / wave-resampler Goto Github PK
View Code? Open in Web Editor NEWPCM audio resampler written entirely in JavaScript.
License: MIT License
PCM audio resampler written entirely in JavaScript.
License: MIT License
import { resampler } from 'wave-resampler';
let newSamples = resample(samples, 48000, 44100);
This is how it works for me:
import resampler from 'wave-resampler';
let newSamples = resampler.resample(samples, 48000, 44100);
Thanks!
Hello and thanks for making this available and free to use!
Am I correct to assume that different channels should be processed using resample(...) independently, rather than resampling chunks of interleaved stereo audio? If so, it may be helpful to include specifying the correct format of input in the docs. ๐
Thanks again!
I have a Buffer with 48kHz audio as PCM signed 16-bit little-endian (FFmpeg format s16le
). Then I'm doing this simple test to find out that the resample function is affecting the source data:
while (...) {
const audioBuffer = Buffer.from(...);
const resampled = WaveResampler.resample(audioBuffer, 48000, 16000, {
LPF: true,
});
// `resampled` is not used. `audioBuffer` has been modified but it shouldn't.
fs.appendFileSync("/tmp/test.raw", audioBuffer);
}
Now playing this audio with FFmpeg, the audio contents have been destroyed and everything is just noise, except that the original audio can be kind of noticed very subtle in the background:
ffplay -f s16le -ar 48k -ac 1 /tmp/test.raw
Setting LPF: false
avoids the issue. The mistake seems to be in the downsample_()
function, which saves data directly into the source buffer, when I believe it shouldn't:
samples[i] = filter.filter(samples[i]);
As it is, no LPF downsampling can be done with this library with default settings, because the resulting audio is garbled.
All the examples show down sampling. Does this support up sampling?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.