Переглянути джерело

cmProc4.h/c : Added comments to the score follower.

master
Kevin Larke 9 роки тому
джерело
коміт
0b46711fd8
2 змінених файлів з 25 додано та 13 видалено
  1. 16
    4
      cmProc4.c
  2. 9
    9
      cmProc4.h

+ 16
- 4
cmProc4.c Переглянути файл

@@ -2363,7 +2363,8 @@ void cmScMatcherPrint( cmScMatcher* p )
2363 2363
   unsigned esli       = 0;
2364 2364
   unsigned i,j,k;
2365 2365
 
2366
-  // get first/last scLocIdx from res[]
2366
+  // get first/last scLocIdx from res[] - this is the range of
2367
+  // score events that the score matcher has identified
2367 2368
   for(i=0; i<p->ri; ++i)
2368 2369
     if( p->res[i].locIdx != cmInvalidIdx )
2369 2370
     {
@@ -2382,15 +2383,16 @@ void cmScMatcherPrint( cmScMatcher* p )
2382 2383
     aan += lp->evtCnt;
2383 2384
   }
2384 2385
 
2385
-  // allocate an array off 'aan' print records
2386
+  // allocate an array of 'aan' print records
2386 2387
   cmScMatcherPrint_t* a  = cmMemAllocZ(cmScMatcherPrint_t,aan);
2387 2388
 
2388
-  // fill a[] note and bar events from cmScoreLoc()
2389
+  // fill the cmScMatcherPrint_t array with note and bar events from the score
2389 2390
   for(i=bsli; i<=esli; ++i)
2390 2391
   {
2391 2392
     unsigned      scLocIdx = i;
2392 2393
     cmScoreLoc_t* lp       = cmScoreLoc(p->mp->scH, scLocIdx );
2393 2394
 
2395
+    // for each score event which occurs at this location
2394 2396
     for(j=0; j<lp->evtCnt; ++j)
2395 2397
     {
2396 2398
       assert( an < aan );
@@ -2400,6 +2402,7 @@ void cmScMatcherPrint( cmScMatcher* p )
2400 2402
 
2401 2403
       an += 1;
2402 2404
       
2405
+      
2403 2406
       switch( ep->type )
2404 2407
       {
2405 2408
         case kBarEvtScId:
@@ -2420,6 +2423,12 @@ void cmScMatcherPrint( cmScMatcher* p )
2420 2423
 
2421 2424
   }
2422 2425
 
2426
+  //
2427
+  // a[an] now contains a record for each note and bar event in the
2428
+  // time range associated with the score matcher's result array.
2429
+  //
2430
+
2431
+
2423 2432
   // for each result record
2424 2433
   for(i=0; i<p->ri; ++i)
2425 2434
   {
@@ -2428,7 +2437,7 @@ void cmScMatcherPrint( cmScMatcher* p )
2428 2437
     // if this result recd matched a score event
2429 2438
     if( cmIsFlag(rp->flags,kSmTruePosFl) )
2430 2439
     {
2431
-      // locate the matching score event
2440
+      // locate the matching score event in a[an]
2432 2441
       for(k=0; k<an; ++k)
2433 2442
         if( a[k].scLocIdx==p->mp->loc[rp->locIdx].scLocIdx && a[k].pitch==rp->pitch )
2434 2443
         {
@@ -2512,6 +2521,9 @@ void cmScMatcherPrint( cmScMatcher* p )
2512 2521
     }
2513 2522
   }
2514 2523
   
2524
+  printf("sloc bar  mni  ptch flag\n");
2525
+  printf("---- ---- ---- ---- ----\n");
2526
+
2515 2527
   for(i=0; i<an; ++i)
2516 2528
   {
2517 2529
     printf("%4i %4i %4i %4s %c%c%c\n",a[i].scLocIdx,a[i].barNumb,a[i].mni,

+ 9
- 9
cmProc4.h Переглянути файл

@@ -244,7 +244,7 @@ extern "C" {
244 244
   // Score location record. 
245 245
   typedef struct
246 246
   {
247
-    unsigned        evtCnt;       // 
247
+    unsigned        evtCnt;       // count of score events at this location (i.e. a chord will have more than one event at a given location)
248 248
     cmScMatchEvt_t* evtV;         // evtV[evtCnt]
249 249
     unsigned        scLocIdx;     // scH score location index
250 250
     int             barNumb;      // bar number of this location
@@ -312,13 +312,13 @@ extern "C" {
312 312
 
313 313
   typedef struct
314 314
   {
315
-    unsigned locIdx;
316
-    unsigned scEvtIdx;
317
-    unsigned mni;
318
-    unsigned smpIdx;
319
-    unsigned pitch;
320
-    unsigned vel;
321
-    unsigned flags;
315
+    unsigned locIdx;    // index into cmScMatch_t.loc[]
316
+    unsigned scEvtIdx;  // score event index 
317
+    unsigned mni;       // index of the performed MIDI event associated with this score location
318
+    unsigned smpIdx;    // sample time index of performed MIDI event
319
+    unsigned pitch;     // performed pitch 
320
+    unsigned vel;       // performed velocity
321
+    unsigned flags;     // smTruePosFl | smFalsePosFl 
322 322
   } cmScMatcherResult_t;
323 323
 
324 324
   struct cmScMatcher_str;
@@ -380,7 +380,7 @@ extern "C" {
380 380
   cmRC_t       cmScMatcherReset( cmScMatcher* p, unsigned scLocIdx );
381 381
 
382 382
   // Slide a score window 'hopCnt' times, beginning at 'bli' (an
383
-  // index int p->mp->loc[]) looking for the best match to p->midiBuf[].  
383
+  // index into p->mp->loc[]) looking for the best match to p->midiBuf[].  
384 384
   // The score window contain scWndN (p->mp->mcn-1) score locations.
385 385
   // Returns the index into p->mp->loc[] of the start of the best
386 386
   // match score window. The score associated

Завантаження…
Відмінити
Зберегти