Drum Attack 2

A quick piece of code for you and a bit of computer synthesized drums for you.

import itertools
a = list(itertools.product('^ox', repeat=8))
print(''.join([''.join(x) for x in a[:1000]]))

Drum Attack 2 output

Drum Attack 2 FLAC [501MB] torrent [magnet]
Drum Attack 2 16th notes midi
Drum Attack 2 8th notes midi
Drum Attack 2 sample FLAC
Drum Attack 2 sample Ogg Vorbis

Creative Commons License
Drum Attack 2 by Javantea is licensed under a Creative Commons Attribution 4.0 International License.

What in the world is this 1 hour 49 minute 22 second cacophony of drum notes? It was generated by a pretty simple 383 line Python script. That script parses a midi file (not completely relevant), then generates two midi files using a similar format to the python script above. You can see that itertools.product does some interesting stuff with a small amount of input. What does it do with repeat=3?

import itertools
a = list(itertools.product('^ox', repeat=3))

[('^', '^', '^'), ('^', '^', 'o'), ('^', '^', 'x'), ('^', 'o', '^'), ('^', 'o', 'o'), ('^', 'o', 'x'), ('^', 'x', '^'), ('^', 'x', 'o'), ('^', 'x', 'x'), ('o', '^', '^'), ('o', '^', 'o'), ('o', '^', 'x'), ('o', 'o', '^'), ('o', 'o', 'o'), ('o', 'o', 'x'), ('o', 'x', '^'), ('o', 'x', 'o'), ('o', 'x', 'x'), ('x', '^', '^'), ('x', '^', 'o'), ('x', '^', 'x'), ('x', 'o', '^'), ('x', 'o', 'o'), ('x', 'o', 'x'), ('x', 'x', '^'), ('x', 'x', 'o'), ('x', 'x', 'x')]

What does that look like? That looks like all possible combinations of the characters '^', 'o', and 'x'. Is there any sense to the length of the output, 27? 27 = 3 * 3 * 3 == 33. So what happens when we change repeat=8? The output becomes 6561 long. 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 == 6561 == 38. So 6561 * 8 = 52488 is the number of notes in our midi file. Now to find the length, we divide by the number of notes per beat (4 for 16th, 2 for 8th) and the number of beats per minute (120 bpm). 52488 / 4 / 120 == 109.35 minutes or 1.8225 hours.

So now we can interpret the symbols used above. I use ^ for closed hi-hat, o for bass drum, and x for snare. If you wanted to, you could generate a midi file with a cowbell instead of snare by changing the pitch.

What am I going to do with this code? I'm probably going to do some interesting stuff with randomly generated computer music. I tried doing it back in 2004-2006 but it never quite turned out right. I ended up with a lot of stuff that sounded like a person pressing notes on a keyboard. Now that there are a lot more video tutorials on how to understand music composition, I'm going to do some ... interesting stuff.

If you're looking for more experiments with computer music, I have been doing this for a long time. Here's a few of the projects I've done going back to 2003 (yeah, 14 years ago!):

Javantea out.
No sig on this one because I'm in a hurry to eat lunch.


Comments: 0

Leave a reply »

  • Leave a Reply
    Your gravatar
    Your Name