UNPKG

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.41 kB
/*! * rubberband-wasm v3.3.0 (https://www.npmjs.com/package/rubberband-wasm) * (c) Dani Biro * @license GPLv2 */ var e,t;!function(e){e[e.RubberBandOptionProcessOffline=0]="RubberBandOptionProcessOffline",e[e.RubberBandOptionProcessRealTime=1]="RubberBandOptionProcessRealTime",e[e.RubberBandOptionStretchElastic=0]="RubberBandOptionStretchElastic",e[e.RubberBandOptionStretchPrecise=16]="RubberBandOptionStretchPrecise",e[e.RubberBandOptionTransientsCrisp=0]="RubberBandOptionTransientsCrisp",e[e.RubberBandOptionTransientsMixed=256]="RubberBandOptionTransientsMixed",e[e.RubberBandOptionTransientsSmooth=512]="RubberBandOptionTransientsSmooth",e[e.RubberBandOptionDetectorCompound=0]="RubberBandOptionDetectorCompound",e[e.RubberBandOptionDetectorPercussive=1024]="RubberBandOptionDetectorPercussive",e[e.RubberBandOptionDetectorSoft=2048]="RubberBandOptionDetectorSoft",e[e.RubberBandOptionPhaseLaminar=0]="RubberBandOptionPhaseLaminar",e[e.RubberBandOptionPhaseIndependent=8192]="RubberBandOptionPhaseIndependent",e[e.RubberBandOptionThreadingAuto=0]="RubberBandOptionThreadingAuto",e[e.RubberBandOptionThreadingNever=65536]="RubberBandOptionThreadingNever",e[e.RubberBandOptionThreadingAlways=131072]="RubberBandOptionThreadingAlways",e[e.RubberBandOptionWindowStandard=0]="RubberBandOptionWindowStandard",e[e.RubberBandOptionWindowShort=1048576]="RubberBandOptionWindowShort",e[e.RubberBandOptionWindowLong=2097152]="RubberBandOptionWindowLong",e[e.RubberBandOptionSmoothingOff=0]="RubberBandOptionSmoothingOff",e[e.RubberBandOptionSmoothingOn=8388608]="RubberBandOptionSmoothingOn",e[e.RubberBandOptionFormantShifted=0]="RubberBandOptionFormantShifted",e[e.RubberBandOptionFormantPreserved=16777216]="RubberBandOptionFormantPreserved",e[e.RubberBandOptionPitchHighSpeed=0]="RubberBandOptionPitchHighSpeed",e[e.RubberBandOptionPitchHighQuality=33554432]="RubberBandOptionPitchHighQuality",e[e.RubberBandOptionPitchHighConsistency=67108864]="RubberBandOptionPitchHighConsistency",e[e.RubberBandOptionChannelsApart=0]="RubberBandOptionChannelsApart",e[e.RubberBandOptionChannelsTogether=268435456]="RubberBandOptionChannelsTogether",e[e.RubberBandOptionEngineFaster=0]="RubberBandOptionEngineFaster",e[e.RubberBandOptionEngineFiner=536870912]="RubberBandOptionEngineFiner"}(e||(e={})),function(e){e[e.DefaultOptions=0]="DefaultOptions",e[e.PercussiveOptions=1056768]="PercussiveOptions"}(t||(t={}));class r{constructor(){}static async initialize(e){if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");let t={};const n=(...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)=>n("proc_exit",e),fd_read:(...e)=>n("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)=>n("fd_seek",e),fd_close:(...e)=>n("fd_close",e),environ_sizes_get:(e,t)=>52,environ_get:(...e)=>n("environ_get",e),clock_time_get:(...e)=>n("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 r;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)}}export{r as RubberBandInterface,e as RubberBandOption,t as RubberBandPresetOption};