sound-processor
May 31, 2019 · View on GitHub
forgive my poor English...
sound-processor
A small(gzip < 3KB), dependency-free audio signal processor, the flow is:
- import original audio signal;
- gaussian filter,make output more smooth;
when you
getByteFrequencyDatafromAnalyserNode, webaudio has already apply a Blackman window, make up for gain loss, the parameters is unadjustable. But most of the time, the vision is prior to precision in audio visualization, so we apply a gaussian filter for signal smooth, the degree of smoothness is steerable.
- weighting, include a-weighting and time-weighting. weighting simulate human subjective feeling of sound;
- octave divide base on parameters given to
SoundProcessor;
three demo(audio is load slow, please wait):



install
npm install sound-processor
usage
import { SoundProcessor } from "sound-processor";
const processor = new SoundProcessor(options);
// in means original signal from getByteFrequencyData
const out = processor.process(in);
options
filterParams: gaussian filter params,object,default toundefined,means do not filter:sigma:gaussian distribution sigma,default to 1,means standardized normal distribution, bigger sigma means more smooth,usually between0.1~250;radius:filter radius, default to 2, bigger means more smooth;
sampleRate:fromaudioContext.sampleRate, like 48000;fftSize:param for FFT,default to 1024;startFrequency:min frequency,default 0;endFrequency:max frequency,default to 10000,you can cut out any frequency section withstartFrequencyandendFrequency;outBandsQty:number of output bands, usually means number of visualization targets;tWeight:whether to apply time-weighting,default tofalse;aWeight:whether to apply time-weighting,default totrue;
frequency cut
frequency of music is between 50~10000 Hz, but in practice, we can cut 100~7000 Hz. perfect frequency cut not exists.
contribution
clone this project,exchange content of package.json and package.dev.json, than npm run start.
license
MIT.