]> Repos - portaudio/commitdiff
mme latency test: minor cleanups. randomised tone pitch
authorrossb <rossb@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 28 Jul 2011 04:40:42 +0000 (04:40 +0000)
committerrossb <rossb@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 28 Jul 2011 04:40:42 +0000 (04:40 +0000)
test/patest_wmme_find_best_latency_params.c

index 876deb62deaaea0dc4d46f03f29145ae55c1254e..625cc20229622b2b584dfe328ca78fb2134fec4a 100644 (file)
@@ -111,7 +111,8 @@ static void printWindowsVersionInfo( FILE *fp )
     if( osVersionInfoEx.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ){\r
         switch( osVersionInfoEx.dwMinorVersion ){\r
             case 0: osName = "Windows 95"; break;\r
-            case 10: osName = "Windows 98"; break; // could also be SE (code I saw discriminated on osInfo.Version.Revision.ToString() == "2222A")\r
+            case 10: osName = "Windows 98"; break;  // could also be 98SE (I've seen code discriminate based \r
+                                                    // on osInfo.Version.Revision.ToString() == "2222A")\r
             case 90: osName = "Windows Me"; break;\r
         }\r
     }else if( osVersionInfoEx.dwPlatformId == VER_PLATFORM_WIN32_NT ){\r
@@ -205,7 +206,9 @@ static void printWindowsVersionInfo( FILE *fp )
 \r
 \r
     fprintf( fp, "OS name and edition: %s %s\n", osName, osProductType );\r
-    fprintf( fp, "OS version: %d.%d.%d %S\n", osVersionInfoEx.dwMajorVersion, osVersionInfoEx.dwMinorVersion, osVersionInfoEx.dwBuildNumber, osVersionInfoEx.szCSDVersion );\r
+    fprintf( fp, "OS version: %d.%d.%d %S\n", \r
+                osVersionInfoEx.dwMajorVersion, osVersionInfoEx.dwMinorVersion, \r
+                osVersionInfoEx.dwBuildNumber, osVersionInfoEx.szCSDVersion );\r
     fprintf( fp, "Processor architecture: %s\n", processorArchitecture );\r
     fprintf( fp, "WoW64 process: %s\n", IsWow64() ? "Yes" : "No" );\r
 }\r
@@ -228,6 +231,7 @@ typedef struct
 {\r
     float sine[TABLE_SIZE];\r
        double phase;\r
+    double phaseIncrement;\r
     volatile int fadeIn;\r
     volatile int fadeOut;\r
     double amp;\r
@@ -257,7 +261,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
     for( i=0; i<framesPerBuffer; i++ )\r
     {\r
         float x = data->sine[(int)data->phase];\r
-        data->phase += 20;\r
+        data->phase += data->phaseIncrement;\r
         if( data->phase >= TABLE_SIZE ){\r
                        data->phase -= TABLE_SIZE;\r
                }\r
@@ -288,7 +292,8 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
 #define NO      0\r
 \r
 \r
-static int playUntilKeyPress( int deviceIndex, float sampleRate, int framesPerUserBuffer, int framesPerWmmeBuffer, int wmmeBufferCount )\r
+static int playUntilKeyPress( int deviceIndex, float sampleRate, \r
+                             int framesPerUserBuffer, int framesPerWmmeBuffer, int wmmeBufferCount )\r
 {\r
     PaStreamParameters outputParameters;\r
     PaWinMmeStreamInfo wmmeStreamInfo;\r
@@ -324,13 +329,15 @@ static int playUntilKeyPress( int deviceIndex, float sampleRate, int framesPerUs
     data.amp = 0;\r
     data.fadeIn = 1;\r
     data.fadeOut = 0;\r
+    data.phase = 0;\r
+    data.phaseIncrement = 15 + ((rand()%100) / 10); // randomise pitch\r
 \r
     err = Pa_StartStream( stream );\r
     if( err != paNoError ) goto error;\r
 \r
 \r
     do{\r
-        printf( "Trying buffer size %d.\nIf it sounds smooth press 'y', if it sounds bad press 'n' ('q' to quit)\n", framesPerWmmeBuffer );\r
+        printf( "Trying buffer size %d.\nIf it sounds smooth (without clicks or glitches) press 'y', if it sounds bad press 'n' ('q' to quit)\n", framesPerWmmeBuffer );\r
         c = tolower(_getch());\r
         if( c == 'q' ){\r
             Pa_Terminate();\r
@@ -364,7 +371,7 @@ static void usage( int wmmeHostApiIndex )
     fprintf( stderr, "Invalid device index. Use one of these:\n" );\r
     for( i=0; i < Pa_GetDeviceCount(); ++i ){\r
 \r
-        if( Pa_GetDeviceInfo(i)->hostApi == wmmeHostApiIndex && Pa_GetDeviceInfo(i)->maxOutputChannels > 0 )\r
+        if( Pa_GetDeviceInfo(i)->hostApi == wmmeHostApiIndex && Pa_GetDeviceInfo(i)->maxOutputChannels > 0  )\r
             fprintf( stderr, "%d (%s)\n", i, Pa_GetDeviceInfo(i)->name );\r
     }\r
     Pa_Terminate();\r
@@ -372,11 +379,9 @@ static void usage( int wmmeHostApiIndex )
 }\r
 \r
 /*\r
-    TODO: test at 22050 44100, 48000, 96000, mono and stereo and surround\r
-\r
-    TODO: could be testing with 80% CPU load\r
-\r
-    another thing to try would be setting the timeBeginPeriod granularity to 1ms and see if it changes the behavior\r
+    ideas: \r
+        o- could be testing with 80% CPU load\r
+        o- could test with different channel counts\r
 */\r
 \r
 int main(int argc, char* argv[])\r
@@ -459,7 +464,7 @@ int main(int argc, char* argv[])
     fprintf( resultsFp, "Sample rate: %f\n", (float)sampleRate );\r
     fprintf( resultsFp, "Buffer count, Smallest working buffer size (frames), Smallest working buffering latency (frames), Smallest working buffering latency (Seconds)\n" );\r
 \r
-    for( wmmeBufferCount = wmmeMinBufferCount; wmmeBufferCount <= wmmeMaxBufferCount; ++wmmeBufferCount ){ // TODO print out range we're going to try before starting\r
+    for( wmmeBufferCount = wmmeMinBufferCount; wmmeBufferCount <= wmmeMaxBufferCount; ++wmmeBufferCount ){\r
  \r
         printf( "Test %d of %d\n", (wmmeBufferCount - wmmeMinBufferCount) + 1, (wmmeMaxBufferCount-wmmeMinBufferCount) + 1 );\r
         printf( "Testing with %d buffers...\n", wmmeBufferCount );\r