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

36
LINES

< > BotCompany Repo | #1025099 // Live Base Drum Finder 2 [dev.]

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

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

1  
!7
2  
3  
cmodule BaseDrumFinder > DynPrintLog {
4  
  new SimpleBaseDrumFinder2 finder;
5  
  double minBPM = 60, maxBPM = 200;
6  
  
7  
  start {
8  
    dm_requireLiveAudioFFT();
9  
10  
    dm_vmBus_onMessage_q newAudioFrequencyImage(voidfunc(virtual BWImage img) {
11  
      float[] b = bwImageColumnBrightnesses_generic(img);
12  
      L<IntRange> ranges = finder.addFrequencyImageBrightnesses(b);
13  
      int[] gaps = intRangeStartGaps(ranges);
14  
      if (empty(gaps)) ret;
15  
      sort(gaps);
16  
      MultiSet<Int> ms = intArrayAsTreeMultiSet(gaps);
17  
      new Best<Int> best;
18  
      for (int gap : keys(ms))
19  
        if (isBetween_double(
20  
          audio_frequencyImage_pixelsToBPM(gap),
21  
          minBPM, maxBPM))
22  
          best.put(gap, ms.get(gap-1)+ms.get(gap)+ms.get(gap+1));
23  
      Int gap = best!;
24  
      if (gap == null) ret with print("no fitting gaps");
25  
      print(ms);
26  
      
27  
      double exactGap = weightedAverage_lit(
28  
        gap-1, ms.get(gap-1),
29  
        gap, ms.get(gap),
30  
        gap+1, ms.get(gap+1));
31  
      double bpm = audio_frequencyImage_pixelsToBPM(exactGap);
32  
      
33  
      printVars_str(+gap, +exactGap, +bpm);
34  
    });
35  
  }
36  
}

Author comment

Began life as a copy of #1025085

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025099
Snippet name: Live Base Drum Finder 2 [dev.]
Eternal ID of this version: #1025099/13
Text MD5: 537e8e0ae2d9462254f637cac8dde6b7
Transpilation MD5: 88eede4118556662059f5c5603d7df81
Author: stefan
Category: javax / audio analysis
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-05 19:19:52
Source code size: 1140 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 257 / 1286
Version history: 12 change(s)
Referenced in: [show references]