Commit 982d8ddf authored by mzed's avatar mzed
Browse files

additive example

parent e1e792ff
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>
Javascript Audio Processing
</title>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?lang=js&amp;skin=sunburst"></script>
<!-- show all line numbers-->
<style type="text/css">.prettyprint ol.linenums > li { list-style-type: decimal }</style>
<script src="maxiLib.js"></script>
<!-- Our javascript code -->
<script type="text/javascript">
var maxiLib = window.MaxiLib();
var audio = new maxiLib.maxiAudio();
audio.init();
var sineBank = [];
for(var i = 0; i < 10; i++){
sineBank.push(new maxiLib.maxiOsc());
}
audio.play = function(){
var wave=0;
var f0 = 100;
for(var i=0; i < 10; i++) {
var thisSine = wave + sineBank[i].sinewave(f0 + (i * f0));
var multiplier = 1.0 / (i+1.0);
thisSine = thisSine * multiplier;
wave = wave + thisSine;
}
wave *= 0.1;
this.output = wave;//simple as that!
}
</script>
</head>
<body>
<h1> Additive Synth </h1>
<p>
summing sinewaves for complex timbres
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var maxiLib = window.MaxiLib();
var audio = new maxiLib.maxiAudio();
audio.init();
var sineBank = [];
for(var i = 0; i < 10; i++){
sineBank.push(new maxiLib.maxiOsc());
}
audio.play = function(){
var wave=0;
var f0 = 100;
for(var i=0; i < 10; i++) {
var thisSine = wave + sineBank[i].sinewave(f0 + (i * f0));
var multiplier = 1.0 / (i+1.0);
thisSine = thisSine * multiplier;
wave = wave + thisSine;
}
wave *= 0.1;
this.output = wave;//simple as that!
}
</pre>
</body></html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment