Tone.js/examples/lfo.html

105 lines
2.6 KiB
HTML
Raw Normal View History

2014-03-15 03:17:18 +00:00
<html>
<head>
2014-03-15 03:30:00 +00:00
<title>LFO</title>
2014-03-15 03:17:18 +00:00
2014-09-06 19:35:31 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
2014-08-29 16:25:10 +00:00
<script type="text/javascript" src="./deps/jquery.min.js"></script>
<script type="text/javascript" src="./deps/jquery-ui.js"></script>
<script type="text/javascript" src="./deps/jquery.ui.touch-punch.js"></script>
<script type="text/javascript" src="../build/Tone.js"></script>
2014-08-29 16:25:10 +00:00
<script type="text/javascript" src="./Widgets.js"></script>
<script type="text/javascript" src="./ExampleList.js"></script>
<link rel="stylesheet" type="text/css" href="./style/widgets.css">
<link rel="stylesheet" type="text/css" href="./style/jquery-ui.css">
2014-03-15 03:17:18 +00:00
</head>
<body>
2014-08-29 16:25:10 +00:00
<div id="Container">
<div id="Explanation">
Low Frequency Oscillators
<br>
<br>
<a href="http://en.wikipedia.org/wiki/Low-frequency_oscillation">LFOs</a> are a powerful musical tool.
2014-09-02 16:15:29 +00:00
LFOs can be connected to Tone.Signals and AudioParams to control nearly anything. This example uses LFOs
to control the oscillators pitch, detune, delay time, and filter frequency to make some crazy sounds.
2014-08-29 16:25:10 +00:00
</div>
<div id="Content"></div>
</div>
<script type="text/javascript">
/* globals Tone, GUI */
2014-09-05 04:58:19 +00:00
var osc = new Tone.Oscillator(110, "triangle");
osc.toMaster();
2014-09-06 19:35:31 +00:00
var freqLFO = new Tone.LFO(0.1, 80, 160);
2014-09-05 04:58:19 +00:00
freqLFO.setType("square");
freqLFO.connect(osc.frequency);
2014-09-06 19:35:31 +00:00
var detuneLFO = new Tone.LFO(12, -80, 80);
2014-09-05 04:58:19 +00:00
detuneLFO.connect(osc.detune);
var amplitudeLFO = new Tone.LFO(4, 0.05, 0.5);
amplitudeLFO.connect(osc.output.gain);
2014-08-29 16:25:10 +00:00
// GUI //
var content = $("#Content");
new GUI.TopBar(Tone);
new GUI.Checkbox(content, function(on){
if (on){
2014-09-05 04:58:19 +00:00
osc.start();
freqLFO.start();
detuneLFO.start();
amplitudeLFO.start();
} else {
2014-09-05 04:58:19 +00:00
osc.stop();
freqLFO.stop();
detuneLFO.stop();
amplitudeLFO.stop();
}
2014-08-29 16:25:10 +00:00
}, "start", "stop");
2014-09-05 04:58:19 +00:00
//sliders
var freqSlider = new GUI.Slider(content, function(val){
var scaled = val * 2 + 0.1;
freqLFO.setFrequency(scaled);
return scaled;
}, 1, "pitch LFO");
freqSlider.render(0.1);
var detuneSlider = new GUI.Slider(content, function(val){
var scaled = val * 20 + 5;
detuneLFO.setFrequency(scaled);
return scaled;
}, 1, "detune LFO");
detuneSlider.render(0.5);
var amplitudeSlider = new GUI.Slider(content, function(val){
var scaled = val * 4 + 1;
amplitudeLFO.setFrequency(scaled);
return scaled;
}, 1, "amplitude LFO");
amplitudeSlider.render(0.75);
2014-08-29 16:25:10 +00:00
2014-03-15 03:17:18 +00:00
</script>
2014-08-29 16:25:10 +00:00
<style type="text/css">
#Content {
text-align: center;
width: 220px;
height: 250px;
}
.Slider {
2014-09-02 16:15:29 +00:00
margin-top: 15px;
2014-08-29 16:25:10 +00:00
}
.Checkbox {
width: 100%;
}
</style>
2014-03-15 03:17:18 +00:00
</body>
</html>