!7 static int bufSize = 40960; static short[] loop1, loop2; static volatile short[] nextLoop2; p { loop1 = decodeWAVToStereoSamples(loadLibrary(#1400093)); loop2 = decodeWAVToStereoSamples(newFile(downloadsDir(), "27130__pryght-one__harp.wav")); VF1 vf = mixLoops(); playAudioFromSampleMakingFunction(bufSize, vf); bot(); } sS answer(S s) { File f = putInDirIfNotAbsolute(downloadsDir(), s); nextLoop2 = decodeWAVToStereoSamples(f); ret "OK"; } static VF1 mixLoops() { ret new VF1() { int i = 0; void get(short[] pair) { int j = max(0, min(l(loop2)-1, 2*iround(i/2*((double) l(loop2))/l(loop1)))); pair[0] = (short) ((loop1[i] + loop2[j])/2); pair[1] = (short) ((loop1[i+1] + loop2[j+1])/2); i = (i+2) % l(loop1); if (i == 0 && nextLoop2 != null) { loop2 = nextLoop2; nextLoop2 = null; } } }; }