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

31
LINES

< > BotCompany Repo | #1032434 // frequencyImageToAudio [dev.]

JavaX fragment (include)

!include once #1018630 // Spectro Edit

static Clip frequencyImageToAudio(BWImage img, IF1<Double> uncolorizer default lambda1 id) ctex {
  int w = img.getWidth(), h = img.getHeight(); 
  // 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))));
  }
  
    double[] timeData = new double[data.length];
    System.arraycopy(data, 0, timeData, 0, data.length);
    DoubleDCT_1D dct = getDctInstance(data.length);
    dct.inverse(timeData, true);
    windowFunc.applyWindow(timeData);
    ret timeData;

  ret img;
}

Author comment

Began life as a copy of #1018632

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032434
Snippet name: frequencyImageToAudio [dev.]
Eternal ID of this version: #1032434/1
Text MD5: aba8af11caaed4525e40a626cc60d06c
Author: stefan
Category: javax / audio analysis + synthesis
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-05 04:35:13
Source code size: 1087 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 44 / 64
Referenced in: [show references]