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

18
LINES

< > BotCompany Repo | #1033033 // SampleIteratorToQuerySound

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

Libraryless. Click here for Pure Java version (3886L/22K).

srecord noeq SampleIteratorToQuerySound(int channels, ShortIterator it) is IQuerySound {
  int idx = 0; // points to the one we haven't queried yet 
  
  public int channels() { ret channels; }
  public double getSample(int channel, double time) {
    int t = ifloor(time);
    if (t < idx)
      fail("Earlier time queried: " + t + " / " + idx);
      
    if (it == null) ret 0; // we're done
    while ping (true) {
      if (!it.hasNext()) { it = null; ret 0; } // we're done
      double sample = it.next();
      if (t == idx++)
        ret sample;
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033033
Snippet name: SampleIteratorToQuerySound
Eternal ID of this version: #1033033/6
Text MD5: 73169bf609b109da1fbe66722c0504f0
Transpilation MD5: 9fa9dbb4ca5a83f690f0d5e9978f8046
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-11 15:22:39
Source code size: 583 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 167 / 287
Version history: 5 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)