Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1026907 // autocorrelationTableForAudioSamples

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2266L/15K).

1  
static double[] autocorrelationTableForAudioSamples(short[] samples) {
2  
  ret autocorrelationTableForAudioSamples(samples, 0, l(samples));
3  
}
4  
5  
static double[] autocorrelationTableForAudioSamples(short[] samples, int start, int end) {
6  
  int n = end-start;
7  
  double[] table = new[n]; // hmm. value at zero seems pointless
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  
    table[j] = correlation;
14  
  }
15  
  ret table;
16  
}
17  
18  
static double[] autocorrelationTableForAudioSamples(short[] samples, IntRange r) {
19  
  ret autocorrelationTableForAudioSamples(samples, r.start, r.end);
20  
}

Author comment

Began life as a copy of #1026895

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: #1026907
Snippet name: autocorrelationTableForAudioSamples
Eternal ID of this version: #1026907/1
Text MD5: b83cd0bc99d09ac8932c5d9e97714c28
Transpilation MD5: f24775e88e58fe755c5aba8c8f7f9112
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 16:40:00
Source code size: 737 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 146 / 203
Referenced in: [show references]