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
var calculateFFT = function(real, imag) { | |
var bufferSize = real.length; | |
if ( bufferSize == 1 ) { | |
return [[real[0], imag[0]]]; | |
} | |
if(bufferSize % 2 != 0) throw "Invalid buffer size, bufferSize must be a power of 2"; | |
var even_real = []; |
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
var generateBaseSignal = function(frequency, bufferSize, sampleRate) { | |
var signal = []; | |
for(var i = 0; i < bufferSize; i++) { | |
var step = i * (frequency / sampleRate) % 1; | |
signal[i] = Math.sin(2*Math.PI * step); | |
//signal[i] = step < 0.5 ? 1 : -1; | |
} | |
return signal; |
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
var calculateDFT = function(buffer, sampleRate) { | |
var complexValues = []; | |
for ( var k = 0; k < buffer.length/2; k ++ ) { | |
var real = 0.0; | |
var imag = 0.0; | |
var binFrequency = k * (sampleRate / buffer.length); | |
for ( var n = 0; n < buffer.length; n++ ) { |
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
def build_reverse_table | |
@reverse = Array.new(@buffersize) | |
@reverse[0] = 0; | |
limit = 1 | |
bit = @buffersize >> 1 | |
while (limit < @buffersize ) | |
(0...limit).each do |i| | |
@reverse[i + limit] = @reverse[i] + bit |
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
ArrayList peaks; | |
void setup() { | |
size(400, 200, P3D); | |
peaks = new ArrayList(); | |
for ( int z = 0; z < 48; z++ ) { | |
int[] p = new int[48]; | |
for ( int x = 0; x < p.length; x++ ) { |
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
var BD_DETECTION_RANGES = 128; | |
var BD_DETECTION_RATE = 10.0; | |
var BD_DETECTION_FACTOR = 0.98; | |
var BD_QUALITY_DECAY = 0.5; | |
var BD_QUALITY_TOLERANCE = 0.9; | |
var BD_QUALITY_REWARD = 1.0; | |
var BD_QUALITY_LOSS = 0.2; | |
var BD_QUALITY_STEP = 0.5; | |
var BD_QUALITY_MINIMUM = 100.0; |
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 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.ReverseTable = this.buildReverseTable(); | |
this.prototype.buildReverseTable = function() { | |
var reverseTable = new Array(this.bufferSize); | |
reverseTable[0] = 0; | |
var limit = 1; |
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
p.FFT = function(bufferSize) { | |
this.bufferSize = bufferSize; | |
this.ReverseTable = this.buildReverseTable(); | |
this.prototype.buildReverseTable = function() { | |
var reverseTable = new Array(this.bufferSize); | |
reverseTable[0] = 0; | |
var limit = 1; |
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
p.FFT = function(_bufferSize) { | |
var bufferSize = _bufferSize; | |
var self = { | |
initialize: function() { | |
self.buildReverseTable(); | |
self.buildTrigTables(); | |
} | |
buildReverseTable: function() { |