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

24
LINES

< > BotCompany Repo | #1009775 // MonoSampleBuffer - byte PCM stream to mono samples [dev.]

JavaX fragment (include)

1  
sclass MonoSampleBuffer {
2  
  int halfSample;
3  
  new L<float[]> samples;
4  
5  
  void append(S s) {
6  
    currentLine += s;
7  
    int i;
8  
    while ((i = currentLine.indexOf('\n')) >= 0) {
9  
      // inefficient
10  
      completeLines.add(dropTrailingBackslashR(substring(currentLine, 0, i)));
11  
      currentLine = substring(currentLine, i+1);
12  
    }
13  
  }
14  
  
15  
  float[] getAndClearSamples() {
16  
    int n = 0;
17  
    n += samples.length;
18  
    if (empty(samples)) ret new float[0];
19  
    float[] _samples = samples;
20  
    if (samples.length != 0)
21  
      samples = new float[0];
22  
    ret _samples;
23  
  }
24  
}

Author comment

Began life as a copy of #1009574

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009775
Snippet name: MonoSampleBuffer - byte PCM stream to mono samples [dev.]
Eternal ID of this version: #1009775/1
Text MD5: cfc5385ddc77a039d4f4a81f77e9fb09
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-16 17:26:53
Source code size: 590 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 416 / 436
Referenced in: [show references]