add a really dumb graph for ring buffer stats

This commit is contained in:
Stephen Birarda 2013-02-04 17:34:40 -08:00
parent 22877c7f3a
commit 6c1511ed41
3 changed files with 54 additions and 2 deletions

View file

@ -84,7 +84,7 @@ int audioCallback (const void *inputBuffer,
// int16_t *inputRight = ((int16_t **) inputBuffer)[1];
if (inputLeft != NULL) {
data->audioSocket->send((char *) WORKCLUB_AUDIO_SERVER, 55443, (void *)inputLeft, BUFFER_LENGTH_BYTES);
data->audioSocket->send((char *) EC2_WEST_AUDIO_SERVER, 55443, (void *)inputLeft, BUFFER_LENGTH_BYTES);
}
int16_t *outputLeft = ((int16_t **) outputBuffer)[0];
@ -376,7 +376,6 @@ error:
void Audio::render()
{
if (initialized && !ECHO_SERVER_TEST) {
for (int s = 0; s < NUM_AUDIO_SOURCES; s++) {
// render gl objects on screen for our sources
glPushMatrix();
@ -390,6 +389,57 @@ void Audio::render()
}
}
void Audio::render(int screenWidth, int screenHeight)
{
if (initialized && ECHO_SERVER_TEST) {
glBegin(GL_LINES);
glColor3f(1,1,1);
int startX = 50.0;
int currentX = startX;
int topY = screenHeight - 90;
int bottomY = screenHeight - 50;
float frameWidth = 50.0;
float halfY = topY + ((bottomY - topY) / 2.0);
// draw the lines for the base of the ring buffer
glVertex2f(currentX, topY);
glVertex2f(currentX, bottomY);
for (int i = 0; i < RING_BUFFER_FRAMES; i++) {
glVertex2f(currentX, halfY);
glVertex2f(currentX + frameWidth, halfY);
currentX += frameWidth;
glVertex2f(currentX, topY);
glVertex2f(currentX, bottomY);
}
// show the next audio buffer and end of last write position
int scaleLength = currentX - startX;
float nextOutputSampleOffset = data->ringBuffer->nextOutput - data->ringBuffer->buffer;
float nextOutputX = startX + (nextOutputSampleOffset / RING_BUFFER_SIZE_SAMPLES) * scaleLength;
glColor3f(1, 0, 0);
glVertex2f(nextOutputX, topY);
glVertex2f(nextOutputX, bottomY);
float endLastWriteSampleOffset = data->ringBuffer->endOfLastWrite - data->ringBuffer->buffer;
if (data->ringBuffer->endOfLastWrite == NULL) {
endLastWriteSampleOffset = 0;
}
float endLastWriteX = startX + (endLastWriteSampleOffset / RING_BUFFER_SIZE_SAMPLES) * scaleLength;
glColor3f(0, 1, 0);
glVertex2f(endLastWriteX, topY);
glVertex2f(endLastWriteX, bottomY);
glEnd();
}
}
/**
* Close the running audio stream, and deinitialize portaudio.
* Should be called at the end of program execution.

View file

@ -21,6 +21,7 @@ public:
static bool init(Head* mainHead);
static void render();
static void render(int screenWidth, int screenHeight);
// terminates audio I/O
static bool terminate();

View file

@ -584,6 +584,7 @@ void display(void)
glDisable(GL_LIGHTING);
//lattice.render(WIDTH, HEIGHT);
Audio::render(WIDTH, HEIGHT);
//drawvec3(100, 100, 0.15, 0, 1.0, 0, myHead.getPos(), 0, 1, 0);
glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic );