Tone.js/examples/noiseEffect.html
2014-06-18 13:40:27 -04:00

66 lines
No EOL
1.4 KiB
HTML

<html>
<head>
<title>Effect Example</title>
<script type="text/javascript" src="../build/Tone.js"></script>
</head>
<body>
<input type='range'>
<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>
<script type="text/javascript">
//extend effect
var NoiseEffect = function(){
//call the super class
Tone.Effect.call(this);
//components
this.noise = new Tone.Noise("brown");
this.crush = new Tone.BitCrusher(5);
// make the noise quieter
this.noise.setVolume(.1);
//connections
this.connectEffect(this.noise);
this.connectEffect(this.crush);
}
//extend effect
Tone.extend(NoiseEffect, Tone.Effect);
//make a new one
var noiseEffect = new NoiseEffect();
noiseEffect.toMaster();
// 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);
}
//INTERFACE//
var range = document.querySelector("input");
range.oninput = function(e){
var val = e.target.value;
noiseEffect.setDry(val / 50 - 1);
}
var noiseType = document.getElementById("noise");
noiseType.onchange = function(e){
noiseEffect.noise.setType(e.target.value);
}
</script>
</body>
</html>