Bläddra i källkod

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

master
kevin 11 år sedan
förälder
incheckning
e550f859c5
2 ändrade filer med 32 tillägg och 7 borttagningar
  1. 26
    6
      app/cmScore.c
  2. 6
    1
      app/cmScore.h

+ 26
- 6
app/cmScore.c Visa fil

9
 #include "cmMidi.h"
9
 #include "cmMidi.h"
10
 #include "cmLex.h"
10
 #include "cmLex.h"
11
 #include "cmCsv.h"
11
 #include "cmCsv.h"
12
+#include "cmSymTbl.h"
12
 #include "cmMidiFile.h"
13
 #include "cmMidiFile.h"
13
 #include "cmAudioFile.h"
14
 #include "cmAudioFile.h"
14
 #include "cmTimeLine.h"
15
 #include "cmTimeLine.h"
78
 {
79
 {
79
   cmErr_t           err;
80
   cmErr_t           err;
80
   cmCsvH_t          cH;
81
   cmCsvH_t          cH;
82
+  cmSymTblH_t       stH;
81
   cmScCb_t          cbFunc;
83
   cmScCb_t          cbFunc;
82
   void*             cbArg;
84
   void*             cbArg;
83
   cmChar_t*         fn;
85
   cmChar_t*         fn;
355
     for(i=0; i<p->setCnt; ++i)
357
     for(i=0; i<p->setCnt; ++i)
356
     {
358
     {
357
       cmMemFree(p->sets[i].eleArray);
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
     cmMemFree(p->sets);
364
     cmMemFree(p->sets);
361
   }
365
   }
708
 }
712
 }
709
 
713
 
710
 
714
 
715
+
711
 // Calculate the total number of all types of sets and
716
 // Calculate the total number of all types of sets and
712
 // then convert each of the cmScSet_t linked list's to 
717
 // then convert each of the cmScSet_t linked list's to 
713
 // a single linear cmScoreSet_t list (p->sets[]).
718
 // a single linear cmScoreSet_t list (p->sets[]).
778
 
783
 
779
       // allocate the section array
784
       // allocate the section array
780
       p->sets[i].varId    = _cmScVarFlagToId(sp->typeFl);
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
       // fill in the section array with sections which this set will be applied to
791
       // fill in the section array with sections which this set will be applied to
785
       ep = sp->sects;
792
       ep = sp->sects;
791
           rc = cmErrMsg(&p->err,kSyntaxErrScRC,"The section labelled '%s' could not be found for the set which includes row number %i.",ep->label,rowNumb);        
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
         else
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
           sp->setArray = cmMemResizeP(cmScoreSet_t*,sp->setArray,++sp->setCnt);
814
           sp->setArray = cmMemResizeP(cmScoreSet_t*,sp->setArray,++sp->setCnt);
797
           sp->setArray[sp->setCnt-1] = p->sets + i;
815
           sp->setArray[sp->setCnt-1] = p->sets + i;
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
   cmScRC_t rc = kOkScRC;
1130
   cmScRC_t rc = kOkScRC;
1113
   if((rc = cmScoreFinalize(hp)) != kOkScRC )
1131
   if((rc = cmScoreFinalize(hp)) != kOkScRC )
1117
 
1135
 
1118
   cmErrSetup(&p->err,&ctx->rpt,"Score");
1136
   cmErrSetup(&p->err,&ctx->rpt,"Score");
1119
 
1137
 
1138
+  p->stH   = stH;
1139
+
1120
   if((rc = _cmScParseFile(p,ctx,fn)) != kOkScRC )
1140
   if((rc = _cmScParseFile(p,ctx,fn)) != kOkScRC )
1121
     goto errLabel;
1141
     goto errLabel;
1122
 
1142
 
1881
 void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )
1901
 void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )
1882
 {
1902
 {
1883
   cmScH_t h = cmScNullHandle;
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
     return;
1905
     return;
1886
 
1906
 
1887
   cmScorePrint(h,&ctx->rpt);
1907
   cmScorePrint(h,&ctx->rpt);

+ 6
- 1
app/cmScore.h Visa fil

94
     unsigned               varId;      // See kXXXVarScId flags above
94
     unsigned               varId;      // See kXXXVarScId flags above
95
     cmScoreEvt_t**         eleArray;   // Events that make up this set in time order
95
     cmScoreEvt_t**         eleArray;   // Events that make up this set in time order
96
     unsigned               eleCnt;     // 
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
     bool                   doneFl;
101
     bool                   doneFl;
98
     double                 value;
102
     double                 value;
99
     struct cmScoreSet_str* llink;      // cmScoreLoc_t setList link
103
     struct cmScoreSet_str* llink;      // cmScoreLoc_t setList link
132
   // If provided the dynRefArray[] is copied into an internal array.
136
   // If provided the dynRefArray[] is copied into an internal array.
133
   // The physical array passed here therefore does not need to remain valid.
137
   // The physical array passed here therefore does not need to remain valid.
134
   // Set 'srate' to zero if the score will not be used to perform measurement calculations.
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
   cmScRC_t      cmScoreFinalize(   cmScH_t* hp );
141
   cmScRC_t      cmScoreFinalize(   cmScH_t* hp );
137
 
142
 
138
   // Filename of last successfuly loaded score file.
143
   // Filename of last successfuly loaded score file.

Laddar…
Avbryt
Spara