GithubHelp home page GithubHelp logo

positonic / json-to-web-audio Goto Github PK

View Code? Open in Web Editor NEW
44.0 2.0 6.0 7.31 MB

json-to-web-audio allows you to specify oscillators and filters as JSON, and it will automatically create the necessary Web audio api nodes and filters, and link them together, and send the result to your speakers

HTML 6.61% JavaScript 93.37% CSS 0.01%

json-to-web-audio's Introduction

json-to-web-audio

json-to-web-audio allows you to specify oscillators and filters as JSON, and it will automatically create the necessary Web audio api nodes and filters, and link them together, and send the result to your speakers.

You can specify any standard web audio filters, and it also includes support for the wonderful link to the wonderful TunaJS filters..

To install:

 npm install json-to-web-audio

To see it working run:

 npm start

Then visit http://localhost:8080/webpack-dev-server/

To use, first specify your json:

  nodeVoiceConfig = {
        oscillators : [
            {
                type: "sine",
                pipeLength: 32,
                gain: 100,
                filter: 1000,
                tuning: 0
            },
            {
                type: "sine",
                pipeLength: 8,
                gain: 100,
                filter: 1000,
                tuning: 700
            }
        ],
        gain: 100,
        filters: [
            {
                type: 'filter',
                props: {
                    type: "lowpass",
                        value: 1000
                }
            },
            {
                type: 'filter',
                tunaType: 'Chorus',
                props: {
                    rate: 1.5,
                        feedback: 0.2,
                        delay: 0.0045,
                        bypass: 0
                }
            },
            {
                type: 'filter',
                tunaType: "Delay",
                props: {
                    feedback: 0.45,    //0 to 1+
                        delayTime: 150,    //1 to 10000 milliseconds
                        wetLevel: 0.25,    //0 to 1+
                        dryLevel: 1,       //0 to 1+
                        cutoff: 2000,      //cutoff frequency of the built in lowpass-filter. 20 to 22050
                        bypass: 0
                }
            },
            {
                type: 'filter',
                tunaType: "Phaser",
                props: {
                    rate: 1.2,                     //0.01 to 8 is a decent range, but higher values are possible
                        depth: 0.3,                    //0 to 1
                        feedback: 0.2,                 //0 to 1+
                        stereoPhase: 30,               //0 to 180
                        baseModulationFrequency: 700,  //500 to 1500
                        bypass: 0
                }
            }
        ]
    }
    ],

    gain: 100

};

...and then run it like so:

 let voice = Voice(context, voiceConfig);
 
 var masterVca = voice.setupOscillators();
 let filterInput = voice.setUpFilters(voiceConfig.filters, masterVca, context.destination);
 
 voice.play();

json-to-web-audio's People

Contributors

mpj avatar positonic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.