Explorar el Código

cmScore.h/c: Added sectArray[],symArray[],costSymArray[] to cmScoreSet_t.

master
kevin hace 11 años
padre
commit
e550f859c5
Se han modificado 2 ficheros con 32 adiciones y 7 borrados
  1. 26
    6
      app/cmScore.c
  2. 6
    1
      app/cmScore.h

+ 26
- 6
app/cmScore.c Ver fichero

@@ -9,6 +9,7 @@
9 9
 #include "cmMidi.h"
10 10
 #include "cmLex.h"
11 11
 #include "cmCsv.h"
12
+#include "cmSymTbl.h"
12 13
 #include "cmMidiFile.h"
13 14
 #include "cmAudioFile.h"
14 15
 #include "cmTimeLine.h"
@@ -78,6 +79,7 @@ typedef struct
78 79
 {
79 80
   cmErr_t           err;
80 81
   cmCsvH_t          cH;
82
+  cmSymTblH_t       stH;
81 83
   cmScCb_t          cbFunc;
82 84
   void*             cbArg;
83 85
   cmChar_t*         fn;
@@ -355,7 +357,9 @@ cmScRC_t _cmScFinalize( cmSc_t* p )
355 357
     for(i=0; i<p->setCnt; ++i)
356 358
     {
357 359
       cmMemFree(p->sets[i].eleArray);
358
-      //cmMemFree(p->sets[i].sectArray);
360
+      cmMemFree(p->sets[i].sectArray);
361
+      cmMemFree(p->sets[i].symArray);
362
+      cmMemFree(p->sets[i].costSymArray);
359 363
     }
360 364
     cmMemFree(p->sets);
361 365
   }
@@ -708,6 +712,7 @@ cmScoreSection_t* _cmScLabelToSection( cmSc_t* p, const cmChar_t* label )
708 712
 }
709 713
 
710 714
 
715
+
711 716
 // Calculate the total number of all types of sets and
712 717
 // then convert each of the cmScSet_t linked list's to 
713 718
 // a single linear cmScoreSet_t list (p->sets[]).
@@ -778,8 +783,10 @@ cmScRC_t _cmScProcSets( cmSc_t* p )
778 783
 
779 784
       // allocate the section array
780 785
       p->sets[i].varId    = _cmScVarFlagToId(sp->typeFl);
781
-      //p->sets[i].sectCnt   = en;    
782
-      //p->sets[i].sectArray = cmMemAllocZ(cmScoreSection_t*,en);
786
+      p->sets[i].sectCnt   = en;    
787
+      p->sets[i].sectArray = cmMemAllocZ(cmScoreSection_t*,en);
788
+      p->sets[i].symArray  = cmMemAllocZ(unsigned,en);
789
+      p->sets[i].costSymArray = cmMemAllocZ(unsigned,en);
783 790
 
784 791
       // fill in the section array with sections which this set will be applied to
785 792
       ep = sp->sects;
@@ -791,7 +798,18 @@ cmScRC_t _cmScProcSets( cmSc_t* p )
791 798
           rc = cmErrMsg(&p->err,kSyntaxErrScRC,"The section labelled '%s' could not be found for the set which includes row number %i.",ep->label,rowNumb);        
792 799
         else
793 800
         {
794
-          //= p->sets[i].sectArray[j];
801
+          if( cmSymTblIsValid(p->stH) )
802
+          {
803
+            p->sets[i].symArray[j]     = cmSymTblRegisterFmt(p->stH,"%c-%s", _cmScVarIdToChar(p->sets[i].varId),ep->label);
804
+            p->sets[i].costSymArray[j] = cmSymTblRegisterFmt(p->stH,"c%c-%s",_cmScVarIdToChar(p->sets[i].varId),ep->label);
805
+          }
806
+          else
807
+          {
808
+            p->sets[i].symArray[j] = cmInvalidId;
809
+            p->sets[i].symArray[j] = cmInvalidId;
810
+          }
811
+
812
+          p->sets[i].sectArray[j] = sp;
795 813
 
796 814
           sp->setArray = cmMemResizeP(cmScoreSet_t*,sp->setArray,++sp->setCnt);
797 815
           sp->setArray[sp->setCnt-1] = p->sets + i;
@@ -1107,7 +1125,7 @@ cmScRC_t _cmScInitLocArray( cmSc_t* p )
1107 1125
 }
