2014-04-06 00:47:59 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
2014-04-16 00:05:11 +00:00
|
|
|
<title>Effect Example</title>
|
2014-04-06 00:47:59 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
<script type="text/javascript" src="../build/Tone.js"></script>
|
2014-04-06 00:47:59 +00:00
|
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<input type='range'>
|
2014-06-18 17:40:27 +00:00
|
|
|
<form action="" id="noise">
|
|
|
|
Noise Type:
|
|
|
|
<input type="radio" name="noise" value="brown" checked>brown</input>
|
|
|
|
<input type="radio" name="noise" value="pink">pink</input>
|
|
|
|
<input type="radio" name="noise" value="white">white</input>
|
|
|
|
</form>
|
2014-04-06 00:47:59 +00:00
|
|
|
<script type="text/javascript">
|
|
|
|
|
2014-06-18 17:40:27 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
//extend effect
|
|
|
|
var NoiseEffect = function(){
|
|
|
|
//call the super class
|
|
|
|
Tone.Effect.call(this);
|
2014-04-06 00:47:59 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
//components
|
|
|
|
this.noise = new Tone.Noise("brown");
|
2014-06-18 17:40:27 +00:00
|
|
|
this.crush = new Tone.BitCrusher(5);
|
2014-04-06 00:47:59 +00:00
|
|
|
|
2014-06-18 17:40:27 +00:00
|
|
|
// make the noise quieter
|
|
|
|
this.noise.setVolume(.1);
|
2014-04-16 00:05:11 +00:00
|
|
|
//connections
|
|
|
|
this.connectEffect(this.noise);
|
2014-06-18 17:40:27 +00:00
|
|
|
this.connectEffect(this.crush);
|
2014-04-16 00:05:11 +00:00
|
|
|
}
|
|
|
|
//extend effect
|
|
|
|
Tone.extend(NoiseEffect, Tone.Effect);
|
2014-04-06 00:47:59 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
//make a new one
|
|
|
|
var noiseEffect = new NoiseEffect();
|
|
|
|
noiseEffect.toMaster();
|
2014-04-06 00:47:59 +00:00
|
|
|
|
2014-06-18 17:40:27 +00:00
|
|
|
|
|
|
|
// play a sound and connect it to the effect?
|
|
|
|
var player = new Tone.Player("../audio/casio/A1.mp3");
|
|
|
|
player.load(doLoop);
|
|
|
|
|
|
|
|
function doLoop() {
|
|
|
|
player.loop(0., .1, .31);
|
|
|
|
player.connect(noiseEffect);
|
|
|
|
}
|
2014-04-16 00:05:11 +00:00
|
|
|
//INTERFACE//
|
2014-04-06 00:47:59 +00:00
|
|
|
|
2014-04-16 00:05:11 +00:00
|
|
|
var range = document.querySelector("input");
|
2014-04-06 00:47:59 +00:00
|
|
|
|
2014-06-18 17:40:27 +00:00
|
|
|
range.oninput = function(e){
|
|
|
|
var val = e.target.value;
|
2014-04-16 00:05:11 +00:00
|
|
|
noiseEffect.setDry(val / 50 - 1);
|
|
|
|
}
|
2014-06-18 17:40:27 +00:00
|
|
|
|
|
|
|
var noiseType = document.getElementById("noise");
|
|
|
|
noiseType.onchange = function(e){
|
|
|
|
noiseEffect.noise.setType(e.target.value);
|
|
|
|
}
|
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|