You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Audio-render is a pass-through audio stream, providing structure for rendering stream audio data.
It resolves common routines like frequency analysis (fft), buffering data, reading pcm format, providing unified API for rendering both in node/browser, events, options, hooks etc. Creating new rendering components based on audio-render is as simple as creating them from scratch, but times more reliable. It is also useful for creating quick debuggers.
Usage
myAudioStream.pipe(Render(function(canvas){vardata=this.getFloatTimeDomainData();//draw volume, spectrum, spectrogram, waveform — any data you need})).pipe(Speaker());
API
varGenerator=require('audio-generator');varSpeaker=require('audio-speaker');varRenderStream=require('audio-render');varisBrowser=require('is-browser');//create rendering stream from passed optionsvarrenderer=RenderStream({//custom rendering function, can be passed instead of optionsrender: function(canvas){//see audio-analyser for APIvarfdata=this.getFrequencyData();varwaveform=this.getTimeData(size);//or use web-audio-api AnalyserNode methods herethis.getFloatFrequencyData(newFloat32Array(self.frequencyBinCount));this.getFloatTimeDomainData(newFloat32Array(self.fftSize));},//channel number to render, 0 - L, 1 - R, ...channel: 0,//FPS (node only)framesPerSecond: 20,//max amount of data to store, number of samplesbufferSize: 44100,//custom canvas (optinal), if you need to render along with other renderercanvas: undefined,//Analysis options//Magnitude diapasone, in dBminDecibels: -100,maxDecibels: 0,// Number of points to grab for fftfftSize: 1024,// Number of points to plot for fftfrequencyBinCount: 1024/2,// Smoothing, or the priority of the old data over the new datasmoothingTimeConstant: 0.2//...any pcm format options, if required. See pcm-util below.});//Depending on the enviromnent, expose canvasisBrowser&&document.body.appendChild(renderer.canvas);renderer.on('render',function(canvas,data){process.stdout.write(canvas._canvas.frame());});//If renderer is not piped, it works as a sink, else - as pass-throughGenerator().pipe(renderer).pipe(Speaker());