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

14
LINES

< > BotCompany Repo | #1026943 // convertSampleRate_stereoShortArray_simple - fast version without anti-aliasing

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

Libraryless. Click here for Pure Java version (2175L/14K).

static short[] convertSampleRate_stereoShortArray_simple(short[] data, double oldSampleRate, double newSampleRate) {
  double ratio = doubleRatio(newSampleRate, oldSampleRate);
  if (ratio == 1) ret data;
  int l = l(data)/2, l2 = iround(l(data)/2*ratio);
  short[] data2 = new[l2*2];
  double j = 0, step = 1/ratio;
  for i to l2: {
    int idxJ = min(ifloor(j), l-1)*2;
    data2[i] = data[idxJ];
    data2[i++] = data[idxJ+1];
    j += step;
  }
  ret data2;
}

Author comment

Began life as a copy of #1026902

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026943
Snippet name: convertSampleRate_stereoShortArray_simple - fast version without anti-aliasing
Eternal ID of this version: #1026943/1
Text MD5: 04582efedabd239571a2b41b1ff0b078
Transpilation MD5: 9139c804eea902ea5ac9e23c6152135a
Author: stefan
Category: javax / audio
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-03 13:34:39
Source code size: 476 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 265 / 361
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)