Warning: session_start(): open(/var/lib/php/sessions/sess_o3hb7r0aq564eu1pjiqon3jvh7, 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
// This looks at a number of periods of a given frequency starting at a certain time in the audio
// and returns an intensity value.
// No phase adjustment here, so you have to call this twice to get meaningful (complex) results.
srecord noeq SumOfVibrations(IAudioSample sample, int channel, double start, double freq, int periods) {
double period, end;
double rawSum() {
period = sample.sampleRate()/freq;
double sum = 0, t = start;
for p to periods: {
// Subtract an expected trough from an expected neighboring peak and add to overall sum.
// Nota bene: Trough and peak have the same area (=length), so this is basically a Haar-like feature!
// By the use of which we automatically get around nasty complications like DC offsets in the input data.
sum += sample.sampleSum(channel, t, t+period/2)
- sample.sampleSum(channel, t+period/2, t+period);
t += period;
}
end = t;
ret sum;
}
// alternate calculation adjusted for duration
double sumDividedByDuration() {
ret rawSum()/(end-start);
}
// Not divided by duration - this seems like the best frequency detector at this point.
// As in a proper FFT/DCT, we return a complex value to represent phase.
// Call abs() to get the desired intensity value.
Complex complex() {
SumOfVibrations sum2 = new(sample, channel, start+sum.period/4, freq, periods);
ret Complex(rawSum(), sum2.rawSum());
}
}