Tone.js/examples/pingPongDelay.html

110 lines
3.4 KiB
HTML
Raw Normal View History

2014-03-12 17:44:29 +00:00
<html>
<head>
<title>Ping Pong Delay</title>
<link rel="stylesheet" type="text/css" href="../style/GUI.css">
2014-03-12 17:44:29 +00:00
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
2014-03-12 20:29:43 +00:00
<script type="text/javascript" src="../src/core/AudioUnit.js"></script>
2014-03-14 00:03:14 +00:00
<script type="text/javascript" src="../src/core/Master.js"></script>
2014-03-12 17:44:29 +00:00
<script type="text/javascript" src="../src/components/Meter.js"></script>
2014-03-14 00:03:14 +00:00
<script type="text/javascript" src="../src/components/Player.js"></script>
2014-03-12 17:44:29 +00:00
<script type="text/javascript" src="../src/components/Envelope.js"></script>
<script type="text/javascript" src="../src/components/LFO.js"></script>
<script type="text/javascript" src="../src/components/Noise.js"></script>
<script type="text/javascript" src="../src/components/StereoSplit.js"></script>
<script type="text/javascript" src="../src/effects/Effect.js"></script>
<script type="text/javascript" src="../src/effects/FeedbackDelay.js"></script>
<script type="text/javascript" src="../src/effects/PingPongDelay.js"></script>
<script type="text/javascript" src="../src/components/Microphone.js"></script>
<script type="text/javascript" src="../src/GUI/GUI.js"></script>
2014-03-14 00:03:14 +00:00
<script type="text/javascript" src="../src/GUI/GUI.Bar.js"></script>
2014-03-12 17:44:29 +00:00
<script type="text/javascript" src="../src/GUI/GUI.Meter.js"></script>
2014-03-14 00:03:14 +00:00
<script type="text/javascript" src="../src/GUI/GUI.Fader.js"></script>
2014-03-14 15:28:35 +00:00
<script type="text/javascript" src="../src/GUI/GUI.ParamFader.js"></script>
<script type="text/javascript" src="../src/GUI/GUI.GainFader.js"></script>
2014-03-14 19:19:42 +00:00
<script type="text/javascript" src="../src/GUI/GUI.Compressor.js"></script>
2014-03-12 17:44:29 +00:00
</head>
<body>
<style type="text/css">
#meter {
2014-03-14 00:03:14 +00:00
width: auto;
2014-03-12 17:44:29 +00:00
text-align: center;
2014-03-14 00:03:14 +00:00
float: right;
position: absolute;
bottom: 10px;
right: 10px;
}
#fader {
position: absolute;
bottom: 10px;
right: 100px;
width: auto;
2014-03-12 17:44:29 +00:00
}
2014-03-14 15:28:35 +00:00
#MasterOut {
width: 160px;
height: 200px;
position: absolute;
bottom: 10px;
right: 0px;
}
#Trigger {
width: 100px;
height: 100px;
position: absolute;
top: 20px;
left: 20px;
background-color: blue;
color: white;
}
2014-03-12 17:44:29 +00:00
</style>
2014-03-14 15:28:35 +00:00
<div id='Trigger'>Press</div>
<div id='MasterOut'>
<div id='meter'></div>
<div id='fader'></div>
</div>
2014-03-12 17:44:29 +00:00
<script type="text/javascript">
2014-03-12 20:29:43 +00:00
var player = new AudioUnit.Player("../audio/A3.mp3");
var meter = new AudioUnit.Meter(2);
2014-03-14 15:28:35 +00:00
var env = new AudioUnit.Envelope(.05, .01, 0, 0);
var lfo = new AudioUnit.LFO(undefined, 1, .5, 1);
var noise = new AudioUnit.Noise();
var feedbackDelay = new AudioUnit.PingPongDelay(.25);
2014-03-14 00:03:14 +00:00
var meterGui = new AudioUnit.GUI.Meter($("#meter"), meter, "master", 20);
2014-03-14 15:28:35 +00:00
var fader = new AudioUnit.GUI.GainFader($("#fader"), AudioUnit.Master.output, "mstr");
2014-03-14 19:19:42 +00:00
var compGui = new AudioUnit.GUI.Compressor($("body"), AudioUnit.Master.limiter);
2014-03-12 17:44:29 +00:00
noise.connect(env);
2014-03-12 17:44:29 +00:00
env.connect(feedbackDelay);
feedbackDelay.setFeedback(.5);
2014-03-14 00:03:14 +00:00
feedbackDelay.toMaster();
2014-03-12 17:44:29 +00:00
2014-03-14 00:03:14 +00:00
//the master output meter
AudioUnit.Master.connect(meter);
2014-03-12 17:44:29 +00:00
player.load(function(){
// player.loop(0, 0, 1);
player.loop();
});
2014-03-14 15:28:35 +00:00
document.addEventListener('touchstart', function(e){
env.triggerAttack();
});
document.addEventListener('touchend', function(e){
env.triggerRelease();
});
$("#Trigger").bind("mousedown touchstart", function(e){
console.log('hi')
env.triggerAttack();
});
$("#Trigger").bind("mouseup touchend", function(e){
env.triggerRelease();
2014-03-12 17:44:29 +00:00
});
</script>
</body>
</html>