Libraryless. Click here for Pure Java version (2175L/14K).
1 | static short[] convertSampleRate_stereoShortArray_simple(short[] data, double oldSampleRate, double newSampleRate) { |
2 | double ratio = doubleRatio(newSampleRate, oldSampleRate); |
3 | if (ratio == 1) ret data; |
4 | int l = l(data)/2, l2 = iround(l(data)/2*ratio); |
5 | short[] data2 = new[l2*2]; |
6 | double j = 0, step = 1/ratio; |
7 | for i to l2: { |
8 | int idxJ = min(ifloor(j), l-1)*2; |
9 | data2[i] = data[idxJ]; |
10 | data2[i++] = data[idxJ+1]; |
11 | j += step; |
12 | } |
13 | ret data2; |
14 | } |
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: | 179 / 258 |
Referenced in: | [show references] |