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

20
LINES

< > BotCompany Repo | #1018636 // spectro_intRangesToWAV

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

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

!include once #1018630 // Spectro Edit

import javax.sound.sampled.*;

// I guess the ranges are in spectro-edit frames (44.1/1024Khz by default)
svoid spectro_intRangesToWAV(Clip clip, L<IntRange> parts, File wavFile) ctex {
  new L<InputStream> l;
  int frames = 0;
  for (IntRange r : parts) {
    if (nempty(l)) {
      int n = 44100/2; // half a second
      l.add(ZerosInputStream(n*2));
      frames += n;
    }
    int n = r.length()*clip.getFrameTimeSamples();
    l.add(clip.getAudio(r.start*clip.getFrameTimeSamples(), n));
    frames += n;
  }
  writeInputStreamsToWAV(l, frames, wavFile);
}

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: #1018636
Snippet name: spectro_intRangesToWAV
Eternal ID of this version: #1018636/14
Text MD5: e839939aa4d746710b1d49729d325101
Transpilation MD5: aee140ef1ddd55fa148225af46d299b2
Author: stefan
Category: javax / audio recognition
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-05 03:22:32
Source code size: 622 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 431 / 521
Version history: 13 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)