int main (int argc, char *argv[]) { int i; FILE *output; double s[N]; srand( time(NULL) ); if (argc =! 1) { printf ("usage: %s\n", argv[0]); exit (EXIT_FAILURE); } output = sound_file_open_write (); for (i = 0; i < 10; ++i) { double x = (double)rand()/RAND_MAX; printf("tire : %f\n", x); double note = get_note_stat(x); oscillateur( s, 1.0, note); sound_file_write (s, output); sound_file_write_silence (output); } sound_file_close_write (output); exit (EXIT_SUCCESS); }
void silence(double* s, FILE* output) { int i; for (i = 0; i < N; i++) s[i] = 0; sound_file_write (s, output); }
void note_sinus(double* s, double f, FILE* output) { int i; double a = 1; for (i = 0; i < N; i++) s[i] += a * sin(2 * M_PI * f * i * 1.0 / FE); sound_file_write (s, output); }
void note_am(double* s, double f1, double f2, FILE* output) { int i; double a1, a2 = 0.5; for (i = 0; i < N; i++) s[i] = (a1 * sin(2 * M_PI * f1 * ((i * 1.0) / FE))) * (a2 * sin(2 * M_PI * f2 * ((i * 1.0) / FE))); sound_file_write (s, output); }
void note_shepard(double* s, double f, FILE* output) { int i; double a = (f / 261.626) - 1; for (i = 0; i < N; i++) { s[i] = a * sin(2 * M_PI * f * ((i * 1.0) / FE)) + (1 - a) * sin(2 * M_PI * (f / 2.0) * ((i * 1.0) / FE)); } sound_file_write (s, output); }
void note_fm(double* s, double f1, double f2, FILE* output) { int i; double a1 = 0.5; double a2 = M_PI; for (i = 0; i < N; i++) s[i] = (a1 * sin(2 * M_PI * (a2 * sin(2 * M_PI * f2 * i * 1.0 / FE)) * i * 1.0 / FE)); sound_file_write (s, output); }
int main (int argc, char *argv[]) { int i; FILE *output; double s[N]; if (argc != 1) { printf ("usage: %s\n", argv[0]); exit (EXIT_FAILURE); } output = sound_file_open_write (); double a = 1; double f = 440; for (i=0; i<N; i++) s[i] = log(1 + (a * sin(2 * M_PI * f * i * 1.0 / FE))); sound_file_write (s, output); sound_file_close_write (output); exit (EXIT_SUCCESS); }