Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
tambien committed Jul 7, 2016
2 parents 5c92595 + 439583b commit c904797
Show file tree
Hide file tree
Showing 212 changed files with 21,254 additions and 16,027 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ test/Main.js
build/p5.Tone.min.js
build/p5.Tone.js

.DS_Store
.DS_Store
examples/graph.html
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"GainNode" : false,
"AudioNode" : false,
"AudioParam" : false,
"AnalyserNode" : false,
"WaveShaperNode" : false,
"DynamicsCompressorNode" : false,
"MediaStreamTrack" : false
Expand Down
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: node_js
node_js:
- "4.1"
before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
before_script:
- cd gulp
- npm install -g karma
- npm install -g gulp
- npm install
script: gulp karma-test
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
### r7

* MetalSynth creates metalic, cymbal sounds
* DrumSynth -> MembraneSynth
* FMOscillator, AMOscillator types
* FatOscillator creates multiple oscillators and detunes them slightly
* FM, AM, Fat Oscillators incorporated into OmniOscillator
* Simplified FM and AM Synths and APIs
* Panner.pan is between -1,1 like the StereoPannerNode
* Pruned away unused (or little used) Signal classes.
* All this functionality will be available when the AudioWorkerNode is introduced.
* Clock uses Web Workers instead of requestAnimationFrame which allows it to run in the background.
* Removed `startMobile`. Using [StartAudioContext](https://github.com/tambien/StartAudioContext) in examples.
* Automated test runner using [Travis CI](https://travis-ci.org/Tonejs/Tone.js/)
* Simplified NoiseSynth by removing filter and filter envelope.
* Added new timing primitive types: Time, Frequency, TransportTime.
* Switching parameter position of type and size in Tone.Analyser
* Tone.Meter uses Tone.Analyser instead of ScriptProcessorNode.
* Tone.Envelope has 5 new attack/release curves: "sine", "cosine", "bounce", "ripple", "step"
* Renamed Tone.SimpleSynth -> Tone.Synth
* Tone.Buffers combines multiple buffers
* Tone.BufferSource a low-level wrapper, and Tone.MultiPlayer which is good for multisampled instruments.
* Tone.GrainPlayer: granular synthesis buffer player.
* Simplified Sampler

DEPRECATED:
* Removed SimpleFM and SimpleAM

### r6

* Added PitchShift and Vibrato Effect.
Expand Down
102 changes: 55 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
Tone.js
=========

Tone.js is a Web Audio framework for creating interactive music in the browser. The architecture of Tone.js aims to be familiar to both musicians and audio programmers looking to create web-based audio applications. On the high-level, Tone offers common DAW (digital audio workstation) features like a global transport for scheduling and timing events and prebuilt synths and effects. For signal-processing programmers (coming from languages like Max/MSP), Tone provides a wealth of high performance, low latency building blocks and DSP modules to build your own synthesizers, effects, and complex control signals.
Tone.js is a Web Audio framework for creating interactive music in the browser. The architecture of Tone.js aims to be familiar to both musicians and audio programmers looking to create web-based audio applications. On the high-level, Tone offers common DAW (digital audio workstation) features like a global transport for scheduling events and prebuilt synths and effects. For signal-processing programmers (coming from languages like Max/MSP), Tone provides a wealth of high performance, low latency building blocks and DSP modules to build your own synthesizers, effects, and complex control signals.

[API](http://tonejs.org/docs/)
[API](https://tonejs.github.io/docs/)

[Examples](http://tonejs.org/examples/)
[Examples](https://tonejs.github.io/examples/)

# Demos

* [Chrome Music Lab - Google Creative Lab](https://musiclab.chromeexperiments.com)
* [Groove Pizza - NYU Music Experience Design Lab](https://apps.musedlab.org/groovepizza/)
* [Jazz.Computer - Yotam Mann](http://jazz.computer/)
* [motionEmotion - Karen Peng, Jason Sigal](http://motionemotion.herokuapp.com/)
* [p5.sound - build with Tone.js](https://github.com/processing/p5.js-sound)
* [Hypercube - @eddietree](http://eddietree.github.io/hypercube/)
* [Random Commander - Jake Albaugh](http://randomcommander.io/)
* [Musical Chord Progression Arpeggiator - Jake Albaugh](http://codepen.io/jakealbaugh/full/qNrZyw/)
* [Tone.js + NexusUI - Ben Taylor](http://taylorbf.github.io/Tone-Rack/)
* [Solarbeat - Luke Twyman](http://www.whitevinyldesign.com/solarbeat/)
* [Wind - João Costa](http://wind.joaocosta.co)
* [Block Chords - Abe Rubenstein](http://dev.abe.sh/block-chords/)
* [This is Not a Machine Learning - David Karam](http://posttool.github.io/)
* [Airjam - Seth Kranzler, Abe Rubenstein, and Teresa Lamb](http://airjam.band/)
* [Calculaural - Matthew Hasbach](https://github.com/mjhasbach/calculaural)
* [Scratch + Tone.js - Eric Rosenbaum](http://ericrosenbaum.github.io/tone-synth-extension/)
* [Game of Reich - Ben Taylor](http://nexusosc.com/gameofreich/)
* [Yume - Helios + Luke Twyman](http://www.unseen-music.com/yume/)
* [TR-808 - Gregor Adams](http://codepen.io/pixelass/full/adyLPR)
* [Tweet FM - Mike Mitchell](https://tweet-fm.herokuapp.com/)
* [TextXoX - Damon Holzborn](http://rustleworks.com/textxox/)
* [Stepping - John Hussey](http://stepping.audio/)
* [Limp Body Beat](http://www.adultswim.com/etcetera/limp-body-beat/)
* [MsCompose 95 - Autotel](http://autotel.co/mscompose95/)
* [Pedalboard - Micha Hanselmann](https://deermichel.github.io/pedalboard/)
* [Keyboard Boogie - Douglas Tarr](http://douglastarr.com/keyboard-boogie)

Using Tone.js? I'd love to hear it: [email protected]
Using Tone.js? I'd love to hear it: [email protected]

# Installation

* CDN - [full](http://cdn.tonejs.org/latest/Tone.js) | [min](http://cdn.tonejs.org/latest/Tone.min.js)
* CDN - [full](https://tonejs.github.io/CDN/latest/Tone.js) | [min](https://tonejs.github.io/CDN/latest/Tone.min.js)
* [bower](http://bower.io/) - `bower install tone`
* [npm](https://www.npmjs.org/) - `npm install tone`

Expand All @@ -38,75 +46,73 @@ Using Tone.js? I'd love to hear it: [email protected]
# Hello Tone

```javascript
//create one of Tone's built-in synthesizers and connect it to the master output
var synth = new Tone.SimpleSynth().toMaster();
//create a synth and connect it to the master output (your speakers)
var synth = new Tone.Synth().toMaster();

//play a middle c for the duration of an 8th note
//play a middle 'C' for the duration of an 8th note
synth.triggerAttackRelease("C4", "8n");
```

[SimpleSynth](http://tonejs.org/docs/#SimpleSynth) is a single oscillator, single envelope synthesizer. It's [ADSR envelope](https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope) has two phases: the attack and the release. These can be triggered by calling `triggerAttack` and `triggerRelease` separately, or combined as shown above. The first argument of `triggerAttackRelease` is the frequency, which can be given either a number (like `440`) or as "pitch-octave" notation (like `"D#2"`). The second argument is the duration of the envelope's sustain (i.e. how long the note is held for). The third (optional) argument of `triggerAttackRelease` is the time the attack should start. With no argument, the time will evaluate to "now" and play immediately. Passing in a time value let's you schedule the event in the future.
#### Tone.Synth

### Time
[Tone.Synth](https://tonejs.github.io/docs/#Synth) is a basic synthesizer with a single [oscillator](https://tonejs.github.io/docs/#OmniOscillator) and an [ADSR envelope](https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope).

Any method which takes a time as a parameter will accept either a number or a string. Numbers will be taken literally as the time in seconds and strings can encode time expressions in terms of the current tempo. For example `"4n"` is a quarter-note, `"8t"` is an eighth-note triplet, and `"1m"` is one measure. Any value prefixed with `"+"` will be added to the current time. To trigger the same note one measure from now:
#### triggerAttackRelease

```javascript
synth.triggerAttackRelease("C4", "8n", "+1m");
```
The "attack" of an envelope is the period when the amplitude is rising, and the "release" is when it is falling back to 0. These two methods can be invoked separately as `triggerAttack` and `triggerRelease`, or combined as shown above. The first argument is the frequency which can either be a number (like `440`) or as "pitch-octave" notation (like `"D#2"`). The second argument is how long the note should be held before triggering the release phases. An optional third argument schedules the event for some time in the future. With no third argument, the note will play immediately.

#### Time

In the examples above, instead of using the time in seconds (for an 8th note at 120 BPM it would be 0.25 seconds), any method which takes time as an argument can accept a number or a string. Numbers will be taken literally as the time in seconds and strings can encode time expressions in terms of the current tempo. For example `"4n"` is a quarter-note, `"8t"` is an eighth-note triplet, and `"1m"` is one measure.

[Read about Time encodings.](https://github.com/Tonejs/Tone.js/wiki/Time)

# Scheduling

### Transport

Time expressions are evaluated against the Transport's BPM. [Tone.Transport](http://tonejs.org/docs/#Transport) is the master timekeeper, allowing for application-wide synchronization of sources, signals and events along a shared timeline. Callbacks scheduled with Tone.Transport will be invoked right before the scheduled time with the exact time of the event is passed in as the first parameter to the callback.

```javascript
//schedule a callback on the second beat of the first measure
Tone.Transport.schedule(function(time){
//schedule the synth's attackRelease using the passed-in time
synth.triggerAttackRelease("C4", "8n", time);
}, "1:2:0");

//start the transport
Tone.Transport.start();
```
[Read more about scheduling events with the Transport.](https://github.com/Tonejs/Tone.js/wiki/Transport)
[Tone.Transport](https://tonejs.github.io/docs/#Transport) is the master timekeeper, allowing for application-wide synchronization of sources, signals and events along a shared timeline. Time expressions (like the ones above) are evaluated against the Transport's BPM which can be set like this: `Tone.Transport.bpm.value = 120`.

### Loops

Instead of scheduling events directly on the Transport, Tone.js provides a few higher-level classes for working with events. [Tone.Loop](http://tonejs.org/docs/#Loop) is a simple way to create a looped callback that can be scheduled to start and stop.
Tone.js provides higher-level abstractions for scheduling events. [Tone.Loop](https://tonejs.github.io/docs/#Loop) is a simple way to create a looped callback that can be scheduled to start and stop.

```javascript
//play a note every quarter-note
var loop = new Tone.Loop(function(time){
synth.triggerAttackRelease("C2", "8n", time);
}, "4n");
```

Since Javascript timing is not sample-accurate, the precise time of the event is passed into the callback function. This time should be used to schedule events within the loop.

You can then start and stop the loop along the Transport's timeline.

```javascript
//loop between the first and fourth measures of the Transport's timeline
loop.start("1m").stop("4m");
```

Start the Transport to hear the looped notes:
Then start the Transport to hear the loop:

```javascript
Transport.start();
```

[Read about Tone.js' Event classes.](https://github.com/Tonejs/Tone.js/wiki/Events)
[Read about Tone.js' Event classes](https://github.com/Tonejs/Tone.js/wiki/Events) and [scheduling events with the Transport.](https://github.com/Tonejs/Tone.js/wiki/Transport)

# Instruments

Tone has a number of instruments which all inherit from the same [Instrument base class](http://tonejs.org/docs/#Instrument), giving them a common API for playing notes. [Tone.MonoSynth](http://tonejs.org/docs/#MonoSynth) is composed of one oscillator, one filter, and two envelopes connected to the amplitude and the filter frequency.
Tone has a number of instruments which all inherit from the same [Instrument base class](https://tonejs.github.io/docs/#Instrument), giving them a common API for playing notes. [Tone.Synth](https://tonejs.github.io/docs/#Synth) is composed of one oscillator and an amplitude envelope.

```javascript
//pass in some initial values for the filter and filter envelope
var monoSynth = new Tone.MonoSynth({
"filter" : {
"type" : "lowpass",
"Q" : 7
var synth = new Tone.Synth({
"oscillator" : {
"type" : "pwm",
"modulationFrequency" : 0.2
},
"filterEnvelope" : {
"envelope" : {
"attack" : 0.02,
"decay" : 0.1,
"sustain" : 0.2,
Expand All @@ -115,14 +121,14 @@ var monoSynth = new Tone.MonoSynth({
}).toMaster();

//start the note "D3" one second from now
monoSynth.triggerAttack("D3", "+1");
synth.triggerAttack("D3", "+1");
```

All instruments are monophonic (one voice) but can be made polyphonic when the constructor is passed in as the second argument to [Tone.PolySynth](http://tonejs.org/docs/#PolySynth).
All instruments are monophonic (one voice) but can be made polyphonic when the constructor is passed in as the second argument to [Tone.PolySynth](https://tonejs.github.io/docs/#PolySynth).

```javascript
//a 4 voice MonoSynth
var polySynth = new Tone.PolySynth(4, Tone.MonoSynth).toMaster();
//a 4 voice Synth
var polySynth = new Tone.PolySynth(4, Tone.Synth).toMaster();
//play a chord
polySynth.triggerAttackRelease(["C4", "E4", "G4", "B4"], "2n");
```
Expand All @@ -131,7 +137,7 @@ polySynth.triggerAttackRelease(["C4", "E4", "G4", "B4"], "2n");

# Effects

In the above examples, the synthesizer was always connected directly to the [master output](http://tonejs.org/docs/#Master), but the output of the synth could also be routed through one (or more) effects before going to the speakers.
In the above examples, the synthesizer was always connected directly to the [master output](https://tonejs.github.io/docs/#Master), but the output of the synth could also be routed through one (or more) effects before going to the speakers.

```javascript
//create a distortion effect
Expand All @@ -144,7 +150,7 @@ synth.connect(distortion);

# Sources

Tone has a few basic audio sources like [Tone.Oscillator](http://tonejs.org/docs/#Oscillator) which has sine, square, triangle, and sawtooth waveforms, a buffer player ([Tone.Player](http://tonejs.org/docs/#Player)), a noise generator ([Tone.Noise]((http://tonejs.org/docs/#Noise))), two additional oscillator types ([pwm](http://tonejs.org/docs/#PWMOscillator), [pulse](http://tonejs.org/docs/#PulseOscillator)) and [external audio input](http://tonejs.org/docs/#Microphone) (when [WebRTC is supported](http://caniuse.com/#feat=stream)).
Tone has a few basic audio sources like [Tone.Oscillator](https://tonejs.github.io/docs/#Oscillator) which has sine, square, triangle, and sawtooth waveforms, a buffer player ([Tone.Player](https://tonejs.github.io/docs/#Player)), a noise generator ([Tone.Noise]((https://tonejs.github.io/docs/#Noise))), two additional oscillator types ([pwm](https://tonejs.github.io/docs/#PWMOscillator), [pulse](https://tonejs.github.io/docs/#PulseOscillator)) and [external audio input](https://tonejs.github.io/docs/#Microphone) (when [WebRTC is supported](http://caniuse.com/#feat=stream)).

```javascript
//a pwm oscillator which is connected to the speaker and started right away
Expand All @@ -165,16 +171,18 @@ Tone.js creates an AudioContext when it loads and shims it for maximum browser c

# MIDI

To use MIDI files, you'll first need to convert them into a JSON format which Tone.js can understand using [MidiConvert](http://tonejs.github.io/MidiConvert/).
To use MIDI files, you'll first need to convert them into a JSON format which Tone.js can understand using [MidiConvert](https://tonejs.github.io/MidiConvert/).

# Performance

Tone.js uses only one ScriptProcessorNode (in Tone.Meter). The rest of Tone's modules find a native Web Audio component workaround, making extensive use of the GainNode and WaveShaperNode especially, which enables Tone.js to work well on both desktop and mobile browsers. While the ScriptProcessorNode is extremely powerful, it introduces a lot of latency and the potential for glitches more than any other node.
Tone.js makes extensive use of the native Web Audio Nodes such as the GainNode and WaveShaperNode for all signal processing, which enables Tone.js to work well on both desktop and mobile browsers. It uses no ScriptProcessorNodes.

# Contributing

There are many ways to contribute to Tone.js. Check out [this wiki](https://github.com/Tonejs/Tone.js/wiki/Contributing) if you're interested.

If you have questions (or answers) that are not necessarily bugs/issues, please post them to the [forum](https://groups.google.com/forum/#!forum/tonejs).

# References and Inspiration

* [Tuna.js](https://github.com/Dinahmoe/tuna)
Expand Down
Loading

0 comments on commit c904797

Please sign in to comment.