![]() |
Mozzi
alpha 0.01.1t
sound synthesis library for Arduino
|
00001 import array 00002 import os 00003 import textwrap 00004 00005 def generate(outfilename, tablename, tablelength, samplerate): 00006 fout = open(os.path.expanduser(outfilename), "w") 00007 fout.write('#ifndef ' + tablename + '_H_' + '\n') 00008 fout.write('#define ' + tablename + '_H_' + '\n \n') 00009 fout.write('#include "Arduino.h"'+'\n') 00010 fout.write('#include <avr/pgmspace.h>'+'\n \n') 00011 fout.write('#define ' + tablename + '_NUM_CELLS '+ str(len(values))+'\n') 00012 fout.write('#define ' + tablename + '_SAMPLERATE '+ str(samplerate)+'\n \n') 00013 outstring = 'const char __attribute__((progmem)) ' + tablename + '_DATA [] = {' 00014 try: 00015 for num in range(tablelength): 00016 outstring += str(num/32) + ", " ## for saw line, or put your own generating code here 00017 finally: 00018 outstring += "};" 00019 outstring = textwrap.fill(outstring, 80) 00020 fout.write(outstring) 00021 fout.write('\n \n #endif /* ' + tablename + '_H_ */\n') 00022 fout.close() 00023 print "wrote " + outfilename 00024 00025 generate("~/Desktop/phasor8192_uint8.h", "phasor8192", 8192, "8192")