Quellcode durchsuchen

cmXScore.h/c : The even-ness label is now written as a quoted string in the output CSV file so that the '*' token is correctly parsed by cmScore.

master
kevin vor 8 Jahren
Ursprung
Commit
68e34d29d7
2 geänderte Dateien mit 26 neuen und 8 gelöschten Zeilen
  1. 25
    7
      app/cmXScore.c
  2. 1
    1
      app/cmXScore.h

+ 25
- 7
app/cmXScore.c Datei anzeigen

16
 #include "cmMidiFile.h"
16
 #include "cmMidiFile.h"
17
 #include "cmLex.h"
17
 #include "cmLex.h"
18
 #include "cmCsv.h"
18
 #include "cmCsv.h"
19
+#include "cmSymTbl.h"
20
+#include "cmScore.h"
19
 
21
 
20
 #include "cmFile.h"
22
 #include "cmFile.h"
21
 #include "cmSymTbl.h"
23
 #include "cmSymTbl.h"
1376
       return kSyntaxErrorXsRC;
1378
       return kSyntaxErrorXsRC;
1377
 
1379
 
1378
 
1380
 
1379
-  cmXsMeas_t* mp = rV[0].note->meas;
1381
+  cmXsMeas_t* mp  = rV[0].note->meas;
1380
   cmXsNote_t* n0p = NULL;
1382
   cmXsNote_t* n0p = NULL;
1381
 
1383
 
1382
   assert( mp->number == measNumb );
1384
   assert( mp->number == measNumb );
1424
   {
1426
   {
1425
     switch( stateId )
1427
     switch( stateId )
1426
     {
1428
     {
1427
-      case kFindEventStId:
1429
+      case kFindEventStId:  // scanning past labels to an event line
1428
         {
1430
         {
1429
           unsigned voice,loc;
1431
           unsigned voice,loc;
1430
           if( sscanf(b,"%i %i",&voice,&loc) != 2 )
1432
           if( sscanf(b,"%i %i",&voice,&loc) != 2 )
1439
           cmXsReorder_t r;
1441
           cmXsReorder_t r;
1440
           char     pitchStr[4];
1442
           char     pitchStr[4];
1441
 
1443
 
1444
+          // parse an event line
1442
           if( sscanf(b,"%i %i %i %i %f %c%c%c",&r.voice,&r.locIdx,&r.tick,&r.durtn,&r.rval,pitchStr,pitchStr+1,pitchStr+2) == 8 )
1445
           if( sscanf(b,"%i %i %i %i %f %c%c%c",&r.voice,&r.locIdx,&r.tick,&r.durtn,&r.rval,pitchStr,pitchStr+1,pitchStr+2) == 8 )
1443
           {
1446
           {
1444
             pitchStr[3] = 0;
1447
             pitchStr[3] = 0;
1455
               r.midi = cmSciPitchToMidi(pitchStr);
1458
               r.midi = cmSciPitchToMidi(pitchStr);
1456
             }
1459
             }
1457
 
1460
 
1461
+            // store the record
1458
             assert( ri < rN );
1462
             assert( ri < rN );
1459
             rV[ri++] = r;
1463
             rV[ri++] = r;
1460
 
1464
 
1461
             continue;
1465
             continue;
1462
           }
1466
           }
1463
 
1467
 
1468
+          // the end of the measure was encountered -
1469
+          // reorder the measure based on the cmXsReorder_t in rV[ri]
1464
           if((rc =  _cmXScoreReorderMeas(p, measNumb, rV, ri )) != kOkXsRC )
1470
           if((rc =  _cmXScoreReorderMeas(p, measNumb, rV, ri )) != kOkXsRC )
1465
             goto errLabel;
1471
             goto errLabel;
1466
 
1472
 
1470
           // fall through
1476
           // fall through
1471
         }
1477
         }
1472
 
1478
 
1473
-      case kFindMeasStId:
1479
+      case kFindMeasStId:  // scanning for a bar-line
1474
         {
1480
         {
1475
           char colon;
1481
           char colon;
1476
           if( sscanf(b,"%i %c",&measNumb,&colon) == 2 && colon == ':' )
1482
           if( sscanf(b,"%i %c",&measNumb,&colon) == 2 && colon == ':' )
1878
     goto errLabel;
1884
     goto errLabel;
1879
 
1885
 
1880
   // col 15: even (all grace notes are 'even' notes
1886
   // col 15: even (all grace notes are 'even' notes
1881
-  if( cmCsvInsertIdentColAfter(p->csvH,lcp,&lcp, evenStr, 0) != kOkCsvRC )
1887
+  if( cmCsvInsertQTextColAfter(p->csvH,lcp,&lcp, evenStr, 0) != kOkCsvRC )
1882
   {
1888
   {
1883
     rc = cmErrMsg(&p->err,kCsvFailXsRC,"CSV insert failed on eveness flag label.");
1889
     rc = cmErrMsg(&p->err,kCsvFailXsRC,"CSV insert failed on eveness flag label.");
1884
     goto errLabel;
1890
     goto errLabel;
2184
   if( dynFn != NULL )
2190
   if( dynFn != NULL )
2185
     cmXScoreInsertDynamics(h, dynFn );
2191
     cmXScoreInsertDynamics(h, dynFn );
2186
 
2192
 
2187
-  if( reorderFn != NULL )
2188
-    cmXScoreReorder(h,reorderFn);
2193
+  //if( reorderFn != NULL )
2194
+  //  cmXScoreReorder(h,reorderFn);
2189
 
2195
 
2190
   if( outFn != NULL )
2196
   if( outFn != NULL )
2197
+  {
2198
+    cmScH_t scH = cmScNullHandle;
2199
+    double srate = 96000.0;
2200
+    
2191
     cmXScoreWriteCsv(h,outFn);
2201
     cmXScoreWriteCsv(h,outFn);
2192
-
2202
+    
2203
+    if( cmScoreInitialize( ctx, &scH, outFn, srate, NULL, 0, NULL, NULL, cmSymTblNullHandle) != kOkScRC )
2204
+      cmErrMsg(&ctx->err,kFileFailXsRC,"The generated CSV file could not be parsed.");
2205
+    else
2206
+      cmScoreFinalize(&scH);
2207
+    
2208
+    
2209
+  }
2210
+  
2193
   //cmXScoreReport(h,&ctx->rpt,true);
2211
   //cmXScoreReport(h,&ctx->rpt,true);
2194
 
2212
 
2195
   return cmXScoreFinalize(&h);
2213
   return cmXScoreFinalize(&h);

+ 1
- 1
app/cmXScore.h Datei anzeigen

35
   //
35
   //
36
   // Steps 1) and 2) can be automated by in emacs by:
36
   // Steps 1) and 2) can be automated by in emacs by:
37
   //
37
   //
38
-  // M-x load-file ~/src/emacs/rpoc_music_xml.el
38
+  // M-x load-file ~/src/emacs/proc_music_xml.el
39
   //
39
   //
40
   // 3) How to assigned dynamic markings (they are not attached to notes). (from MIDI file?)
40
   // 3) How to assigned dynamic markings (they are not attached to notes). (from MIDI file?)
41
   // 4) Tempo syntax is inconsistent (only a problem in full part2 score)     
41
   // 4) Tempo syntax is inconsistent (only a problem in full part2 score)     

Laden…
Abbrechen
Speichern