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).

!include once #1018630 // Spectro Edit

static BWImage clipToFrequencyImage(Clip clip, IF1<Double> colorizer default lambda1 abs) ctex {
  //print("spectro min/max: " + spectro_minMaxValues(clip));
  
  int w = clip.getFrameCount(), h = clip.getFrameFreqSamples();
  int h2 = min(h, audio_frequencyImageHeight());
  BWImage img = new(w, h2);
  
  Rectangle region = new(0, 0, w, h);
  //toClipCoords(region, clip);
  region.y = clip.getFrameFreqSamples() - (region.y + region.height);
  //print(+region);
        
  int endCol = region.x + region.width;
  int endRow = min(region.y + region.height, h2);
  
  for (int col = region.x; col < endCol; col++) {
    net.bluecow.spectro.Frame f = clip.getFrame(col);
    for (int row = region.y; row < endRow; row++)
      img.setPixel(col, h2-1-row, toFloat(colorizer.get(f.getReal(row))));
  }
  
  ret img;
}

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: 374 / 471
Version history: 9 change(s)
Referenced in: [show references]