mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
97 lines
No EOL
2.6 KiB
HTML
97 lines
No EOL
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>SCORE</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
|
|
|
<script type="text/javascript" src="../build/Tone.js"></script>
|
|
<script type="text/javascript" src="../build/Tone.Preset.js"></script>
|
|
<script type="text/javascript" src="./deps/jquery.min.js"></script>
|
|
<script type="text/javascript" src="./deps/qwerty-hancock.js"></script>
|
|
<script type="text/javascript" src="./deps/nexusUI.js"></script>
|
|
<script type="text/javascript" src="./deps/prism.js"></script>
|
|
<script type="text/javascript" src="./scripts/Interface.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="./style/examples.css">
|
|
<link rel="stylesheet" type="text/css" href="./style/prism.css">
|
|
|
|
<script type="text/javascript">
|
|
// jshint ignore: start
|
|
</script>
|
|
|
|
</head>
|
|
<body>
|
|
<style type="text/css">
|
|
|
|
</style>
|
|
<div id="Explanation">
|
|
Tone.Transport
|
|
<br>
|
|
<br>
|
|
Tone.Transport is the application-wide timekeeper. It uses an OscillatorNode
|
|
as it's clock source which enables sample-accurate scheduling as well as
|
|
tempo-curves and automation. This example uses Tone.Transport.setInterval
|
|
to invoke a callback every 16th note.
|
|
</div>
|
|
<div id="Content">
|
|
<div id="LoadingBar"></div>
|
|
<div id="Controls"></div>
|
|
<div id="Rack">
|
|
|
|
</div>
|
|
<div id="Code"></div>
|
|
</div>
|
|
<script id="ToneCode" type="text/javascript">
|
|
//setup a polyphonic sampler
|
|
var keys = new Tone.PolySynth(4, Tone.Sampler, {
|
|
"A" : "./audio/casio/A1.mp3",
|
|
"C#" : "./audio/casio/Cs2.mp3",
|
|
"E" : "./audio/casio/E2.mp3",
|
|
"F#" : "./audio/casio/Fs2.mp3",
|
|
}, {
|
|
"envelope" : {
|
|
"release" : 0.2
|
|
}
|
|
}).toMaster();
|
|
keys.volume.value = -15;
|
|
|
|
//keep track of steps and notes
|
|
var stepNumber = 0;
|
|
var noteNames = ["A", "C#", "E", "F#"];
|
|
|
|
//the repeated callback
|
|
Tone.Transport.setInterval(function(time){
|
|
//get the notes at the step
|
|
var column = matrix1.matrix[stepNumber];
|
|
for (var i = 0; i < 4; i++){
|
|
if (column[i] === 1){
|
|
keys.triggerAttackRelease(noteNames[i], "32n", time);
|
|
}
|
|
}
|
|
stepNumber++;
|
|
stepNumber = stepNumber % 16;
|
|
}, "16n");
|
|
|
|
//transport settings
|
|
Tone.Transport.loopEnd = "1m";
|
|
Tone.Transport.loop = true;
|
|
</script>
|
|
<script type="text/javascript">
|
|
Interface.Loading("LoadingBar");
|
|
Interface.Rack("Rack", "Transport");
|
|
Interface.StepSequencer("Rack", 32, 8).randomize();
|
|
Interface.Slider("Rack", Tone.Transport, "bpm", 100, 150);
|
|
Interface.Toggle("Rack", function(on){
|
|
if (on){
|
|
Tone.Transport.start();
|
|
} else {
|
|
Tone.Transport.stop();
|
|
}
|
|
});
|
|
Interface.Code("Code", "ToneCode");
|
|
|
|
</script>
|
|
</body>
|
|
</html> |