a97c687f9dcb — Chris Cannam tip 4 years ago
Do some timing calculations
2 files changed, 65 insertions(+), 0 deletions(-)

M rubberbandtest.xcodeproj/project.pbxproj
M rubberbandtest/ViewController.mm
M rubberbandtest.xcodeproj/project.pbxproj +17 -0
@@ 188,9 188,11 @@
 TargetAttributes = {
 					A8DB68651A36F0A100E0BE5F = {
 						CreatedOnToolsVersion = 6.1.1;
+						DevelopmentTeam = 73F996B92S;
 					};
 					A8DB687E1A36F0A100E0BE5F = {
 						CreatedOnToolsVersion = 6.1.1;
+						DevelopmentTeam = 73F996B92S;
 						TestTargetID = A8DB68651A36F0A100E0BE5F;
 					};
 				};

          
@@ 322,6 324,7 @@
 ONLY_ACTIVE_ARCH = YES;
 				SDKROOT = iphoneos;
 				TARGETED_DEVICE_FAMILY = "1,2";
+				"VALID_ARCHS[sdk=*]" = "arm64 armv7 armv7s";
 			};
 			name = Debug;
 		};

          
@@ 365,13 368,17 @@
 isa = XCBuildConfiguration;
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+				CODE_SIGN_IDENTITY = "iPhone Developer";
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				INFOPLIST_FILE = rubberbandtest/Info.plist;
+				IPHONEOS_DEPLOYMENT_TARGET = 6.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
 					"$(PROJECT_DIR)/rubberbandtest",
 				);
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				PROVISIONING_PROFILE = "";
 				TARGETED_DEVICE_FAMILY = "1,2";
 			};
 			name = Debug;

          
@@ 380,13 387,17 @@
 isa = XCBuildConfiguration;
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+				CODE_SIGN_IDENTITY = "iPhone Developer";
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				INFOPLIST_FILE = rubberbandtest/Info.plist;
+				IPHONEOS_DEPLOYMENT_TARGET = 6.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				LIBRARY_SEARCH_PATHS = (
 					"$(inherited)",
 					"$(PROJECT_DIR)/rubberbandtest",
 				);
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				PROVISIONING_PROFILE = "";
 				TARGETED_DEVICE_FAMILY = "1,2";
 			};
 			name = Release;

          
@@ 395,6 406,8 @@
 isa = XCBuildConfiguration;
 			buildSettings = {
 				BUNDLE_LOADER = "$(TEST_HOST)";
+				CODE_SIGN_IDENTITY = "iPhone Developer";
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(SDKROOT)/Developer/Library/Frameworks",
 					"$(inherited)",

          
@@ 406,6 419,7 @@
 INFOPLIST_FILE = rubberbandtestTests/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				PROVISIONING_PROFILE = "";
 				TEST_HOST = "$(BUILT_PRODUCTS_DIR)/rubberbandtest.app/rubberbandtest";
 			};
 			name = Debug;

          
@@ 414,6 428,8 @@
 isa = XCBuildConfiguration;
 			buildSettings = {
 				BUNDLE_LOADER = "$(TEST_HOST)";
+				CODE_SIGN_IDENTITY = "iPhone Developer";
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(SDKROOT)/Developer/Library/Frameworks",
 					"$(inherited)",

          
@@ 421,6 437,7 @@
 INFOPLIST_FILE = rubberbandtestTests/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
 				PRODUCT_NAME = "$(TARGET_NAME)";
+				PROVISIONING_PROFILE = "";
 				TEST_HOST = "$(BUILT_PRODUCTS_DIR)/rubberbandtest.app/rubberbandtest";
 			};
 			name = Release;

          
M rubberbandtest/ViewController.mm +48 -0
@@ 10,6 10,13 @@
  #include "rubberband/RubberBandStretcher.h"
 
+#include <iostream>
+
+#include <sys/time.h>
+
+using std::cerr;
+using std::endl;
+
 using namespace RubberBand;
 
 @interface ViewController ()

          
@@ 22,6 29,47 @@
 [super viewDidLoad];
 
     RubberBandStretcher stretcher(44100, 1);
+    stretcher.setTimeRatio(1.2);
+    stretcher.setPitchScale(1.02);
+    
+    timeval tv;
+    (void)gettimeofday(&tv, 0);
+
+    int countIn = 0, countOut = 0;
+    
+    int n = 10000;
+    for (int i = 0; i < n; ++i) {
+        float *buffer = new float[1024];
+        for (int j = 0; j < 1024; ++j) {
+            buffer[j] = drand48();
+        }
+        stretcher.process(&buffer, 1024, i == n-1);
+        countIn += 1024;
+        delete[] buffer;
+        int avail = 0;
+        while ((avail = stretcher.available()) > 0) {
+            countOut += avail;
+            float *out = new float[avail];
+            stretcher.retrieve(&out, avail);
+            delete[] out;
+        }
+    }
+
+    timeval etv;
+    (void)gettimeofday(&etv, 0);
+    
+    etv.tv_sec -= tv.tv_sec;
+    if (etv.tv_usec < tv.tv_usec) {
+        etv.tv_usec += 1000000;
+        etv.tv_sec -= 1;
+    }
+    etv.tv_usec -= tv.tv_usec;
+    
+    double sec = double(etv.tv_sec) + (double(etv.tv_usec) / 1000000.0);
+    cerr << "elapsed time: " << sec << " sec, in frames/sec: " << countIn/sec << ", out frames/sec: " << countOut/sec << endl;
+
+    exit(0);
+    
     // Do any additional setup after loading the view, typically from a nib.
 }