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

46
LINES

< > BotCompany Repo | #1018845 // Grow auto-clip algorithm for audio recordings v4 [find best band for exit points, dev.]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 11913K of libraries. Click here for Pure Java version (14739L/106K).

1  
!7
2  
3  
replace MarkedImage with BWImageAndRange.
4  
static L<MarkedImage> markedImages;
5  
6  
p-exp {
7  
  L<File> files = latestFilesFirst(audioRecordingsWithSingleClip());
8  
  pnl(files);
9  
  markedImages = map_printProgress(f audioFileToBWImageAndRange, files);
10  
11  
  showOriginalClips();
12  
  findBestBand();
13  
}
14  
15  
srecord Band(IntRange r, float threshold) {}
16  
17  
svoid findBestBand {
18  
  final int h = first(markedImages).image.getHeight();
19  
  final new Best<Band> best;
20  
  final new AIStrategy_RandomWithVariation<Band> strategy;
21  
  strategy.random = func -> Band { Band(randomIntRange(1, 0, h), randomFloat()) };
22  
  strategy.vary = func(Band b) -> Band { Band(varyIntRange(b.r, 5, 1, 0, h), varyFloat(b.threshold)) };
23  
  strategy.submit = func(final Band b) -> double {
24  
    new Scorer scorer;
25  
    for (MarkedImage img : markedImages)
26  
      audio_scoreExitPoints(scorer, img, audio_exitPointsUsingBand_v1(img.image, b.r, threshold := b.threshold));
27  
    if (best.put(b, scorer!)) {
28  
      print(scorer + " / Band: " + b + " of " + h);
29  
      quickShowZoomedImage(mergeBWImagesVertically(map(markedImages,
30  
        func(MarkedImage img) -> BWImage {
31  
          new Var<BWImage> processedImage;
32  
          L<Int> exitPoints = audio_exitPointsUsingBand_v1(img.image, b.r, threshold := b.threshold, +processedImage, printStreaks := true);
33  
          ret markIntRangesOnTopOfBWImage(
34  
            squishBWImage(processedImage!, 20),
35  
            ll(intRange(img.start, img.end)),
36  
            intsToSize2Ranges(map(func(int x) -> int { max(0, x-2) }, exitPoints)));
37  
        })));
38  
    }
39  
    ret scorer!;
40  
  };
41  
  thread { while licensed { strategy.go(); } }
42  
}
43  
44  
svoid showOriginalClips {
45  
  showImage(mergeBWImagesVertically(map renderBWImageAndRange(markedImages)));
46  
}

Author comment

Began life as a copy of #1018800

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1018845
Snippet name: Grow auto-clip algorithm for audio recordings v4 [find best band for exit points, dev.]
Eternal ID of this version: #1018845/10
Text MD5: 61078dce056963d989fe87779768575e
Transpilation MD5: 45942c276316e38e985c9f8956846446
Author: stefan
Category: javax / audio
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-14 13:28:41
Source code size: 1763 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 516 / 1224
Version history: 9 change(s)
Referenced in: [show references]