#include #include #define TABLE_SIZE 1024 #define SAMPLE_RATE 44100 /*Takes one argument, which is the file to write to. *The sin values (output) are scaled up by 2^15-1 = 32767 *To generate float values uncomment the two lines, and comment out the next two */ int main (int argc, char **argv){ int i, temp = 0; FILE *f; const double inc = 2*M_PI/TABLE_SIZE; //in radians double out; f = fopen(argv[1], "w"); for(i = 0; i < TABLE_SIZE; i++){ //out = sin(((double)i)*inc); //fprintf(f, "%1.20f, ", out); out = sin(((double)i)*inc)*32767; fprintf(f, "%d, ", (int)out); if(temp == 4){ fprintf(f, "\\\n"); temp = 0; } else temp++; } fclose(f); return 0; }