Libraryless. Click here for Pure Java version (2269L/14K).
1 | static double autocorrelationOfAudioSamples(short[] samples) { |
2 | ret autocorrelationOfAudioSamples(samples, 0, l(samples)); |
3 | } |
4 | |
5 | static double autocorrelationOfAudioSamples(short[] samples, int start, int end) { |
6 | int n = end-start; |
7 | double sum = 0; |
8 | for j to n: { |
9 | double correlation = 0; |
10 | for i to n: |
11 | correlation += sixteenBitAudioSampleToDouble(samples[start+i]) |
12 | * sixteenBitAudioSampleToDouble(samples[start+mod(i - j, n)]); |
13 | sum += correlation; |
14 | } |
15 | ret doubleRatio(sum, n); |
16 | } |
17 | |
18 | static double autocorrelationOfAudioSamples(short[] samples, IntRange r) { |
19 | ret autocorrelationOfAudioSamples(samples, r.start, r.end); |
20 | } |
Began life as a copy of #1026886
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1026895 |
Snippet name: | autocorrelationOfAudioSamples |
Eternal ID of this version: | #1026895/3 |
Text MD5: | 835c0eab43df2569fac7ddc08a50e753 |
Transpilation MD5: | 4dcd035579df933b6a6fbdd0301b95fa |
Author: | stefan |
Category: | javax / audio |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-02 15:23:34 |
Source code size: | 664 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 220 / 301 |
Version history: | 2 change(s) |
Referenced in: | [show references] |