Tone.js/examples/monoSynth.html

100 lines
2.9 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
2014-06-25 16:47:47 +00:00
<title>MONOSYNTH</title>
2014-09-06 19:35:31 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
2014-09-02 04:25:38 +00:00
<script type="text/javascript" src="./deps/jquery.min.js"></script>
<script type="text/javascript" src="../build/Tone.js"></script>
2014-09-05 03:56:34 +00:00
<script type="text/javascript" src="../build/Tone.Preset.js"></script>
2015-02-20 05:59:19 +00:00
<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>
<script type="text/javascript" src="./deps/qwerty-hancock.js"></script>
2015-02-20 05:59:19 +00:00
<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>
2015-02-20 05:59:19 +00:00
<style type="text/css">
#Amplitude {
2015-02-24 03:14:51 +00:00
/*position: relative;*/
width: calc(40% - 10px)!important;
}
#FilterEnvelope {
/*position: relative;*/
width: calc(60% - 10px)!important;
}
.FilterEnvelope.Envelope {
width: 100%!important;
}
.Envelope {
width: 100%!important;
2015-02-20 05:59:19 +00:00
}
</style>
<div id="Explanation">
MonoSynth
<br>
<br>
MonoSynth is a monophonic synthesizer composed simply of one oscillator and one filter each with their own independent envelope.
</div>
<div id="Content">
<div id="KeyRack">
<div id="Keyboard"></div>
2014-09-02 04:25:38 +00:00
</div>
2015-02-20 05:59:19 +00:00
<div id="Oscillator"></div>
<div id="Envelope">
<div id="Amplitude"></div>
<div id="FilterEnvelope"></div>
2014-09-02 04:25:38 +00:00
</div>
2015-02-24 03:14:51 +00:00
<div id="Filter"></div>
2015-02-26 16:25:16 +00:00
<div id="Presets"></div>
</div>
2015-02-20 05:59:19 +00:00
<script id="ToneCode" type="text/javascript">
var synth = new Tone.MonoSynth().toMaster();
</script>
<script id="GUI" type="text/javascript">
2014-09-02 04:25:38 +00:00
2015-02-20 05:59:19 +00:00
Interface.Rack("KeyRack", "Keyboard", true).open();
//the keyboard
2014-09-02 04:25:38 +00:00
var keyboard = new QwertyHancock({
id: "Keyboard",
2015-02-20 05:59:19 +00:00
width: $("#KeyRack").width(),
2014-09-02 04:25:38 +00:00
height: 75,
2015-02-20 05:59:19 +00:00
octaves : 3,
startNote: "A2",
2014-09-02 04:25:38 +00:00
});
keyboard.keyDown = function(note, freq){
synth.triggerAttack(freq);
};
2014-09-02 16:15:20 +00:00
keyboard.keyUp = function(){
2014-09-02 04:25:38 +00:00
synth.triggerRelease();
};
2015-02-20 05:59:19 +00:00
//the oscillator
Interface.Rack("Oscillator", "Oscillator", true);
2015-02-28 23:07:12 +00:00
Interface.DropDown("Oscillator", synth.oscillator, "type", ["sine", "square", "triangle", "sawtooth", "pwm", "pulse"]).listen();
2015-02-20 05:59:19 +00:00
//the envelopes
Interface.Rack("Envelope", "Envelopes", true);
var ampGroup = Interface.Group("Amplitude", "Amplitude");
2015-02-28 23:07:12 +00:00
Interface.AmplitudeEnvelope(ampGroup, synth.envelope).listen();
2015-02-20 05:59:19 +00:00
var filtGroup = Interface.Group("FilterEnvelope", "Filter");
2015-02-28 23:07:12 +00:00
Interface.FilterEnvelope(filtGroup, synth.filterEnvelope).listen();
2015-02-24 03:14:51 +00:00
Interface.Rack("Filter", "Filter", true);
2015-02-28 23:07:12 +00:00
var type = Interface.DropDown("Filter", synth.filter, "type", ["lowpass", "highpass", "bandpass"]).listen();
2015-02-24 03:14:51 +00:00
var Q = Interface.Slider("Filter", synth.filter, "Q", 0.1, 20);
2015-02-26 16:25:16 +00:00
Interface.Rack("Presets", "Presets", true);
Interface.Presets("Presets", synth);
2014-09-02 04:25:38 +00:00
</script>
</body>
</html>