comparison scanpath.mm @ 5:085d80989ba7

Release 1.01
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 10 Dec 2012 16:20:57 +0000
parents 79c7cf39a0a0
children 4ea605899aca
comparison
equal deleted inserted replaced
4:79c7cf39a0a0 5:085d80989ba7
157 } 157 }
158 //---------------------------------------------------------------- 158 //----------------------------------------------------------------
159 void ScanPath::updateWavetables(){ 159 void ScanPath::updateWavetables(){
160 // swap old , new 160 // swap old , new
161 double * temp; 161 double * temp;
162 162 if(pathElements.size() == 0) return;
163 // TODO THRED MUTEX HERE!?? 163 // TODO THRED MUTEX HERE!??
164 // this is called from graphics thread 164 // this is called from graphics thread
165 // reset the interp between frames 165 // reset the interp between frames
166 166 /*
167 int i = 0; 167 int i = 0;
168 while(audioAccessing){ 168 while(audioAccessing){
169 i++; 169 i++;
170 } 170 }
171 if(i > 0){ 171 if(i > 0){
172 cout << "Update wavetables had to wait for audio access " << i << " times\n"; 172 cout << "Update wavetables had to wait for audio access " << i << " times\n";
173 // hardly ever happens 173 // hardly ever happens
174 } 174 }
175 */
175 updateAccessing = true; 176 updateAccessing = true;
176 177
177 178
178 switch(scanMode){ 179 switch(scanMode){
179 case DISPLACEMENT: 180 case DISPLACEMENT:
180 // now fill with new values 181 // now fill with new values
181 for(int i = 0; i < numElements; i++){ 182 for(int i = 0; i < numElements; i++){
182 // double check 183 // double check
183 if(pathElements[i].eLump->isInScanPath){ 184
184 wavetableUpdate[i] = pathElements[i].eLump->scanRadialDisplacement()/1.5; 185 wavetableUpdate[i] = pathElements[i].eLump->scanRadialDisplacement();
185 } 186
186 187
187 } 188 }
188 break; 189 break;
189 case SPEED: 190 case SPEED:
190 for(int i = 0; i < numElements; i++){ 191 for(int i = 0; i < numElements; i++){
191 if(pathElements[i].eLump->isInScanPath){ 192
192 wavetableUpdate[i] = pathElements[i].eLump->scanLumpSpeed(); 193 wavetableUpdate[i] = pathElements[i].eLump->scanLumpSpeed();
193 } 194
194 } 195 }
195 break; 196 break;
196 case SPRING_FORCE: 197 case SPRING_FORCE:
197 for(int i = 0; i < numElements; i++){ 198 for(int i = 0; i < numElements; i++){
198 if(pathElements[i].eSpring->isInScanPath){ 199 if(pathElements[i].eSpring->isInScanPath){
231 // get next sample 232 // get next sample
232 233
233 double ScanPath::getNextSample(double aPhasor){ 234 double ScanPath::getNextSample(double aPhasor){
234 // move along path, interpolating between points 235 // move along path, interpolating between points
235 // move between frames too 236 // move between frames too
237 if(pathElements.size() == 0) return 0.0;
238
236 double alongPath = aPhasor*double(numElements); 239 double alongPath = aPhasor*double(numElements);
237 240
238 // indexes for interpolated points 241 // indexes for interpolated points
239 int n0 = floor(alongPath); 242 int n0 = floor(alongPath);
240 int n1 = n0+1; 243 int n1 = n0+1;
244 247
245 double frac = alongPath - double(n0); 248 double frac = alongPath - double(n0);
246 249
247 // TODO THRED MUTEX HERE!?? 250 // TODO THRED MUTEX HERE!??
248 // this is called from audio thread 251 // this is called from audio thread
249 252 /*
250 int i = 0; 253 int i = 0;
251 while(updateAccessing){ 254 while(updateAccessing){
252 i++; 255 i++;
253 } 256 }
257 */
254 audioAccessing = true; 258 audioAccessing = true;
255 if(i>0) cout << "Audio thread had to wait for wavetable update " << i << " times\n"; 259 // if(i>0) cout << "Audio thread had to wait for wavetable update " << i << " times\n";
256 260
257 261
258 double oldsample = (1 - frac) * wavetableOld[n0] + frac * wavetableOld[n1]; 262 double oldsample = (1 - frac) * wavetableOld[n0] + frac * wavetableOld[n1];
259 263
260 double newsample = (1 - frac) * wavetableNew[n0] + frac * wavetableNew[n1]; 264 double newsample = (1 - frac) * wavetableNew[n0] + frac * wavetableNew[n1];