// For audio recognition, we need a double-precision (16 bit) // integral image. We simply turn the sample data into pixels and // have ourselves a verybig*1 image. srecord noeq AudioRecognizer { interface IAudioSample { double length(); double sampleSum(int channel, double start, double end); } // the 16 bit per channel integral image class AudioSample implements IAudioSample { int channels; long[] data; public double length() { ret data.length; } public double sampleSum(int channel, double start, double end) { int a = ifloor(start), b = ifloor(end); ret getEntry(b)-getEntry(a); } public getPixel(int channel, double start, double end) { ret doubleRatio(sampleSum, end-start); } // get an entry of the sum table long getEntry(int i) { ret data[i]; } *(short[] samples) { int n = l(samples); data = new long[n]; long sum = 0; for i to n: data[i] = (sum += samples[i]); } } }