# quake.py: extracts earthquake data from a text file and sonifies it. # The depth of the quake is translated to a note, and the magnitude is # translated into a number of "overtones." The score generated is designed # to be used with the adsynt csound opcode. The notes are triggered in # time with the actual time and date of the quake in question; the # approximate scale is 1 hour of real time to 200 milliseconds music time. # # Adam Parrish # Algorithmic Composition # ITP Fall 2007 from time import * import sys origin_time = mktime(strptime("19980101", "%Y%m%d")) note_dur = 2 kamp = 300 time_divider = 1800000.0 overtone_divider = 6.0 top_octave = 8 def format_note(time_offset, lat, long, magnitude, depth): note_offset = time_offset / time_divider steps_down = depth / 10 octaves_down = steps_down / 12 pitchclass = (top_octave - octaves_down) + ((12 - steps_down % 12) / 100.0) overtones = (magnitude * magnitude) / overtone_divider return "i 1 %f %d %d %.2f %d" % (note_offset, note_dur, kamp, pitchclass, overtones) if __name__ == '__main__': for filename in sys.argv[1:]: f = open(filename, 'r') for line in f: p = line.split(',') p = [elem.strip() for elem in p] quake_time = mktime(strptime(''.join(p[0:4]), "%Y%m%d%H%M%S")) print format_note(quake_time - origin_time, float(p[4]), float(p[5]), float(p[6]), int(p[7])) print "e"