Created
January 11, 2010 21:24
-
-
Save corbanbrook/274617 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function p.FFT (bufferSize) { | |
this.bufferSize = bufferSize; | |
this.SinTable = new Array(bufferSize); | |
this.CosTable = new Array(bufferSize); | |
this.ReverseTable = new Array(bufferSize); | |
this.prototype.FFT(bufferSize) { | |
this.buildTrigTables(); | |
this.buildReverseTable(); | |
} | |
this.prototype.buildTrigTables = function() { | |
for ( var i = 0; i < this.bufferSize; i++ ) { | |
this.SinTable[i] = Math.sin(-Math.PI/i); | |
this.CosTable[i] = Math.cos(-Math.PI/i); | |
} | |
} | |
this.prototype.buildReverseTable = function() { | |
ReverseTable[0] = 0; | |
var limit = 1; | |
var bit = this.bufferSize >> 1; | |
while ( limit < this.bufferSize ) { | |
for ( var i = 0; i < limit; i++ ) { | |
ReverseTable[i + limit] = ReverseTable[i] + bit; | |
} | |
limit = limit << 1; | |
bit = bit >> 1; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment