changeset 2349:a916f7215b62

tonegen swithed to FMT_FLOAT for debugging purposes
author Eugene Zagidullin <e.asphyx@gmail.com>
date Thu, 31 Jan 2008 12:43:55 +0300
parents 47d7a45b26a0
children 233996ff7603
files src/tonegen/tonegen.c
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/tonegen/tonegen.c	Wed Jan 30 05:04:15 2008 +0300
+++ b/src/tonegen/tonegen.c	Thu Jan 31 12:43:55 2008 +0300
@@ -73,13 +73,13 @@
 }
 
 #define BUF_SAMPLES 512
-#define BUF_BYTES BUF_SAMPLES * 2
+#define BUF_BYTES BUF_SAMPLES * sizeof(float)
 
 static void* play_loop(void *arg)
 {
         InputPlayback *playback = arg;
 	GArray* frequencies = playback->data;
-	gint16 data[BUF_SAMPLES];
+	float data[BUF_SAMPLES];
 	gsize i;
 	struct {
 		double wd;
@@ -111,10 +111,9 @@
 					tone[j].t -= tone[j].period;
 				tone[j].t++;
 			}
-			data[i] = rint(((1 << 15) - 1) *
-				       (sum_sines / frequencies->len));
+			data[i] = (sum_sines / (double)frequencies->len);
 		}
-		playback->pass_audio(playback, FMT_S16_NE, 1, BUF_BYTES, data, &going);
+		playback->pass_audio(playback, FMT_FLOAT, 1, BUF_BYTES, data, &going);
 	}
 
 	g_array_free(frequencies, TRUE);
@@ -193,7 +192,7 @@
 
  	going = TRUE;
 	audio_error = FALSE;
-	if (playback->output->open_audio(FMT_S16_NE, OUTPUT_FREQ, 1) == 0)
+	if (playback->output->open_audio(FMT_FLOAT, OUTPUT_FREQ, 1) == 0)
 	{
 		audio_error = TRUE;
 		going = FALSE;