3 import sys, array, os, textwrap, math
6 fin = open(os.path.expanduser(infile),
"rb")
7 print "opened " + infile
8 valuesetad = os.path.getsize(os.path.expanduser(infile))/4
11 valuesfromfile = array.array(
'f')
13 valuesfromfile.fromfile(fin,valuesetad)
17 values=valuesfromfile.tolist()
21 fout = open(os.path.expanduser(outfile),
"w")
22 fout.write(
'#ifndef ' + tablename +
'_H_' +
'\n')
23 fout.write(
'#define ' + tablename +
'_H_' +
'\n \n')
24 fout.write(
'#include <Arduino.h>'+
'\n')
25 fout.write(
'#include "mozzi_pgmspace.h"'+
'\n \n')
26 fout.write(
'#define ' + tablename +
'_NUM_CELLS '+ str(len(values))+
'\n')
27 fout.write(
'#define ' + tablename +
'_SAMPLERATE '+ str(samplerate)+
'\n \n')
28 outstring =
'CONSTTABLE_STORAGE(int8_t) ' + tablename +
'_DATA [] = {'
31 outstring += str(math.trunc((num*256)+0.5)) +
", "
36 outstring = textwrap.fill(outstring, 80)
38 fout.write(
'\n \n #endif /* ' + tablename +
'_H_ */\n')
40 print "wrote " + outfile