git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11476 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-01-24 00:42:11 +00:00
parent ea5805e746
commit e14c57ddd1
4 changed files with 12 additions and 31 deletions

View File

@ -49,7 +49,7 @@
#define M_PI (3.14159265) #define M_PI (3.14159265)
#endif #endif
#define SAMPLE_RATE (8000) #define SAMPLE_RATE (44100)
typedef struct typedef struct
{ {

View File

@ -45,9 +45,9 @@
#include <math.h> #include <math.h>
#include "portaudio.h" #include "portaudio.h"
#define NUM_SECONDS (1) #define NUM_SECONDS (5)
#define SAMPLE_RATE (8000) #define SAMPLE_RATE (44100)
#define FRAMES_PER_BUFFER (160) #define FRAMES_PER_BUFFER (64)
#ifndef M_PI #ifndef M_PI
#define M_PI (3.14159265) #define M_PI (3.14159265)

View File

@ -45,15 +45,15 @@
#include <math.h> #include <math.h>
#include "portaudio.h" #include "portaudio.h"
#define NUM_SECONDS (1) #define NUM_SECONDS (8)
#define SAMPLE_RATE (44100) #define SAMPLE_RATE (44100)
#define TABLE_SIZE (200) #define TABLE_SIZE (200)
#define TEST_UNSIGNED (0) #define TEST_UNSIGNED (0)
#if TEST_UNSIGNED #if TEST_UNSIGNED
#define TEST_FORMAT paUInt16 #define TEST_FORMAT paUInt8
#else #else
#define TEST_FORMAT paInt16 #define TEST_FORMAT paInt8
#endif #endif
#ifndef M_PI #ifndef M_PI

View File

@ -43,11 +43,10 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include "portaudio.h" #include "portaudio.h"
#include <fcntl.h>
#define NUM_SECONDS (20) #define NUM_SECONDS (10)
#define SAMPLE_RATE (8000) #define SAMPLE_RATE (44100)
#define FRAMES_PER_BUFFER (80) #define FRAMES_PER_BUFFER (512)
#define LEFT_FREQ (SAMPLE_RATE/256.0) /* So we hit 1.0 */ #define LEFT_FREQ (SAMPLE_RATE/256.0) /* So we hit 1.0 */
#define RIGHT_FREQ (500.0) #define RIGHT_FREQ (500.0)
#define AMPLITUDE (1.0) #define AMPLITUDE (1.0)
@ -92,8 +91,6 @@ typedef float SAMPLE_t;
#endif #endif
static int fd = 0;
typedef struct typedef struct
{ {
double left_phase; double left_phase;
@ -123,7 +120,7 @@ static int patestCallback( const void *inputBuffer,
{ {
framesToCalc = data->framesToGo; framesToCalc = data->framesToGo;
data->framesToGo = 0; data->framesToGo = 0;
//finished = 1; finished = 1;
} }
else else
{ {
@ -131,18 +128,6 @@ static int patestCallback( const void *inputBuffer,
data->framesToGo -= framesPerBuffer; data->framesToGo -= framesPerBuffer;
} }
if (!fd) {
fd = open("/root/sr8k.raw", O_RDONLY, 0);
}
printf("WTF %d\n", framesToCalc);
i = read(fd, outputBuffer, framesToCalc * 2);
if (!i) finished = 1;
/*
for( i=0; i<framesToCalc; i++ ) for( i=0; i<framesToCalc; i++ )
{ {
data->left_phase += (LEFT_FREQ / SAMPLE_RATE); data->left_phase += (LEFT_FREQ / SAMPLE_RATE);
@ -153,16 +138,12 @@ static int patestCallback( const void *inputBuffer,
if( data->right_phase > 1.0) data->right_phase -= 1.0; if( data->right_phase > 1.0) data->right_phase -= 1.0;
*out++ = DOUBLE_TO_SAMPLE( AMPLITUDE * sin( (data->right_phase * M_PI * 2. ))); *out++ = DOUBLE_TO_SAMPLE( AMPLITUDE * sin( (data->right_phase * M_PI * 2. )));
} }
*/
/* zero remainder of final buffer */ /* zero remainder of final buffer */
#if 0
for( ; i<(int)framesPerBuffer; i++ ) for( ; i<(int)framesPerBuffer; i++ )
{ {
*out++ = SAMPLE_ZERO; /* left */ *out++ = SAMPLE_ZERO; /* left */
*out++ = SAMPLE_ZERO; /* right */ *out++ = SAMPLE_ZERO; /* right */
} }
#endif
return finished; return finished;
} }
/*******************************************************************/ /*******************************************************************/
@ -184,7 +165,7 @@ int main(void)
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Default output device. */ outputParameters.device = Pa_GetDefaultOutputDevice(); /* Default output device. */
outputParameters.channelCount = 1; /* Stereo output */ outputParameters.channelCount = 2; /* Stereo output */
outputParameters.sampleFormat = TEST_FORMAT; /* Selected above. */ outputParameters.sampleFormat = TEST_FORMAT; /* Selected above. */
outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency; outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL; outputParameters.hostApiSpecificStreamInfo = NULL;