rubberband-wasm
Version:
WebAssembly version of the Rubber Band Library (high quality software library for audio time-stretching and pitch-shifting)
8 lines (6 loc) • 6.76 kB
JavaScript
/*!
* rubberband-wasm v3.3.0 (https://www.npmjs.com/package/rubberband-wasm)
* (c) Dani Biro
* @license GPLv2
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).rubberband={})}(this,(function(e){"use strict";var t,r;e.RubberBandOption=void 0,(t=e.RubberBandOption||(e.RubberBandOption={}))[t.RubberBandOptionProcessOffline=0]="RubberBandOptionProcessOffline",t[t.RubberBandOptionProcessRealTime=1]="RubberBandOptionProcessRealTime",t[t.RubberBandOptionStretchElastic=0]="RubberBandOptionStretchElastic",t[t.RubberBandOptionStretchPrecise=16]="RubberBandOptionStretchPrecise",t[t.RubberBandOptionTransientsCrisp=0]="RubberBandOptionTransientsCrisp",t[t.RubberBandOptionTransientsMixed=256]="RubberBandOptionTransientsMixed",t[t.RubberBandOptionTransientsSmooth=512]="RubberBandOptionTransientsSmooth",t[t.RubberBandOptionDetectorCompound=0]="RubberBandOptionDetectorCompound",t[t.RubberBandOptionDetectorPercussive=1024]="RubberBandOptionDetectorPercussive",t[t.RubberBandOptionDetectorSoft=2048]="RubberBandOptionDetectorSoft",t[t.RubberBandOptionPhaseLaminar=0]="RubberBandOptionPhaseLaminar",t[t.RubberBandOptionPhaseIndependent=8192]="RubberBandOptionPhaseIndependent",t[t.RubberBandOptionThreadingAuto=0]="RubberBandOptionThreadingAuto",t[t.RubberBandOptionThreadingNever=65536]="RubberBandOptionThreadingNever",t[t.RubberBandOptionThreadingAlways=131072]="RubberBandOptionThreadingAlways",t[t.RubberBandOptionWindowStandard=0]="RubberBandOptionWindowStandard",t[t.RubberBandOptionWindowShort=1048576]="RubberBandOptionWindowShort",t[t.RubberBandOptionWindowLong=2097152]="RubberBandOptionWindowLong",t[t.RubberBandOptionSmoothingOff=0]="RubberBandOptionSmoothingOff",t[t.RubberBandOptionSmoothingOn=8388608]="RubberBandOptionSmoothingOn",t[t.RubberBandOptionFormantShifted=0]="RubberBandOptionFormantShifted",t[t.RubberBandOptionFormantPreserved=16777216]="RubberBandOptionFormantPreserved",t[t.RubberBandOptionPitchHighSpeed=0]="RubberBandOptionPitchHighSpeed",t[t.RubberBandOptionPitchHighQuality=33554432]="RubberBandOptionPitchHighQuality",t[t.RubberBandOptionPitchHighConsistency=67108864]="RubberBandOptionPitchHighConsistency",t[t.RubberBandOptionChannelsApart=0]="RubberBandOptionChannelsApart",t[t.RubberBandOptionChannelsTogether=268435456]="RubberBandOptionChannelsTogether",t[t.RubberBandOptionEngineFaster=0]="RubberBandOptionEngineFaster",t[t.RubberBandOptionEngineFiner=536870912]="RubberBandOptionEngineFiner",e.RubberBandPresetOption=void 0,(r=e.RubberBandPresetOption||(e.RubberBandPresetOption={}))[r.DefaultOptions=0]="DefaultOptions",r[r.PercussiveOptions=1056768]="PercussiveOptions";class n{constructor(){}static async initialize(e){if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");let t={};const r=(...e)=>(console.error("WASI called with params",e),52);let s=[];const a=await WebAssembly.instantiate(e,{env:{emscripten_notify_memory_growth:()=>{t.HEAP8=new Uint8Array(a.exports.memory.buffer),t.HEAP32=new Uint32Array(a.exports.memory.buffer)}},wasi_snapshot_preview1:{proc_exit:(...e)=>r("proc_exit",e),fd_read:(...e)=>r("fd_read",e),fd_write:(e,r,n,a)=>{if(e>2)return 52;let b=0;for(let e=0;e<n;e++){const e=t.HEAP32[r>>2],n=t.HEAP32[r+4>>2];r+=8;for(let r=0;r<n;r++){const n=t.HEAP8[e+r];0===n||10===n?(console.log(s.join("")),s.length=0):s.push(String.fromCharCode(n))}b+=n}return t.HEAP32[a>>2]=b,0},fd_seek:(...e)=>r("fd_seek",e),fd_close:(...e)=>r("fd_close",e),environ_sizes_get:(e,t)=>52,environ_get:(...e)=>r("environ_get",e),clock_time_get:(...e)=>r("clock_time_get",e)}}),b=a.exports;t.HEAP8=new Uint8Array(a.exports.memory.buffer),t.HEAP32=new Uint32Array(a.exports.memory.buffer),b._initialize();const i={heap:t,exports:b},o=new n;return o.wasm=i,o}malloc(e){return this.wasm.exports.wasm_malloc(e)}memWrite(e,t){const r=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this.wasm.heap.HEAP8.set(r,e)}memWritePtr(e,t){const r=new Uint8Array(4);new DataView(r.buffer).setUint32(0,t,!0),this.wasm.heap.HEAP8.set(r,e)}memReadU8(e,t){return this.wasm.heap.HEAP8.subarray(e,e+t)}memReadF32(e,t){const r=this.memReadU8(e,4*t);return new Float32Array(r.buffer,r.byteOffset,t)}free(e){this.wasm.exports.wasm_free(e)}rubberband_new(e,t,r,n,s){return this.wasm.exports.rb_new(e,t,r,n,s)}rubberband_delete(e){this.wasm.exports.rb_delete(e)}rubberband_reset(e){this.wasm.exports.rb_reset(e)}rubberband_set_time_ratio(e,t){this.wasm.exports.rb_set_time_ratio(e,t)}rubberband_set_pitch_scale(e,t){this.wasm.exports.rb_set_pitch_scale(e,t)}rubberband_set_formant_scale(e,t){this.wasm.exports.rb_set_formant_scale(e,t)}rubberband_get_time_ratio(e){return this.wasm.exports.rb_get_time_ratio(e)}rubberband_get_pitch_scale(e){return this.wasm.exports.rb_get_pitch_scale(e)}rubberband_get_formant_scale(e){return this.wasm.exports.rb_get_formant_scale(e)}rubberband_get_preferred_start_pad(e){return this.wasm.exports.rb_get_preferred_start_pad(e)}rubberband_get_start_delay(e){return this.wasm.exports.rb_get_start_delay(e)}rubberband_get_latency(e){return this.wasm.exports.rb_get_latency(e)}rubberband_set_transients_option(e,t){this.wasm.exports.rb_set_transients_option(e,t)}rubberband_set_detector_option(e,t){this.wasm.exports.rb_set_detector_option(e,t)}rubberband_set_phase_option(e,t){this.wasm.exports.rb_set_phase_option(e,t)}rubberband_set_formant_option(e,t){this.wasm.exports.rb_set_formant_option(e,t)}rubberband_set_pitch_option(e,t){this.wasm.exports.rb_set_pitch_option(e,t)}rubberband_set_expected_input_duration(e,t){this.wasm.exports.rb_set_expected_input_duration(e,t)}rubberband_get_samples_required(e){return this.wasm.exports.rb_get_samples_required(e)}rubberband_set_max_process_size(e,t){this.wasm.exports.rb_set_max_process_size(e,t)}rubberband_get_process_size_limit(e){return this.wasm.exports.rb_get_process_size_limit(e)}rubberband_set_key_frame_map(e,t,r,n){this.wasm.exports.rb_set_key_frame_map(e,t,r,n)}rubberband_study(e,t,r,n){this.wasm.exports.rb_study(e,t,r,n)}rubberband_process(e,t,r,n){this.wasm.exports.rb_process(e,t,r,n)}rubberband_available(e){return this.wasm.exports.rb_available(e)}rubberband_retrieve(e,t,r){return this.wasm.exports.rb_retrieve(e,t,r)}rubberband_get_channel_count(e){return this.wasm.exports.rb_get_channel_count(e)}rubberband_calculate_stretch(e){this.wasm.exports.rb_calculate_stretch(e)}rubberband_set_debug_level(e,t){this.wasm.exports.rb_set_debug_level(e,t)}rubberband_set_default_debug_level(e){this.wasm.exports.rb_set_default_debug_level(e)}}e.RubberBandInterface=n,Object.defineProperty(e,"__esModule",{value:!0})}));