Giter Site home page Giter Site logo

audio-shader's Introduction

Webgl-based audio processing stream.

npm install audio-shader

var AudioShader = require('audio-shader');
var Speaker = require('audio-speaker');

//Create shader stream based on sound processing function
AudioShader(`
	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:

//index.js
var Shader = require('audio-shader');
var Speaker = require('speaker');
var glslify = require('glslify');

Shader(glslify('./sound.glsl'), options?).pipe(Speaker());
//sound.glsl
vec2 mainSound( float time ){
	return vec2( 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.

var MusicXML = require('musicxml-to-pcm');
var Processor = require('audio-shader');
var Speaker = require('speaker');

MusicXML()
.pipe(Processor(`
	vec2 main (float time) {
		//TODO test this example and document it, shadertoy is down
		return vec2();
	}
`))
.pipe(Speaker());

Related

audio-shader's People

Contributors

dy avatar jamen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.