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

25
LINES

< > BotCompany Repo | #1018632 // clipToFrequencyImage

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

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

1  
!include once #1018630 // Spectro Edit
2  
3  
static BWImage clipToFrequencyImage(Clip clip, IF1<Double> colorizer default lambda1 abs) ctex {
4  
  //print("spectro min/max: " + spectro_minMaxValues(clip));
5  
  
6  
  int w = clip.getFrameCount(), h = clip.getFrameFreqSamples();
7  
  int h2 = min(h, audio_frequencyImageHeight());
8  
  BWImage img = new(w, h2);
9  
  
10  
  Rectangle region = new(0, 0, w, h);
11  
  //toClipCoords(region, clip);
12  
  region.y = clip.getFrameFreqSamples() - (region.y + region.height);
13  
  //print(+region);
14  
        
15  
  int endCol = region.x + region.width;
16  
  int endRow = min(region.y + region.height, h2);
17  
  
18  
  for (int col = region.x; col < endCol; col++) {
19  
    net.bluecow.spectro.Frame f = clip.getFrame(col);
20  
    for (int row = region.y; row < endRow; row++)
21  
      img.setPixel(col, h2-1-row, toFloat(colorizer.get(f.getReal(row))));
22  
  }
23  
  
24  
  ret img;
25  
}

Author comment

Began life as a copy of #1018580

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: #1018632
Snippet name: clipToFrequencyImage
Eternal ID of this version: #1018632/10
Text MD5: ae0d5db00650a13d376bb7e6b2171476
Transpilation MD5: ba16d98dc071c200d58c5ce19e35696d
Author: stefan
Category: javax / audio analysis
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-07-24 06:28:03
Source code size: 879 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 375 / 473
Version history: 9 change(s)
Referenced in: [show references]