From 1dbcc33442a9fa5b70ea8f4e962e47b83edced91 Mon Sep 17 00:00:00 2001 From: philburk Date: Fri, 22 Feb 2002 22:06:23 +0000 Subject: [PATCH] Change from 22050 to 44100 Hz Process audio in a block for better efficiency. --- pablio/test_rw.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pablio/test_rw.c b/pablio/test_rw.c index 245e19c..7f7e886 100644 --- a/pablio/test_rw.c +++ b/pablio/test_rw.c @@ -44,9 +44,10 @@ ** full duplex audio (simultaneous record and playback). ** And some only support full duplex at lower sample rates. */ -#define SAMPLE_RATE (22050) -#define NUM_SECONDS (15) -#define SAMPLES_PER_FRAME (2) +#define SAMPLE_RATE (44100) +#define NUM_SECONDS (5) +#define SAMPLES_PER_FRAME (2) +#define FRAMES_PER_BLOCK (64) /* Select whether we will use floats or shorts. */ #if 1 @@ -62,7 +63,7 @@ int main(void); int main(void) { int i; - SAMPLE samples[SAMPLES_PER_FRAME]; + SAMPLE samples[SAMPLES_PER_FRAME * FRAMES_PER_BLOCK]; PaError err; PABLIO_Stream *aStream; @@ -75,13 +76,12 @@ int main(void) if( err != paNoError ) goto error; /* Process samples in the foreground. */ - for( i=0; i<(NUM_SECONDS * SAMPLE_RATE); i++ ) + for( i=0; i<(NUM_SECONDS * SAMPLE_RATE); i += FRAMES_PER_BLOCK ) { - /* Read one frame of data into sample array from audio input. */ - ReadAudioStream( aStream, samples, 1 ); - /* Write that same frame of data to output. */ - /* samples[1] = (i&256) * (1.0f/256.0f); /* sawtooth */ - WriteAudioStream( aStream, samples, 1 ); + /* Read one block of data into sample array from audio input. */ + ReadAudioStream( aStream, samples, FRAMES_PER_BLOCK ); + /* Write that same block of data to output. */ + WriteAudioStream( aStream, samples, FRAMES_PER_BLOCK ); } CloseAudioStream( aStream ); -- 2.43.0