/* * simple-tone-generator.c * * Copyright (C) 2011 Kamal Mostafa * * NO LICENSE HAS BEEN SPECIFIED OR GRANTED FOR THIS WORK. * */ #include #include #include #include #include "simpleaudio.h" /* "current" phase state of the tone generator */ static float sa_tone_cphase = 0.0; void simpleaudio_tone_reset() { sa_tone_cphase = 0.0; } void simpleaudio_tone(simpleaudio *sa_out, float tone_freq, size_t nsamples_dur) { float *buf = malloc(nsamples_dur * sizeof(float)); assert(buf); if ( tone_freq != 0 ) { float wave_nsamples = 48000.0 / tone_freq; // FIXME rate size_t i; for ( i=0; i 0 ); free(buf); }