!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(loop1, loop2); playAudioFromSampleMakingFunction(bufSize, vf); bot(); } answer { File f = putInDirIfNotAbsolute(downloadsDir(), s); nextLoop2 = decodeWAVToStereoSamples(newFile(s)); } static VF1 mixLoops() { ret new VF1() { int i = 0; void get(short[] pair) { int j = max(0, min(l(loop2), 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; } } }; }