#include #include "sine_table.h" // The following assumes a sampling rate of 44100 Hz and produces a 21 // kHz tone for LENGTH milliseconds. // The duration (in milliseconds) to play the 21 kHz tone. #define LENGTH 2000 // Since it is assumed that the sampling rate is 44100 Hz, TABLE_LENGTH // is equal to the sampling rate. #define TABLE_LENGTH 44100 // In order to get a 21 kHz tone, increment through the 44100-entry sine // table by 21000 entries every sample. #define INCREMENT 21000 int main (int argc, char **argv) { int sin[TABLE_LENGTH] = TABLE; int index = 0, i = 0; FILE *f; f = fopen(argv[1], "w"); for (i = 0; i < (LENGTH*TABLE_LENGTH)/1000; i++) { fprintf(f, "%d \n", sin[index]); index = (index + INCREMENT) % TABLE_LENGTH; } return 0; }