Tone.js/examples/jump.html

285 lines
6.3 KiB
HTML
Raw Normal View History

2016-01-30 18:40:19 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FatOscillator</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" type="image/png" sizes="174x174" href="./style/favicon.png">
<script type="text/javascript" src="../build/Tone.js"></script>
<script type="text/javascript" src="./scripts/jquery.min.js"></script>
<script type="text/javascript" src="./scripts/draggabilly.js"></script>
2016-07-07 21:31:06 +00:00
<script type="text/javascript" src="https://tonejs.github.io/Logo/build/Logo.js"></script>
2016-03-04 22:38:32 +00:00
<script type="text/javascript" src="./scripts/StartAudioContext.js"></script>
2016-01-30 18:40:19 +00:00
<script type="text/javascript" src="./scripts/Interface.js"></script>
<link rel="stylesheet" type="text/css" href="./style/examples.css">
<script type="text/javascript">
// jshint ignore: start
</script>
</head>
<body>
<style type="text/css">
</style>
<div id="Content">
<div id="Title">Supersaw</div>
<div id="Explanation">
<a href="https://tonejs.github.io/docs/#FatOscillator">Tone.FatOscillator</a> creates multiple oscillators
2016-01-30 18:40:19 +00:00
and detunes them slightly from each other to thicken the sound. The <code>count</code> parameter sets
the number of oscillators and <code>spread</code> sets the total spread (in cents) between the oscillators.
<br><br>
FatOscillator is also available in <a href="https://tonejs.github.io/docs/#OmniOscillator">Tone.OmniOscillator</a>
by prefixing another type with "fat", then use the count and spread to control the number and detune of the oscillators. To create a "supersaw": <code>omniOscillator.type = "fatsawtooth"</code>.
2016-01-30 18:40:19 +00:00
<br><br>
<a href="http://www.midiworld.com/files/1121/">Jump by Van Halen MIDI</a> converted using <a href="http://tonejs.github.io/MidiConvert/">MidiConvert</a>
</div>
</div>
<script type="text/javascript">
var synth = new Tone.PolySynth(3, Tone.Synth, {
2016-01-30 18:40:19 +00:00
"oscillator" : {
"type" : "fatsawtooth",
"count" : 3,
"spread" : 30
},
"envelope": {
"attack": 0.01,
"decay": 0.1,
"sustain": 0.5,
"release": 0.4,
"attackCurve" : "exponential"
},
}).toMaster();
// Van Halen - Jump MIDI from http://www.midiworld.com/files/1121/
// converted using
var part = new Tone.Part(function(time, note){
synth.triggerAttackRelease(note.noteName, note.duration, time, note.velocity);
}, [
{
2016-07-07 17:59:45 +00:00
"time": "192i",
2016-01-30 18:40:19 +00:00
"noteName": "G4",
"velocity": 0.8110236220472441,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "192i",
2016-01-30 18:40:19 +00:00
"noteName": "B4",
"velocity": 0.7874015748031497,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "192i",
2016-01-30 18:40:19 +00:00
"noteName": "D5",
"velocity": 0.8031496062992126,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "480i",
2016-01-30 18:40:19 +00:00
"noteName": "G4",
"velocity": 0.7559055118110236,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "480i",
2016-01-30 18:40:19 +00:00
"noteName": "C5",
"velocity": 0.6850393700787402,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "480i",
2016-01-30 18:40:19 +00:00
"noteName": "E5",
"velocity": 0.6771653543307087,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "768i",
2016-01-30 18:40:19 +00:00
"noteName": "F4",
"velocity": 0.8661417322834646,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "768i",
2016-01-30 18:40:19 +00:00
"noteName": "A4",
"velocity": 0.8346456692913385,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "768i",
2016-01-30 18:40:19 +00:00
"noteName": "C5",
"velocity": 0.8188976377952756,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1056i",
2016-01-30 18:40:19 +00:00
"noteName": "F4",
"velocity": 0.7007874015748031,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1056i",
2016-01-30 18:40:19 +00:00
"noteName": "A4",
"velocity": 0.6850393700787402,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1056i",
2016-01-30 18:40:19 +00:00
"noteName": "C5",
"velocity": 0.6614173228346457,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1248i",
2016-01-30 18:40:19 +00:00
"noteName": "G4",
"velocity": 0.6771653543307087,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1248i",
2016-01-30 18:40:19 +00:00
"noteName": "B4",
"velocity": 0.6771653543307087,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1248i",
2016-01-30 18:40:19 +00:00
"noteName": "D5",
"velocity": 0.7165354330708661,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1440i",
2016-01-30 18:40:19 +00:00
"noteName": "G4",
"velocity": 0.8818897637795275,
2016-07-07 17:59:45 +00:00
"duration": "248i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1440i",
2016-01-30 18:40:19 +00:00
"noteName": "B4",
"velocity": 0.84251968503937,
2016-07-07 17:59:45 +00:00
"duration": "248i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1440i",
2016-01-30 18:40:19 +00:00
"noteName": "D5",
"velocity": 0.8818897637795275,
2016-07-07 17:59:45 +00:00
"duration": "248i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1728i",
2016-01-30 18:40:19 +00:00
"noteName": "G4",
"velocity": 0.8267716535433071,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1728i",
2016-01-30 18:40:19 +00:00
"noteName": "C5",
"velocity": 0.8031496062992126,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "1728i",
2016-01-30 18:40:19 +00:00
"noteName": "E5",
"velocity": 0.8188976377952756,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "2016i",
2016-01-30 18:40:19 +00:00
"noteName": "F4",
"velocity": 0.7086614173228346,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "2016i",
2016-01-30 18:40:19 +00:00
"noteName": "A4",
"velocity": 0.7244094488188977,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "2016i",
2016-01-30 18:40:19 +00:00
"noteName": "C5",
"velocity": 0.7007874015748031,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "2208i",
2016-01-30 18:40:19 +00:00
"noteName": "C4",
"velocity": 0.9921259842519685,
2016-07-07 17:59:45 +00:00
"duration": "296i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "2208i",
2016-01-30 18:40:19 +00:00
"noteName": "F4",
"velocity": 0.968503937007874,
2016-07-07 17:59:45 +00:00
"duration": "200i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "2208i",
2016-01-30 18:40:19 +00:00
"noteName": "A4",
"velocity": 0.9606299212598425,
2016-07-07 17:59:45 +00:00
"duration": "208i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "2400i",
2016-01-30 18:40:19 +00:00
"noteName": "E4",
"velocity": 0.7559055118110236,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "2400i",
2016-01-30 18:40:19 +00:00
"noteName": "G4",
"velocity": 0.7007874015748031,
2016-07-07 17:59:45 +00:00
"duration": "104i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "2592i",
2016-01-30 18:40:19 +00:00
"noteName": "C4",
"velocity": 0.968503937007874,
2016-07-07 17:59:45 +00:00
"duration": "488i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "2592i",
2016-01-30 18:40:19 +00:00
"noteName": "D4",
"velocity": 0.9448818897637795,
2016-07-07 17:59:45 +00:00
"duration": "488i"
2016-01-30 18:40:19 +00:00
},
{
2016-07-07 17:59:45 +00:00
"time": "2592i",
2016-01-30 18:40:19 +00:00
"noteName": "G4",
"velocity": 0.937007874015748,
2016-07-07 17:59:45 +00:00
"duration": "488i"
2016-01-30 18:40:19 +00:00
}
]).start(0);
part.loop = true;
part.loopEnd = "4m";
Tone.Transport.bpm.value = 132;
</script>
<script id="GUI" type="text/javascript">
$(function(){
Interface.Button({
2016-01-30 18:40:19 +00:00
key : 32,
type : "toggle",
text : "Start",
activeText : "Stop",
start : function(){
Tone.Transport.start("+0.1");
2016-01-30 18:40:19 +00:00
},
end : function(){
Tone.Transport.stop();
}
});
});
</script>
</style>
</body>
</html>