Browse Source

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

master
Kevin Larke 9 years ago
parent
commit
0b46711fd8
2 changed files with 25 additions and 13 deletions
  1. 16
    4
      cmProc4.c
  2. 9
    9
      cmProc4.h

+ 16
- 4
cmProc4.c View File

2363
   unsigned esli       = 0;
2363
   unsigned esli       = 0;
2364
   unsigned i,j,k;
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
   for(i=0; i<p->ri; ++i)
2368
   for(i=0; i<p->ri; ++i)
2368
     if( p->res[i].locIdx != cmInvalidIdx )
2369
     if( p->res[i].locIdx != cmInvalidIdx )
2369
     {
2370
     {
2382
     aan += lp->evtCnt;
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
   cmScMatcherPrint_t* a  = cmMemAllocZ(cmScMatcherPrint_t,aan);
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
   for(i=bsli; i<=esli; ++i)
2390
   for(i=bsli; i<=esli; ++i)
2390
   {
2391
   {
2391
     unsigned      scLocIdx = i;
2392
     unsigned      scLocIdx = i;
2392
     cmScoreLoc_t* lp       = cmScoreLoc(p->mp->scH, scLocIdx );
2393
     cmScoreLoc_t* lp       = cmScoreLoc(p->mp->scH, scLocIdx );
2393
 
2394
 
2395
+    // for each score event which occurs at this location
2394
     for(j=0; j<lp->evtCnt; ++j)
2396
     for(j=0; j<lp->evtCnt; ++j)
2395
     {
2397
     {
2396
       assert( an < aan );
2398
       assert( an < aan );
2400
 
2402
 
2401
       an += 1;
2403
       an += 1;
2402
       
2404
       
2405
+      
2403
       switch( ep->type )
2406
       switch( ep->type )
2404
       {
2407
       {
2405
         case kBarEvtScId:
2408
         case kBarEvtScId:
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
   // for each result record
2432
   // for each result record
2424
   for(i=0; i<p->ri; ++i)
2433
   for(i=0; i<p->ri; ++i)
2425
   {
2434
   {
2428
     // if this result recd matched a score event
2437
     // if this result recd matched a score event
2429
     if( cmIsFlag(rp->flags,kSmTruePosFl) )
2438
     if( cmIsFlag(rp->flags,kSmTruePosFl) )
2430
     {
2439
     {
2431
-      // locate the matching score event
2440
+      // locate the matching score event in a[an]
2432
       for(k=0; k<an; ++k)
2441
       for(k=0; k<an; ++k)
2433
         if( a[k].scLocIdx==p->mp->loc[rp->locIdx].scLocIdx && a[k].pitch==rp->pitch )
2442
         if( a[k].scLocIdx==p->mp->loc[rp->locIdx].scLocIdx && a[k].pitch==rp->pitch )
2434
         {
2443
         {
2512
     }
2521
     }
2513
   }
2522
   }
2514
   
2523
   
2524
+  printf("sloc bar  mni  ptch flag\n");
2525
+  printf("---- ---- ---- ---- ----\n");
2526
+
2515
   for(i=0; i<an; ++i)
2527
   for(i=0; i<an; ++i)
2516
   {
2528
   {
2517
     printf("%4i %4i %4i %4s %c%c%c\n",a[i].scLocIdx,a[i].barNumb,a[i].mni,
2529
     printf("%4i %4i %4i %4s %c%c%c\n",a[i].scLocIdx,a[i].barNumb,a[i].mni,

+ 9
- 9
cmProc4.h View File

244
   // Score location record. 
244
   // Score location record. 
245
   typedef struct
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
     cmScMatchEvt_t* evtV;         // evtV[evtCnt]
248
     cmScMatchEvt_t* evtV;         // evtV[evtCnt]
249
     unsigned        scLocIdx;     // scH score location index
249
     unsigned        scLocIdx;     // scH score location index
250
     int             barNumb;      // bar number of this location
250
     int             barNumb;      // bar number of this location
312
 
312
 
313
   typedef struct
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
   } cmScMatcherResult_t;
322
   } cmScMatcherResult_t;
323
 
323
 
324
   struct cmScMatcher_str;
324
   struct cmScMatcher_str;
380
   cmRC_t       cmScMatcherReset( cmScMatcher* p, unsigned scLocIdx );
380
   cmRC_t       cmScMatcherReset( cmScMatcher* p, unsigned scLocIdx );
381
 
381
 
382
   // Slide a score window 'hopCnt' times, beginning at 'bli' (an
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
   // The score window contain scWndN (p->mp->mcn-1) score locations.
384
   // The score window contain scWndN (p->mp->mcn-1) score locations.
385
   // Returns the index into p->mp->loc[] of the start of the best
385
   // Returns the index into p->mp->loc[] of the start of the best
386
   // match score window. The score associated
386
   // match score window. The score associated

Loading…
Cancel
Save