Coder Social home page Coder Social logo

aolsenjazz / libsamplerate-js Goto Github PK

View Code? Open in Web Editor NEW
30.0 1.0 7.0 10.61 MB

Resample audio in node or browser using a web assembly port of libsamplerate.

License: Other

HTML 0.33% JavaScript 48.93% C 8.96% C++ 6.97% TypeScript 31.22% Shell 3.12% Dockerfile 0.46%
webassembly web-assembly web-audio wasm libsamplerate resample resampler audio sample-rate-converter dsp

libsamplerate-js's Introduction

Hi there ๐Ÿ‘‹

I'm building libraries+apps to make life easier for musicians and engineers working with Web Audio. I'm interested in:

  • Intelligent MIDI device rendering w/React+Electron
  • WebAssembly integration into audio processing
  • AI workflow integration
  • Music composition algorithm design

You can reach me at my LinkedIn or Twitter

libsamplerate-js's People

Contributors

aolsenjazz avatar depfu[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

libsamplerate-js's Issues

Sync changing of sample rate

Could the call to new SRC somehow be moved out of the promise, so that different sample rates can be chosen without needlessly having to resolve a promise?

AudioWorklet example?

Hi,

First of all thanks for this work: it works perfectly for my use-case which is resampling audio within an AudioWorklet. I think this is a logical place for audio resampling. However I am wondering which is the best way to do this? The import statements - which work in a 'normal' worklet - do not seem to work in the audio context.

I have managed to get it working by building a 'shell' version of the library and including the code directly in an Audioworklet. I am wondering if this is the best way and if you could provide an AudioWorklet example showing the best way to do it.

See here for my hacked resampler: https://github.com/JorenSix/Olaf/tree/master/wasm

Lazy Load the glue module

The big glue js module should be loaded lazily.

Lazy loading was added, then remove again in #119 because it cause the library to break when loaded via <script> tag. Can't imagine too many people are loading via script tag but this change isn't justified imo.

Problem was, ts was transpiling the async imports into requires, cause it to break in the above scenario. Shouldn't be too difficult to not-transpile that way, but I can't find it at the time of this writing.

Makefile?

Hello, thanks for the library. Is it possible for you to add to the repo the Makefile used for compilation for both the wasm module and the libsamplerate?

Thanks.

Support multiple parallel streams

As requested in #8: let's say you're downloading an audio file in chunks and you want to resample it. For best results you'd want to feed the chunks to libsamplerate as they arrive, this way doing Network I/O and processing in parallel.

With the current version of this lib you'll have to make sure that you only process a single audio file in this way; if you wanted to download and resample multiple files chunk-wise in parallel, you'd need more than one SRC_STATE because due to the async nature of JavaScript, chunks from different files are likely to arrive interleaved in the same thread.

For some audio buffers, I get a RangeError.

Expected Behavior

Error-free sample rate conversion of an audiobuffer.

Current Behavior

Uncaught RangeError: offset is out of bounds

Steps to Reproduce

This only happens on certain audio buffers, with certain conversion requests. I'm not sure how to make it reproducible for you without sharing a big .wav file. If it's helpful, I can provide you with a link to my web app and instructions for how to reproduce the problem there.

Possible Solution

If I change:

        return Math.ceil(O.length * this.ratio) > r ? this._chunkAndResample(O) : (this.sourceArray.set(O),

to

        return Math.ceil(O.length * this.ratio) > r ? this._chunkAndResample(O) : (this.sourceArray.set(O.slice(0, r)),

the error isn't raised, but I'm not convinced that's the right fix. I just took a stab :-).

Context

Straightforward sr conversion

no

Your Environment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.