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

27
LINES

< > BotCompany Repo | #1026891 // Audio Input Autocorrelation Test

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (4681L/24K).

!7

cmodule AudioInputCorrelationTest > DynPrintLogAndEnabled {
  double windowSize = 1; // milliseconds
  transient short[] buffer;

  start {
    dm_addAudioListener(voidfunc(short[] data) enter {
      if (!enabled) ret;
      
      buffer = cloneArray(data);
      dm_q(r {
        if (q.size() > 2) ret with print("overload");
        short[] buf = buffer;
        Float sampleRate = dm_audioInputSampleRate();
        if (sampleRate == null) ret;
        int windowLength = msToSamples_int(windowSize, sampleRate);
        //printWithMilliseconds("Window length (" + sampleRate + "): " + windowLength);
        new L<Double> l;
        for (IntRange r : intRangeChunks(data, windowLength))
          l.add(normalizedAutocorrelationOfAudioSamples(data, r));
        double result = doubleAverage(l);
        print(iround(result) + ", max=" + iround(doubleMax(l)) + " " + takeFirst(5, l));
      });
    });
  }
}

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: #1026891
Snippet name: Audio Input Autocorrelation Test
Eternal ID of this version: #1026891/21
Text MD5: 95ecb94107eec14b38bdfb3080185d58
Transpilation MD5: e52005d4ca8cf20ecaf73269fd6db09f
Author: stefan
Category: javax / audio
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-02 15:40:46
Source code size: 944 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 276 / 598
Version history: 20 change(s)
Referenced in: [show references]