Commit 4c377e83 authored by Chris Kiefer's avatar Chris Kiefer
Browse files

ifft update

parent 0b40a80a
<!DOCTYPE HTML>
<html>
<head><script src='../maxiLib/maxiLib.js'></script>
<meta charset="utf-8">
<title>maxiLib.js template</title>
</head>
<body>
<h1>maxiLib.js template</h1>
<br>
<p>This document shows you how to use maxiLib.js as an add on library.</p>
<p>You can add maxiLib.js without using the script tag and loading it remotely.</p>
<p>Just select the 'Libraries' panel as shown in the about document, and select maxiLib.js</p>
<p>You can then use the code in this document to make noise</p>
</body>
<script>
// var maxiAudio = new maximJs.maxiAudio();
var maxiLib = window.MaxiLib();
var maxiAudio = new maxiLib.maxiAudio();
myWave = new maxiLib.maxiOsc();
var fft = new maxiLib.maxiFFT();
var ifft = new maxiLib.maxiIFFT();
maxiAudio.init();
fft.setup(1024,1024,256);
ifft.setup(1024,1024,256);
var mags = new maxiLib.VectorFloat();
var phs = new maxiLib.VectorFloat();
for(var i=0; i < 1024; i++) {
mags.push_back(0);
phs.push_back(0);
}
maxiAudio.play = function() {
var w=0;
w = myWave.saw(50);
if (fft.process(w)) {
// console.log("fft");
mags.delete();
mags = fft.magnitudes;
phs.delete();
phs = fft.phases;
}
w = ifft.process(mags, phs);
this.output = w;
};
</script>
</html>
This diff is collapsed.
<!DOCTYPE HTML>
<html>
<head><script src='maxiLib.js'></script>
<meta charset="utf-8">
<title>maxiLib.js template</title>
</head>
<body>
<h1>maxiLib.js template</h1>
<br>
<p>This document shows you how to use maxiLib.js as an add on library.</p>
<p>You can add maxiLib.js without using the script tag and loading it remotely.</p>
<p>Just select the 'Libraries' panel as shown in the about document, and select maxiLib.js</p>
<p>You can then use the code in this document to make noise</p>
</body>
<script>
var maxiAudio = new maximJs.maxiAudio();
var sinecount=200;
var myWave = new Array(sinecount);
var phases = new Array(sinecount);
for(var i=0; i < sinecount; i++) {
myWave[i] = new maximJs.maxiOsc();
phases[i] = 0;
}
// maxiAudio.init();
//
// maxiAudio.play = function() {
// var w=0;
// for(i=0; i < sinecount; i++) {
// w += myWave[i].sinewave(300 + (i*50)) * (sinecount - i);
// // w += Math.sin(phases[i]) * (1.0-(i/sinecount));
// // phases[i] += ((i+1) * 0.8);
// }
// this.output = w / sinecount;
// };
var fft = new maximJs.maxiFFT();
var testosc = new maximJs.maxiOsc();
fft.setup(512, 256, 128);
var currentFrame = 0;
var start = Date.now();
var x=0;
var testruns=100000000;
for (var i = 0; i < testruns; i++) {
// fft.process(currentFrame);
testosc.sinewave(100);
// x = Math.sin(i);
}
console.log(x);
var finish = Date.now();
var elapsed = finish - start;
console.log(elapsed);
var millisPerOsc = elapsed / testruns;
var bufferTime = 1024/44100.0;
// var totalPossibleOscs = ((testruns / 44100.0) / millisPerOsc);
// var totalPossibleOscs = (1000 / millisPerOsc);
// console.log(Math.floor(totalPossibleOscs));
console.log(bufferTime / millisPerOsc);
</script>
</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