Skip to content

Commit c904797

Browse files
committed
Merge branch 'dev'
2 parents 5c92595 + 439583b commit c904797

File tree

212 files changed

+21254
-16027
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+21254
-16027
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ test/Main.js
4646
build/p5.Tone.min.js
4747
build/p5.Tone.js
4848

49-
.DS_Store
49+
.DS_Store
50+
examples/graph.html

.jshintrc

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"GainNode" : false,
1919
"AudioNode" : false,
2020
"AudioParam" : false,
21+
"AnalyserNode" : false,
2122
"WaveShaperNode" : false,
2223
"DynamicsCompressorNode" : false,
2324
"MediaStreamTrack" : false

.travis.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: node_js
2+
node_js:
3+
- "4.1"
4+
before_install:
5+
- export CHROME_BIN=chromium-browser
6+
- export DISPLAY=:99.0
7+
- sh -e /etc/init.d/xvfb start
8+
before_script:
9+
- cd gulp
10+
- npm install -g karma
11+
- npm install -g gulp
12+
- npm install
13+
script: gulp karma-test

CHANGELOG.md

+28
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
### r7
2+
3+
* MetalSynth creates metalic, cymbal sounds
4+
* DrumSynth -> MembraneSynth
5+
* FMOscillator, AMOscillator types
6+
* FatOscillator creates multiple oscillators and detunes them slightly
7+
* FM, AM, Fat Oscillators incorporated into OmniOscillator
8+
* Simplified FM and AM Synths and APIs
9+
* Panner.pan is between -1,1 like the StereoPannerNode
10+
* Pruned away unused (or little used) Signal classes.
11+
* All this functionality will be available when the AudioWorkerNode is introduced.
12+
* Clock uses Web Workers instead of requestAnimationFrame which allows it to run in the background.
13+
* Removed `startMobile`. Using [StartAudioContext](https://github.com/tambien/StartAudioContext) in examples.
14+
* Automated test runner using [Travis CI](https://travis-ci.org/Tonejs/Tone.js/)
15+
* Simplified NoiseSynth by removing filter and filter envelope.
16+
* Added new timing primitive types: Time, Frequency, TransportTime.
17+
* Switching parameter position of type and size in Tone.Analyser
18+
* Tone.Meter uses Tone.Analyser instead of ScriptProcessorNode.
19+
* Tone.Envelope has 5 new attack/release curves: "sine", "cosine", "bounce", "ripple", "step"
20+
* Renamed Tone.SimpleSynth -> Tone.Synth
21+
* Tone.Buffers combines multiple buffers
22+
* Tone.BufferSource a low-level wrapper, and Tone.MultiPlayer which is good for multisampled instruments.
23+
* Tone.GrainPlayer: granular synthesis buffer player.
24+
* Simplified Sampler
25+
26+
DEPRECATED:
27+
* Removed SimpleFM and SimpleAM
28+
129
### r6
230

331
* Added PitchShift and Vibrato Effect.

README.md

+55-47
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
11
Tone.js
22
=========
33

4-
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.
4+
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.
55

6-
[API](http://tonejs.org/docs/)
6+
[API](https://tonejs.github.io/docs/)
77

8-
[Examples](http://tonejs.org/examples/)
8+
[Examples](https://tonejs.github.io/examples/)
99

1010
# Demos
1111

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

28-
Using Tone.js? I'd love to hear it: [email protected]
36+
Using Tone.js? I'd love to hear it: [email protected]
2937

3038
# Installation
3139

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

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

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

44-
//play a middle c for the duration of an 8th note
52+
//play a middle 'C' for the duration of an 8th note
4553
synth.triggerAttackRelease("C4", "8n");
4654
```
4755

48-
[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.
56+
#### Tone.Synth
4957

50-
### Time
58+
[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).
5159

52-
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:
60+
#### triggerAttackRelease
5361

54-
```javascript
55-
synth.triggerAttackRelease("C4", "8n", "+1m");
56-
```
62+
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.
63+
64+
#### Time
65+
66+
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.
5767

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

70+
# Scheduling
71+
6072
### Transport
6173

62-
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.
63-
64-
```javascript
65-
//schedule a callback on the second beat of the first measure
66-
Tone.Transport.schedule(function(time){
67-
//schedule the synth's attackRelease using the passed-in time
68-
synth.triggerAttackRelease("C4", "8n", time);
69-
}, "1:2:0");
70-
71-
//start the transport
72-
Tone.Transport.start();
73-
```
74-
[Read more about scheduling events with the Transport.](https://github.com/Tonejs/Tone.js/wiki/Transport)
74+
[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`.
7575

7676
### Loops
7777

78-
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.
78+
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.
7979

8080
```javascript
8181
//play a note every quarter-note
8282
var loop = new Tone.Loop(function(time){
8383
synth.triggerAttackRelease("C2", "8n", time);
8484
}, "4n");
85+
```
86+
87+
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.
8588

89+
You can then start and stop the loop along the Transport's timeline.
90+
91+
```javascript
8692
//loop between the first and fourth measures of the Transport's timeline
8793
loop.start("1m").stop("4m");
8894
```
8995

90-
Start the Transport to hear the looped notes:
96+
Then start the Transport to hear the loop:
9197

9298
```javascript
9399
Transport.start();
94100
```
95101

96-
[Read about Tone.js' Event classes.](https://github.com/Tonejs/Tone.js/wiki/Events)
102+
[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)
97103

98104
# Instruments
99105

100-
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.
106+
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.
101107

102108
```javascript
103109
//pass in some initial values for the filter and filter envelope
104-
var monoSynth = new Tone.MonoSynth({
105-
"filter" : {
106-
"type" : "lowpass",
107-
"Q" : 7
110+
var synth = new Tone.Synth({
111+
"oscillator" : {
112+
"type" : "pwm",
113+
"modulationFrequency" : 0.2
108114
},
109-
"filterEnvelope" : {
115+
"envelope" : {
110116
"attack" : 0.02,
111117
"decay" : 0.1,
112118
"sustain" : 0.2,
@@ -115,14 +121,14 @@ var monoSynth = new Tone.MonoSynth({
115121
}).toMaster();
116122

117123
//start the note "D3" one second from now
118-
monoSynth.triggerAttack("D3", "+1");
124+
synth.triggerAttack("D3", "+1");
119125
```
120126

121-
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).
127+
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).
122128

123129
```javascript
124-
//a 4 voice MonoSynth
125-
var polySynth = new Tone.PolySynth(4, Tone.MonoSynth).toMaster();
130+
//a 4 voice Synth
131+
var polySynth = new Tone.PolySynth(4, Tone.Synth).toMaster();
126132
//play a chord
127133
polySynth.triggerAttackRelease(["C4", "E4", "G4", "B4"], "2n");
128134
```
@@ -131,7 +137,7 @@ polySynth.triggerAttackRelease(["C4", "E4", "G4", "B4"], "2n");
131137

132138
# Effects
133139

134-
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.
140+
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.
135141

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

145151
# Sources
146152

147-
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)).
153+
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)).
148154

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

166172
# MIDI
167173

168-
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/).
174+
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/).
169175

170176
# Performance
171177

172-
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.
178+
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.
173179

174180
# Contributing
175181

176182
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.
177183

184+
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).
185+
178186
# References and Inspiration
179187

180188
* [Tuna.js](https://github.com/Dinahmoe/tuna)

0 commit comments

Comments
 (0)