You havent got the main issue/obstacle here... THE TIME SIGNATURE NEEDED for arduino know where to end the loop.Unless you make it in the arduino, use it to record those notes, and only then he can [process, quantize, and if requested change pitch( aka transpose), or increase/deecrease tempo.. Only that way would work just with arduino.