From 1b764faa5b85724046a978952766777eb035bbdc Mon Sep 17 00:00:00 2001 From: Kamal Mostafa Date: Wed, 22 Jun 2011 11:14:01 -0700 Subject: [PATCH] simpleaudio_tone: handle any duration --- src/simple-tone-generator.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/simple-tone-generator.c b/src/simple-tone-generator.c index 6a3ca33..ff5b2df 100644 --- a/src/simple-tone-generator.c +++ b/src/simple-tone-generator.c @@ -10,6 +10,7 @@ #include #include +#include #include #include "simpleaudio.h" @@ -27,20 +28,16 @@ simpleaudio_tone_reset() void simpleaudio_tone(simpleaudio *sa_out, float tone_freq, size_t nsamples_dur) { -#define TONE_GEN_BUFSIZE (10*48000) // FIXME - float buf[TONE_GEN_BUFSIZE]; - - assert ( nsamples_dur <= TONE_GEN_BUFSIZE ); + 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); }