1108 1126
 
1109 1127
 
1110
-cmScRC_t cmScoreInitialize( cmCtx_t* ctx, cmScH_t* hp, const cmChar_t* fn, double srate, const unsigned* dynRefArray, unsigned dynRefCnt, cmScCb_t cbFunc, void* cbArg )
1128
+cmScRC_t cmScoreInitialize( cmCtx_t* ctx, cmScH_t* hp, const cmChar_t* fn, double srate, const unsigned* dynRefArray, unsigned dynRefCnt, cmScCb_t cbFunc, void* cbArg, cmSymTblH_t stH )
1111 1129
 {
1112 1130
   cmScRC_t rc = kOkScRC;
1113 1131
   if((rc = cmScoreFinalize(hp)) != kOkScRC )
@@ -1117,6 +1135,8 @@ cmScRC_t cmScoreInitialize( cmCtx_t* ctx, cmScH_t* hp, const cmChar_t* fn, doubl
1117 1135
 
1118 1136
   cmErrSetup(&p->err,&ctx->rpt,"Score");
1119 1137
 
1138
+  p->stH   = stH;
1139
+
1120 1140
   if((rc = _cmScParseFile(p,ctx,fn)) != kOkScRC )
1121 1141
     goto errLabel;
1122 1142
 
@@ -1881,7 +1901,7 @@ void cmScorePrint( cmScH_t h, cmRpt_t* rpt )
1881 1901
 void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )
1882 1902
 {
1883 1903
   cmScH_t h = cmScNullHandle;
1884
-  if( cmScoreInitialize(ctx,&h,fn,0,NULL,0,NULL,NULL) != kOkScRC )
1904
+  if( cmScoreInitialize(ctx,&h,fn,0,NULL,0,NULL,NULL, cmSymTblNullHandle ) != kOkScRC )
1885 1905
     return;
1886 1906
 
1887 1907
   cmScorePrint(h,&ctx->rpt);

+ 6
- 1
app/cmScore.h Ver fichero

@@ -94,6 +94,10 @@ extern "C" {
94 94
     unsigned               varId;      // See kXXXVarScId flags above
95 95
     cmScoreEvt_t**         eleArray;   // Events that make up this set in time order
96 96
     unsigned               eleCnt;     // 
97
+    cmScoreSection_t**     sectArray;  // Sections this set will be applied to
98
+    unsigned               sectCnt;    // 
99
+    unsigned*              symArray;   // symArray[sectCnt] - symbol name of all variables represented by this set (e.g '1a-e', '1b-e', '2-t', etc)
100
+    unsigned*              costSymArray; // costSymArray[sectCnt] - same as symbols in symArray[] with 'c' prepended to front
97 101
     bool                   doneFl;
98 102
     double                 value;
99 103
     struct cmScoreSet_str* llink;      // cmScoreLoc_t setList link
@@ -132,7 +136,8 @@ extern "C" {
132 136
   // If provided the dynRefArray[] is copied into an internal array.
133 137
   // The physical array passed here therefore does not need to remain valid.
134 138
   // Set 'srate' to zero if the score will not be used to perform measurement calculations.
135
-  cmScRC_t      cmScoreInitialize( cmCtx_t* ctx, cmScH_t* hp, const cmChar_t* fn, double srate, const unsigned* dynRefArray, unsigned dynRefCnt, cmScCb_t cbFunc, void* cbArg );
139
+  // The symbol table is only necessary if valid symbols are to be assigned to the cmScoreSet_t.symArray[].
140
+  cmScRC_t      cmScoreInitialize( cmCtx_t* ctx, cmScH_t* hp, const cmChar_t* fn, double srate, const unsigned* dynRefArray, unsigned dynRefCnt, cmScCb_t cbFunc, void* cbArg, cmSymTblH_t stH );
136 141
   cmScRC_t      cmScoreFinalize(   cmScH_t* hp );
137 142
 
138 143
   // Filename of last successfuly loaded score file.

Loading…
Cancelar
Guardar