Warning: session_start(): open(/var/lib/php/sessions/sess_pi9an5qouilopbd42hvlgju161, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// 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);
public default double getPixel(int channel, double start, double end) {
ret doubleRatio(sampleSum(channel, start, end), end-start);
}
}
// the 16 bit per channel integral image
class AudioSample implements IAudioSample {
int channels;
int length;
long[] data;
public double length() { ret length; }
public double sampleSum(int channel, double start, double end) {
int a = ifloor(start), b = ifloor(end);
ret getEntry(channel, b)-getEntry(channel, a-1);
}
// get an entry of the sum table
long getEntry(int channel, int i) {
if (i < 0) ret 0;
i = min(i, length-1);
ret data[i*channels+channel];
}
*(short[] samples, int *channels) {
length = l(samples)/channels;
data = new long[n*channels];
long[] sums = new[samples];
int iSample = 0;
for i to length:
for c to channels: {
data[iSample] = (sums[c] += samples[iSample]);
iSample++;
}
}
}
}