Giter Club home page Giter Club logo

music.js's Introduction

music.js

Javascript library to make music

Goals of the project

The goal of music.js is to cover all the layers needed between HTML5 Web Audio API provided by browsers and fully usable music composition application similar to known ones like FL Studio

Music Composition Application
music.js
WebAudio API provided by Browser

Running this software on browsers gives us several advantages:

  • Potential portability among browsers and OSs where Web Audio API is supported
  • Access to other resources available on browsers, for example:
    • WebSockets or even simple ajax to exchange data with server and make collaborative music composition
    • WebRTC to make streaming of sound
    • Standard UI design tools like HTML and CSS would make easier to design and implement UI
    • Canvas 2D drawing or even WebGL may be useful for visualizations,etc...
  • NO installation needed

Although, these desirable features for music composition app are out of scope of music.js.

Music.js will cover:

  • DSL
    • To easily create sound processing pipelines and effects
    • To easily create virtual instruments from sounds, and from composing other virtual instruments
    • To easily create sequences of musical notes, events of an score, etc...
  • Library of sound effects usable from sound pipelines
    • Using webaudio capabilities, for example, the lowpass effect (via audioContext.createBiquadFilter)
    • Composed effects, for example stopCurve or echo effects
    • Effects imported from other libraries, for example reverb effect from Timbre.js

Installation

Sorry, for the moment there is no stable or single-file downloadable version for use. The status of this project is proof of concept

But, you can test the software at http://tario.github.io/music.js/ through examples. If you need to run it on your computer (e.g. to modify the code, etc...) the only thing you need to do is cloning the repo and host the static files (apache, iis, http-server from node.js, whatever), there is no server-side component needed to run music.js

Browser Compatibility

For the moment this proof of concept library was only tested on Chrome latests versions (39), so, may or not may work in others browsers then chrome. If you found compatibility errors you can report it if you want, but cross-browser compatibility is not the priority for now

Contents of repository

For convenience, the repository is organized toward the static website showing the examples (this could change in the future), being the components of music.js in and directory. Also, there is no single-file downloadable version of music.js yet

  • src: all the source of music.js library
  • site: all Angular.js components of the site, these includes for now controllers.js and services.js
  • spec: Automatic tests for music.js library
  • examples: code examples of using music.js. Be advice these examples were written to run in the main app, so you will found them listed on the main page
  • css: CSS files for the site
  • lib: all external libraries needed for the site and music.js including Angular.js and plugins, codemirror, timbre.js and jazmine.js for tests

Contribution

