signal = []
t=0
for (p,d) in [(4,1),(5,1),(7,3),(None,1), (4,1),(5,1),(7,3),(None,1), (4,1),(7,1),(12,2),(11,2),(9,2),(9,2),(7,1),(None,1), (2,1),(4,1),(5,3),(None,1), (2,1),(4,1),(5,3),(None,1), (2,1),(5,1),(11,1),(9,1),(7,2),(11,2),(12,4)]:
if p is not None: add_note(t, 440*2**(((p+random.choice([-1,0,0,0,1]))+random.random())/12.), 0.3*d+0.1, 1)
t += 0.3*d*math.exp(random.random()*random.random())
save_signal()
It (1) displaces 20% of notes up and 20% of notes down by one semitone, (2) detunes all notes randomly by about +/- a quarter-tone, and (3) inserts random delays, usually quite short but up to a factor of about 1.7 times the length of the preceding note or rest.
[EDITED to add: actually, I think it distorts the pitches just a little too much.]
[FURTHER EDITED: really, it should be tweaked so that when two consecutive notes in the original melody are, say, increasing in pitch, the same is true of the distorted ones. I am too lazy to make this happen. A simpler improvement is to replace the two pitch-diddlings with a single call to random.choice() so that you never get, e.g., a semitone displacement plus a quarter-tone mistuning in the same direction. I also tried making the timbre nastier by putting the partials at non-harmonic frequencies, which does indeed sound quite nasty but not in a particularly hummable way. This doesn’t introduce as much nastiness as it would in music with actual harmony in it; one can make even a perfect fifth sound hideously discordant by messing up the spectrum of the notes. See William Sethares’s excellent book “Tuning, timbre, spectrum, scale” for more details, though he inexplicably gives more attention to making music sound better rather than worse.]
This is quite Quirrellicious:
It (1) displaces 20% of notes up and 20% of notes down by one semitone, (2) detunes all notes randomly by about +/- a quarter-tone, and (3) inserts random delays, usually quite short but up to a factor of about 1.7 times the length of the preceding note or rest.
[EDITED to add: actually, I think it distorts the pitches just a little too much.]
[FURTHER EDITED: really, it should be tweaked so that when two consecutive notes in the original melody are, say, increasing in pitch, the same is true of the distorted ones. I am too lazy to make this happen. A simpler improvement is to replace the two pitch-diddlings with a single call to random.choice() so that you never get, e.g., a semitone displacement plus a quarter-tone mistuning in the same direction. I also tried making the timbre nastier by putting the partials at non-harmonic frequencies, which does indeed sound quite nasty but not in a particularly hummable way. This doesn’t introduce as much nastiness as it would in music with actual harmony in it; one can make even a perfect fifth sound hideously discordant by messing up the spectrum of the notes. See William Sethares’s excellent book “Tuning, timbre, spectrum, scale” for more details, though he inexplicably gives more attention to making music sound better rather than worse.]