You may have noticed that the drumloop doesn't loop so well. Let's fix this...
Now out drumloop is one bar long and perfectly loops. Let's extract the kick,
the snare and hihat into sixteenth note long files:
Notice that we don't provide any name or location for those files (in fact, we don't care...)
If no name / location are set, files will be created in temp directory with a unique name.
But you could choose name and location if you wish. Let's check this:
I love hihat, so normalize our Hihat sample so it will be as loud as other instruments...
Why not making some new files by reversing them
Now, we put all them in an array so we can later randomly pick samples.
Some are doubled so they'll have more luck to be picked.
Now, we'll play the original loop three times,
Next, we append a random sequence of 16 sixteenth of audio to build our random drum solo...
Each time you'll run this playground, the resulting audioFile will be different.
Let's listen to our edited audiofile: Original Loop 3 times,
followed by the "drum solo of the day"...