!7 static int bufSize = 40960; static short[] loop1, loop2; static volatile short[] nextLoop2; static double speed2 = 2; p { loop1 = decodeWAVToStereoSamples(loadLibrary(#1400093)); loop2 = decodeWAVToStereoSamples(newFile(downloadsDir(), "Audio/103615__deller24__loop1.wav")); VF1 vf = mixLoops(); playAudioFromSampleMakingFunction(bufSize, vf); bot(); } sS answer(S s) { new Matches m; if (swic_trim(trim(s), "speed ", m)) ret "OK" with speed2 = parseDouble($1); File f = putInDirIfNotAbsolute(downloadsDir(), s); nextLoop2 = decodeWAVToStereoSamples(f); ret "OK"; } static VF1 mixLoops() { ret new VF1() { int i = 0; void get(double[] pair) { int j = mod(2*iround( i/2*((double) l(loop2))/l(loop1)*speed2), l(loop2)); pair[0] = (loop1[i] + loop2[j])/2.0; pair[1] = (loop1[i+1] + loop2[j+1])/2.0; i = (i+2) % l(loop1); if (i == 0 && nextLoop2 != null) { print("Switching"); loop2 = nextLoop2; nextLoop2 = null; } } }; }