It's not what you think. The sparks were not "generating" the tones, they were just triggering a pre-programmed set of tones already put together phonically. That's why everything seems to fit nicely from a musical standpoint, just the rhythm is erratic.
It's the same idea as the juggler who appears to be "playing" music by bouncing balls on a keyboard on the ground in front of him. If you watch closely, the balls just hit the keyboard in random areas, not specific keys. So the only thing he need to control is the rhythm.