From 5491f95ac3af4a1aeeb63bb054f96cbe256fefd3 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 4 Feb 2013 10:44:00 -0800 Subject: [PATCH 1/2] don't log first data point, log to folder for cleanliness --- Source/Audio.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Source/Audio.cpp b/Source/Audio.cpp index 5d350558cc..d008aa3993 100644 --- a/Source/Audio.cpp +++ b/Source/Audio.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "Audio.h" #include "Util.h" #include "AudioSource.h" @@ -76,7 +77,7 @@ int audioCallback (const void *inputBuffer, // int16_t *inputRight = ((int16_t **) inputBuffer)[1]; if (inputLeft != NULL) { - data->audioSocket->send((char *) "192.168.1.19", 55443, (void *)inputLeft, BUFFER_LENGTH_BYTES); + data->audioSocket->send((char *) "54.241.92.53", 55443, (void *)inputLeft, BUFFER_LENGTH_BYTES); } int16_t *outputLeft = ((int16_t **) outputBuffer)[0]; @@ -193,27 +194,38 @@ void *receiveAudioViaUDP(void *args) { int16_t *receivedData = new int16_t[BUFFER_LENGTH_SAMPLES]; int *receivedBytes = new int; - timeval previousReceiveTime, currentReceiveTime; + timeval previousReceiveTime, currentReceiveTime = {}; if (LOG_SAMPLE_DELAY) { gettimeofday(&previousReceiveTime, NULL); + char *directory = new char[50]; char *filename = new char[50]; - sprintf(filename, "%s/Desktop/%ld.csv", getenv("HOME"), previousReceiveTime.tv_sec); + + sprintf(directory, "%s/Desktop/echo_tests", getenv("HOME")); + + mkdir(directory, S_IRWXU | S_IRWXG | S_IRWXO); + sprintf(filename, "%s/%ld.csv", directory, previousReceiveTime.tv_sec); logFile.open(filename, std::ios::out); + delete[] directory; delete[] filename; } while (true) { if (sharedAudioData->audioSocket->receive((void *)receivedData, receivedBytes)) { - gettimeofday(¤tReceiveTime, NULL); - + if (LOG_SAMPLE_DELAY) { - // write time difference (in microseconds) between packet receipts to file - double timeDiff = diffclock(previousReceiveTime, currentReceiveTime); - logFile << timeDiff << std::endl; + if (currentReceiveTime.tv_sec == 0) { + gettimeofday(¤tReceiveTime, NULL); + } else { + gettimeofday(¤tReceiveTime, NULL); + + // write time difference (in microseconds) between packet receipts to file + double timeDiff = diffclock(previousReceiveTime, currentReceiveTime); + logFile << timeDiff << std::endl; + } } AudioRingBuffer *ringBuffer = sharedAudioData->ringBuffer; From 72d4d073fd90e7f1184cfa5f4b5eb3e0d656bf84 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 4 Feb 2013 10:44:43 -0800 Subject: [PATCH 2/2] use Philip's constant for server IP --- Source/Audio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Audio.cpp b/Source/Audio.cpp index 7699dd9a0e..f2d2edee35 100644 --- a/Source/Audio.cpp +++ b/Source/Audio.cpp @@ -81,7 +81,7 @@ int audioCallback (const void *inputBuffer, // int16_t *inputRight = ((int16_t **) inputBuffer)[1]; if (inputLeft != NULL) { - data->audioSocket->send((char *) "54.241.92.53", 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];