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

57
LINES

< > BotCompany Repo | #1018774 // Grow auto-clip algorithm for audio recordings Prelude 1 [OK]

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

Download Jar. Uses 11806K of libraries. Click here for Pure Java version (11776L/83K).

1  
!7
2  
3  
sclass MarkedImage {
4  
  BWImage image;
5  
  int start, end;
6  
}
7  
8  
static L<MarkedImage> markedImages;
9  
10  
p-exp {
11  
  L<File> files = audioRecordingsWithSingleClip();
12  
  pnl(files);
13  
  markedImages = map_printProgress(files, func(File f) -> MarkedImage {
14  
    BWImage image = wavToFrequencyImage(f);
15  
    L<IntRange> parts = markerIntRangesForWAV(f, image);
16  
    ret nu(MarkedImage, +image, start := first(parts).start, end := first(parts).end);
17  
  });
18  
  
19  
  //showOriginalClips();
20  
  //showYAveraged();
21  
  showYAveragedOnDifferentBands();
22  
}
23  
24  
svoid showYAveragedOnDifferentBands {
25  
  // Select a band, y-average, auto-contrast
26  
  repeat with sleep 5 {
27  
    int h = first(markedImages).image.getHeight();
28  
    double a = random()*0.9, b = a+0.1;
29  
    final int y1 = iround(a*h), y2 = iround(b*h);
30  
    print("Band: " + y1 + " to " + y2 + " of " + h);
31  
32  
    quickShowImage(mergeBWImagesVertically(map(markedImages,
33  
      func(MarkedImage img) -> BWImage {
34  
        BWImage bandImage = clipBWImage(img.image, 0, y1, img.image.getWidth(), y2-y1);
35  
        ret markIntRangesOnTopOfBWImage(
36  
          bwAutoContrast(squishBWImage(squishBWImage(bandImage, 1), 20)),
37  
          ll(intRange(img.start, img.end)));
38  
      })));
39  
  }
40  
}
41  
42  
svoid showYAveraged {
43  
  // Show y-averaged, auto-contrasted on whole image
44  
  showImage(mergeBWImagesVertically(map(markedImages,
45  
    func(MarkedImage img) -> BWImage {
46  
      markIntRangesOnTopOfBWImage(
47  
        bwAutoContrast(squishBWImage(squishBWImage(img.image, 1), 20)),
48  
        ll(intRange(img.start, img.end)))
49  
    })));
50  
}
51  
52  
svoid showOriginalClips {
53  
  showImage(mergeBWImagesVertically(map(markedImages,
54  
    func(MarkedImage img) -> BWImage {
55  
      markIntRangesOnTopOfBWImage(img.image, ll(intRange(img.start, img.end)))
56  
    })));
57  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018774
Snippet name: Grow auto-clip algorithm for audio recordings Prelude 1 [OK]
Eternal ID of this version: #1018774/14
Text MD5: 4ff422b3364a6b0f40e7043017e6532f
Transpilation MD5: 1504f4ca1956b1e46839617647802469
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-13 17:32:50
Source code size: 1792 bytes / 57 lines
Pitched / IR pitched: No / No
Views / Downloads: 448 / 1033
Version history: 13 change(s)
Referenced in: [show references]