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
varAudioShader=require('audio-shader');varSpeaker=require('audio-speaker');//Create shader stream based on sound processing functionAudioShader(` vec2 mainSound( float time ){ return vec2( sin(6.2831*880.0*time)*exp(-3.0*time) ); }`)//Send generated sound to speaker.pipe(Speaker());
API
API is fully compatible with shadertoy to copy-paste and run it’s code locally. Note that shadertoy limits output sound to 60s, whereas audio-shader runs till it is stoped.
It also might be found helpful to use glslify to get code inserted neatly:
//sound.glslvec2 mainSound( float time ){
returnvec2( sin(6.2831*440.0*time)*exp(-3.0*time) );
}
Audio-shader can also be used as a processing stream. It inherits audio-through, which is basically a transform stream, so it can be used with other node streams.
varMusicXML=require('musicxml-to-pcm');varProcessor=require('audio-shader');varSpeaker=require('speaker');MusicXML().pipe(Processor(` vec2 main (float time) { //TODO test this example and document it, shadertoy is down return vec2(); }`)).pipe(Speaker());