Any kind of contribution is welcome on this project, but, since this is proof of concept I need certain things before others:

  • Testing of features (find missing features, for example, you can't set change curves for frequences of custom oscillators)
  • Ideas for new features (including, "if X software or library can do X, why music.js can't do it too?")
  • New awesome effects and/or interesting waveforms or instruments
  • Songs made using music.js would be awesome too
  • Documentation and/or more examples

music.js's People

Contributors

tario avatar

Stargazers

Augusto Franzoia avatar

Watchers

 avatar David LQ avatar

music.js's Issues

Echo node cannot accept gain = 0

Repro steps:

  1. Choose a generator (e.g. square osc.)
  2. Add an echo effect with some delay and gain 0

Expected: the note sound reproduces only ONE time and then silence
Got: we got the sound reproduced ONE time and then the echo effect with arbitrary gain value (the default?)

Enable dropoff for oscillator node

This:

var stopC =  MUSIC.Curve.Ramp(1260, 1260/2, 100).during(0.2);
...
.oscillator({type: 'sine', frequency: stopC}
...

Should result in on sine sound doing dropoff from freq 1260 to 1260/2

Automatic Casting

Automatic type conversion to prevent user to have to worry about what wrapper should be used on each situation. For example, you should be able to use a simple playable (e.g. a sound) as instrument

iseq("A A A   A", music.sound("src/sound/Kick 1.wav"));

Make sequences stoppable

Currently, sequences doesnt respond to stop. e.g. arpeggiators can't be silenced in the middle of an iteration

Attack phase ignored when too many notes plays at the same time

Steps to reproduce:

  1. Add oscillator of type square
  2. Add envelop
  3. Arpeggiate on keyboard using the mouse as quick as you can

Get:

  • From time to time, you will hear a note without attack phase

Expected:

  • ALL notes plays with adsr envelope including attack phase

Design isolation for heavy reused stopCurve effect

This pattern is repeated a lot:

      return baseGainNode
              .noise()
              .onStop(function(){baseGainNode.dispose(); }) // dispose gain node
              .stopDelay(100)
              .onStop(function(){ baseGainNode .setParam('gain', stopCurve); }); // set gain curve

Implement optional separator on notation

Using pipe character "|", this character should be ignored on string, so:

"C4D4E4C4|D4C4====|....A#4=|F4==...." produces the same result as
"C4D4E4C4D4C4====....A#4=F4==...."

Implement Nested Components

Starting with multi-instrument component, nested components should be added through special directives for list of inner components

NOTE: at first, separate multiple-components using tabs

Implement build pipeline

Use grunt, bower or whatever we need to generate "music.js" and "music.min.js" with only one command

Oscillosope node

Two modes:

  1. Waveform
    Options:
  • Period:
  • Automatic
  • Fixed
  • Period multiplier (X1,X2,X3,X4,etc,,,) , only integer values
  1. frequency map (center main frequency)

Echo node reproduce the first repetition without attenuation

Repro steps:

  1. Choose a generator (e.g. square osc.)
  2. Add an echo effect with some delay and gain 0.001 (0 will NOT work because of another bug :P )

Expected: the note sound reproduces only ONE time
Got: we got the sound reproduced TWO times at equal volume level separated by delay

Implement character string music notation for sequences

Desirable features:

  • Espatial-temporal relation, for example four characters equal one beat, flexible according user needs
  • Notes are named CDEFGAB and can be altered using # and b and the octave number. So
    F
    F#
    F#4
    F 4
    ...Are all valid notes

Capital letters should act as separators and spaces are silence, example
"A B C=F#4FFF"
It plays:
A semiquaver,
silence semiquaver
B semiquaver
silence semiquaver
C quaver
F# octave 4 quaver + semiquaver duration note
and finally three F semiquavers

REmember on any situation the duration of the note is proportional to the lenght of the notation on character string plus the = extension

  • Insert of any playable object using aliases, for example
    seq("ABCDXAAAX", {X: snareSound});
  • Key Signature allowing alteration of any note, notes can be de-altered on notation using dash, example:

"F=F=F-F-"
It should play two sustained F and then two unaltered F

Componentize script editor

By implemented component basic system. Could be angular-bound

Components of music.js has TWO main parts:

  • Template to edit data objects (HTML/Angular including needed CSS and other assets)
  • Script to make live objects (e.g. instruments, sounds, songs, wave forms, etc...) from data objects

Accessory:

  • javascript function to initialize objects to default state
  • Manifest on json format

ADSR Envelope

Allow applying ADSR envelope on any pipeline, there is three main parametric numeric values:

  • Attack time (time taken to rise volume from zero to max)
  • Decay time (time taken to down volume from max to sustain volume)
  • Release time (time taken to down volumen from sustain level to zero after key is released)

More info: http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope

Implement audio param modulation

For example, you can modulate the frequency or detune of an oscillator with another periodic wave to generate a vibrato effect. Or you can modulate a gain node to generate ADSR effect

Example:

// create the sound generator
var soundGenerator = {
  freq: function(fr) {
    var osc = music.oscillator({type: 'square', detune: MUSIC.modulator(function(p) {
      return p.gain(50).oscillator({type: "sine", frequency: 1.0});
    }));
  }
};

// add instrument to show on UI
return new MUSIC.Instrument(soundGenerator);

Simplify script component and general components return contract

It should simply return ONE object and should not requires any structure, array or plain object wrapping the result of the script

Example:

// create the sound generator
var soundGenerator = {
  freq: function(fr) {
    return music.
            ADSR({
              node: function(node) {
                return node.oscillator({type: 'square', frequency: fr});
              }, 
              attackTime: 0.2,
              decayTime: 0.2,
              releaseTime: 0.2,
              sustainLevel: 0.8
            });
  }
};

// create the instrument from sound generator
return new MUSIC.Instrument(soundGenerator)
                .mapNote(function(n) { return n + 36; });

On script component implementation:

module.export = function(MusicContext) {
    return function(object){
        var results = MusicContext.run(object.code);
        if (results.error) {
            object.codeError = results.error;
        } else {
            object.codeError = null;
        }
        return results.returnedObject;
    };
};

Arpeggiator node

parameters

  • Scale (minor and major scale)
  • Note duration
  • Note count

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.