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

31
LINES

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

JavaX fragment (include)

1  
!include once #1018630 // Spectro Edit
2  
3  
static Clip frequencyImageToAudio(BWImage img, IF1<Double> uncolorizer default lambda1 id) ctex {
4  
  int w = img.getWidth(), h = img.getHeight(); 
5  
  // clip.getFrameFreqSamples()?
6  
  int h2 = min(h, audio_frequencyImageHeight());
7  
  BWImage img = new(w, h2);
8  
  
9  
  Rectangle region = new(0, 0, w, h);
10  
  //toClipCoords(region, clip);
11  
  region.y = clip.getFrameFreqSamples() - (region.y + region.height);
12  
  //print(+region);
13  
        
14  
  int endCol = region.x + region.width;
15  
  int endRow = min(region.y + region.height, h2);
16  
  
17  
  for (int col = region.x; col < endCol; col++) {
18  
    net.bluecow.spectro.Frame f = clip.getFrame(col);
19  
    for (int row = region.y; row < endRow; row++)
20  
      img.setPixel(col, h2-1-row, toFloat(colorizer.get(f.getReal(row))));
21  
  }
22  
  
23  
    double[] timeData = new double[data.length];
24  
    System.arraycopy(data, 0, timeData, 0, data.length);
25  
    DoubleDCT_1D dct = getDctInstance(data.length);
26  
    dct.inverse(timeData, true);
27  
    windowFunc.applyWindow(timeData);
28  
    ret timeData;
29  
30  
  ret img;
31  
}

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: 191 / 195
Referenced in: [show references]