diff scanpath.mm @ 4:79c7cf39a0a0

Fixed new mesh crash - static array bounds. Made home made mutex for wavetable access. Less clicks?
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 10 Dec 2012 13:00:03 +0000
parents d346ddc50f70
children 085d80989ba7
line wrap: on
line diff
--- a/scanpath.mm	Fri Dec 07 19:20:57 2012 +0000
+++ b/scanpath.mm	Mon Dec 10 13:00:03 2012 +0000
@@ -29,7 +29,9 @@
     scanMode = DISPLACEMENT;
     initWavetables();
     framesPerSample = 60.0/SAMPLE_RATE;
-
+    updateAccessing = false;
+    audioAccessing = false;
+    
 }
 void ScanPath::init(){
     framesPerSample = ofGetFrameRate()/SAMPLE_RATE;
@@ -37,8 +39,7 @@
 }
 //----------------------------------------------------------------
 ScanPath::~ScanPath(){
-    
-    //VECTORISE
+
 
     delete [] wavetableNew;
     delete [] wavetableOld;
@@ -47,7 +48,7 @@
 }
 
 void ScanPath::clear(){
-    //VECTORISE
+
     for(vector<Element>::iterator elitr = pathElements.begin(); elitr < pathElements.end(); elitr++){
         (*elitr).eLump->removeFromScanPath();
         (*elitr).eSpring->removeFromScanPath();
@@ -162,16 +163,18 @@
     // TODO THRED MUTEX HERE!??
     // this is called from graphics thread
     // reset the interp between frames
-    
-    /*
+
     int i = 0;
     while(audioAccessing){
         i++;
     }
-    cout << "buffers swapped while update!" << i << "times\n";
+    if(i > 0){
+        cout << "Update wavetables had to wait for audio access " << i << " times\n";
+        // hardly ever happens
+    }
     updateAccessing = true;
      
-     */
+
     switch(scanMode){
         case DISPLACEMENT:
             // now fill with new values
@@ -206,13 +209,9 @@
             break;
         default:
             break;
-            
-          
+    
     }
-    
-    
-    
- 
+
     temp = wavetableOld;
     wavetableOld = wavetableNew;
     wavetableNew = wavetableUpdate;
@@ -247,15 +246,14 @@
     
     // TODO THRED MUTEX HERE!??
     // this is called from audio thread
-    /*
+
     int i = 0;
     while(updateAccessing){
         i++;
     }
     audioAccessing = true;
-    cout << "update is accessing while audio is" << i << "times\n";
-     
-     */
+    if(i>0) cout << "Audio thread had to wait for wavetable update " << i << " times\n";
+
     
     double oldsample = (1 - frac) * wavetableOld[n0] + frac * wavetableOld[n1];