Download Jar. Libraryless. Click here for Pure Java version (6365L/44K).
1 | !7 |
2 | |
3 | static int bufSize = 40960; |
4 | static short[] loop1, loop2; |
5 | static volatile short[] nextLoop2; |
6 | static double speed2 = 2; |
7 | |
8 | p { |
9 | loop1 = decodeWAVToStereoSamples(loadLibrary(#1400093)); |
10 | loop2 = decodeWAVToStereoSamples(newFile(downloadsDir(), "Audio/103615__deller24__loop1.wav")); |
11 | VF1<double[]> vf = mixLoops(); |
12 | playAudioFromSampleMakingFunction(bufSize, vf); |
13 | bot(); |
14 | } |
15 | |
16 | sS answer(S s) { |
17 | new Matches m; |
18 | if (swic_trim(trim(s), "speed ", m)) ret "OK" with speed2 = parseDouble($1); |
19 | File f = putInDirIfNotAbsolute(downloadsDir(), s); |
20 | nextLoop2 = decodeWAVToStereoSamples(f); |
21 | ret "OK"; |
22 | } |
23 | |
24 | static VF1<double[]> mixLoops() { |
25 | ret new VF1<double[]>() { |
26 | int i = 0; |
27 | |
28 | void get(double[] pair) { |
29 | int j = mod(2*iround( |
30 | i/2*((double) l(loop2))/l(loop1)*speed2), l(loop2)); |
31 | pair[0] = (loop1[i] + loop2[j])/2.0; |
32 | pair[1] = (loop1[i+1] + loop2[j+1])/2.0; |
33 | i = (i+2) % l(loop1); |
34 | if (i == 0 && nextLoop2 != null) { |
35 | print("Switching"); |
36 | loop2 = nextLoop2; |
37 | nextLoop2 = null; |
38 | } |
39 | } |
40 | }; |
41 | } |
Began life as a copy of #1016690
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016692 |
Snippet name: | Mix 2 Loops with switching second loop (OK) |
Eternal ID of this version: | #1016692/19 |
Text MD5: | dd31e0556526f1be75bcc5ca3181fbf7 |
Transpilation MD5: | 8d3bed4820dc79f83c8d2d9213cd1293 |
Author: | stefan |
Category: | javax / sound |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-08 17:07:29 |
Source code size: | 1104 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 491 / 1152 |
Version history: | 18 change(s) |
Referenced in: | [show references] |