Bladeren bron

Merge branch 'develop' of gitea.larke.org:klarke/libcm into develop

master
kevin 4 jaren geleden
bovenliggende
commit
47d4dda2b0
12 gewijzigde bestanden met toevoegingen van 488 en 114 verwijderingen
  1. 17
    0
      .gitignore
  2. 44
    3
      src/cmAudDsp.c
  3. 2
    1
      src/cmAudDsp.h
  4. 4
    0
      src/cmAudioNrtDev.c
  5. 12
    10
      src/cmAudioSys.h
  6. 45
    0
      src/cmPP_NARG.h
  7. 43
    16
      src/dsp/cmDspBuiltIn.c
  8. 174
    1
      src/dsp/cmDspFx.c
  9. 1
    0
      src/dsp/cmDspFx.h
  10. 58
    15
      src/dsp/cmDspPgm.c
  11. 75
    66
      src/dsp/cmDspPgmKrTimeLineLiteAf.c
  12. 13
    2
      src/dsp/cmDspSys.h

+ 17
- 0
.gitignore Bestand weergeven

@@ -1,3 +1,20 @@
1 1
 Makefile.in
2 2
 .DS_Store
3
+aclocal.m4
4
+config.h.in
5
+config.h.in~
6
+configure
7
+Makefile.in
8
+
9
+autom4te.cache
10
+build-aux
11
+
12
+m4/libtool.m4
13
+m4/lt~obsolete.m4
14
+m4/libtool.m4
15
+m4/ltoptions.m4
16
+m4/ltsugar.m4
17
+m4/ltversion.m4
18
+m4/lt~obsolete.m4
19
+m4/.DS_Store
3 20
 

+ 44
- 3
src/cmAudDsp.c Bestand weergeven

@@ -354,10 +354,15 @@ cmAdRC_t _cmAdParseSysJsonTree( cmAd_t* p )
354 354
     {
355 355
       cmAudioSysArgs_t*   asap        = &p->asCfgArray[i].cfg.ssArray[j].args;
356 356
       const cmJsonNode_t* argsNodePtr = cmJsonArrayElementC(ssArrayNodePtr,j);
357
+      
358
+      asap->inDevIdx    = cmInvalidIdx;
359
+      asap->outDevIdx   = cmInvalidIdx;
360
+      asap->inDevLabel  = NULL;
361
+      asap->outDevLabel = NULL;
357 362
 
358 363
       if((jsRC = cmJsonMemberValues( argsNodePtr, &errLabelPtr,
359
-          "inDevIdx",           kIntTId,  &asap->inDevIdx,
360
-          "outDevIdx",          kIntTId,  &asap->outDevIdx,
364
+          "inDevLabel",         kStringTId,  &asap->inDevLabel,
365
+          "outDevLabel",        kStringTId,  &asap->outDevLabel,
361 366
           "syncToInputFl",      kTrueTId, &asap->syncInputFl,
362 367
           "msgQueueByteCnt",    kIntTId,  &asap->msgQueueByteCnt,
363 368
           "devFramesPerCycle",  kIntTId,  &asap->devFramesPerCycle,
@@ -443,6 +448,35 @@ cmAdRC_t _cmAdCreateAggDevices( cmAd_t* p )
443 448
   return rc;
444 449
 }
445 450
 
451
+cmAdRC_t _cmAdResolveDeviceLabels( cmAd_t* p )
452
+{
453
+  cmAdRC_t rc = kOkAdRC;
454
+  unsigned i,j;
455
+  
456
+  // for each cmAsAudioSysCfg record in audioSysCfgArray[]
457
+  for(i=0; i<p->asCfgCnt; ++i)
458
+  {
459
+    // for each audio system sub-subsystem 
460
+    for(j=0; j<p->asCfgArray[i].cfg.ssCnt; ++j)
461
+    {
462
+      cmAudioSysArgs_t*   asap        = &p->asCfgArray[i].cfg.ssArray[j].args;
463
+      if((asap->inDevIdx = cmApDeviceLabelToIndex( asap->inDevLabel )) == cmInvalidId )
464
+      {
465
+        rc = cmErrMsg(&p->err,kInvalidAudioDevIdxAdRC,"The audio input device '%s' could not be found.", cmStringNullGuard(asap->inDevLabel));
466
+        goto errLabel;
467
+      }
468
+      
469
+      if((asap->outDevIdx = cmApDeviceLabelToIndex( asap->outDevLabel )) == cmInvalidId )
470
+      {
471
+        rc = cmErrMsg(&p->err,kInvalidAudioDevIdxAdRC,"The audio input device '%s' could not be found.", cmStringNullGuard(asap->inDevLabel));
472
+        goto errLabel;
473
+      }
474
+    }
475
+  }
476
+ errLabel:
477
+  return rc;
478
+}
479
+
446 480
 cmAdRC_t _cmAdCreateNrtDevices( cmAd_t* p )
447 481
 {
448 482
   cmAdRC_t rc = kOkAdRC;
@@ -721,10 +755,11 @@ cmAdRC_t cmAudDspAlloc( cmCtx_t* ctx, cmAdH_t* hp, cmMsgSendFuncPtr_t cbFunc, vo
721 755
   if((rc = _cmAdParseSysJsonTree(p)) != kOkAdRC )
722 756
     goto errLabel;
723 757
 
758
+ 
724 759
   // create the aggregate device
725 760
   if( _cmAdCreateAggDevices(p) != kOkAdRC )
726 761
     goto errLabel;
727
-
762
+  
728 763
   // create the non-real-time devices
729 764
   if( _cmAdCreateNrtDevices(p) != kOkAdRC )
730 765
     goto errLabel;
@@ -740,6 +775,12 @@ cmAdRC_t cmAudDspAlloc( cmCtx_t* ctx, cmAdH_t* hp, cmMsgSendFuncPtr_t cbFunc, vo
740 775
     goto errLabel;
741 776
   }
742 777
 
778
+  if( _cmAdResolveDeviceLabels(p) != kOkApRC )
779
+  {
780
+    rc = cmErrMsg(&p->err,kAudioPortFailAdRC,"Audio device labels could not be resolved..");
781
+    goto errLabel;
782
+  }
783
+
743 784
   // initialize the audio buffer
744 785
   if( cmApBufInitialize( cmApDeviceCount(), p->meterMs ) != kOkApRC )
745 786
   {

+ 2
- 1
src/cmAudDsp.h Bestand weergeven

@@ -27,7 +27,8 @@ extern "C" {
27 27
     kAggDevCreateFailAdRC,
28 28
     kNrtDevSysFailAdRC,
29 29
     kAfpDevSysFailAdRC,
30
-    kNetSysFailAdRC
30
+    kNetSysFailAdRC,
31
+    kInvalidAudioDevIdxAdRC
31 32
   };
32 33
 
33 34
 

+ 4
- 0
src/cmAudioNrtDev.c Bestand weergeven

@@ -189,6 +189,10 @@ cmApRC_t cmApNrtAllocate( cmRpt_t* rpt )
189 189
 cmApRC_t cmApNrtFree()
190 190
 {
191 191
   cmApRC_t rc = kOkApRC;
192
+  
193
+  if( _cmNrt == NULL )
194
+    return rc;
195
+  
192 196
   cmApNrtDev_t* dp = _cmNrt->devs;
193 197
   while( dp != NULL )
194 198
   {

+ 12
- 10
src/cmAudioSys.h Bestand weergeven

@@ -130,16 +130,18 @@ extern "C" {
130 130
   // Audio device sub-sytem configuration record 
131 131
   typedef struct cmAudioSysArgs_str
132 132
   {
133
-    cmRpt_t*       rpt;               // system console object
134
-    unsigned       inDevIdx;          // input audio device
135
-    unsigned       outDevIdx;         // output audio device
136
-    bool           syncInputFl;       // true/false sync the DSP update callbacks with audio input/output
137
-    unsigned       msgQueueByteCnt;   // Size of the internal msg queue used to buffer msgs arriving via cmAudioSysDeliverMsg().
138
-    unsigned       devFramesPerCycle; // (512) Audio device samples per channel per device update buffer.
139
-    unsigned       dspFramesPerCycle; // (64)  Audio samples per channel per DSP cycle.
140
-    unsigned       audioBufCnt;       // (3)   Audio device buffers.
141
-    double         srate;             // Audio sample rate.
142
-    int            srateMult;         // Sample rate multiplication factor (negative for divide)
133
+    cmRpt_t*        rpt;               // system console object
134
+    const cmChar_t* inDevLabel;        // input audio device text label
135
+    const cmChar_t* outDevLabel;       // output audio device text label
136
+    unsigned        inDevIdx;          // input audio device index
137
+    unsigned        outDevIdx;         // output audio device index 
138
+    bool            syncInputFl;       // true/false sync the DSP update callbacks with audio input/output
139
+    unsigned        msgQueueByteCnt;   // Size of the internal msg queue used to buffer msgs arriving via cmAudioSysDeliverMsg().
140
+    unsigned        devFramesPerCycle; // (512) Audio device samples per channel per device update buffer.
141
+    unsigned        dspFramesPerCycle; // (64)  Audio samples per channel per DSP cycle.
142
+    unsigned        audioBufCnt;       // (3)   Audio device buffers.
143
+    double          srate;             // Audio sample rate.
144
+    int             srateMult;         // Sample rate multiplication factor (negative for divide)
143 145
   } cmAudioSysArgs_t;
144 146
 
145 147
   // Audio sub-system configuration record.

+ 45
- 0
src/cmPP_NARG.h Bestand weergeven

@@ -0,0 +1,45 @@
1
+#ifndef cmPP_NARG_H
2
+#define cmPP_NARG_H
3
+
4
+
5
+// Taken from here:
6
+// https://groups.google.com/forum/#!topic/comp.std.c/d-6Mj5Lko_s
7
+// and here:
8
+// https://stackoverflow.com/questions/4421681/how-to-count-the-number-of-arguments-passed-to-a-function-that-accepts-a-variabl
9
+
10
+#define PP_NARG(...) \
11
+         PP_NARG_(__VA_ARGS__,PP_RSEQ_N())
12
+
13
+#define PP_NARG_(...) \
14
+         PP_128TH_ARG(__VA_ARGS__)
15
+
16
+#define PP_128TH_ARG( \
17
+          _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
18
+         _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
19
+         _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
20
+         _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
21
+         _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
22
+         _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
23
+         _61,_62,_63,_64,_65,_66,_67,_68,_69,_70, \
24
+         _71,_72,_73,_74,_75,_76,_77,_78,_79,_80, \
25
+         _81,_82,_83,_84,_85,_86,_87,_88,_89,_90, \
26
+         _91,_92,_93,_94,_95,_96,_97,_98,_99,_100, \
27
+         _101,_102,_103,_104,_105,_106,_107,_108,_109,_110, \
28
+         _111,_112,_113,_114,_115,_116,_117,_118,_119,_120, \
29
+         _121,_122,_123,_124,_125,_126,_127,N,...) N
30
+#define PP_RSEQ_N() \
31
+         127,126,125,124,123,122,121,120, \
32
+         119,118,117,116,115,114,113,112,111,110, \
33
+         109,108,107,106,105,104,103,102,101,100, \
34
+         99,98,97,96,95,94,93,92,91,90, \
35
+         89,88,87,86,85,84,83,82,81,80, \
36
+         79,78,77,76,75,74,73,72,71,70, \
37
+         69,68,67,66,65,64,63,62,61,60, \
38
+         59,58,57,56,55,54,53,52,51,50, \
39
+         49,48,47,46,45,44,43,42,41,40, \
40
+         39,38,37,36,35,34,33,32,31,30, \
41
+         29,28,27,26,25,24,23,22,21,20, \
42
+         19,18,17,16,15,14,13,12,11,10, \
43
+         9,8,7,6,5,4,3,2,1,0
44
+
45
+#endif

+ 43
- 16
src/dsp/cmDspBuiltIn.c Bestand weergeven

@@ -1067,6 +1067,7 @@ enum
1067 1067
 {
1068 1068
   kChAoId,
1069 1069
   kGainAoId,
1070
+  kEnableAoId,
1070 1071
   kInAoId
1071 1072
 };
1072 1073
 
@@ -1075,23 +1076,30 @@ cmDspClass_t _cmAudioOutDC;
1075 1076
 typedef struct
1076 1077
 {
1077 1078
   cmDspInst_t inst;
1079
+  unsigned    onSymId;
1080
+  unsigned    offSymId;  
1078 1081
 } cmDspAudioOut_t;
1079 1082
 
1080 1083
 cmDspInst_t*  _cmDspAudioOutAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
1081 1084
 {
1082 1085
   cmDspVarArg_t args[] =
1083 1086
   {
1084
-    { "ch",  kChAoId,  0,      0, kInDsvFl | kUIntDsvFl   | kReqArgDsvFl, "Audio output channel index"},
1085
-    { "gain",kGainAoId,0,      0, kInDsvFl | kDoubleDsvFl | kOptArgDsvFl, "Output gain multiplier"},  
1086
-    { "in",  kInAoId,  0,      1, kInDsvFl | kAudioBufDsvFl, "Audio input" },
1087
+    { "ch",    kChAoId,    0,      0, kInDsvFl | kUIntDsvFl   | kReqArgDsvFl, "Audio output channel index"},
1088
+    { "gain",  kGainAoId,  0,      0, kInDsvFl | kDoubleDsvFl | kOptArgDsvFl, "Output gain multiplier"},
1089
+    { "enable",kEnableAoId,0,      0, kInDsvFl | kSymDsvFl    | kOptArgDsvFl, "Enable: on off"},
1090
+    { "in",    kInAoId,    0,      1, kInDsvFl | kAudioBufDsvFl, "Audio input" },
1087 1091
     { NULL, 0, 0, 0, 0 }
1088 1092
   };
1089 1093
 
1090 1094
   cmDspAudioOut_t* p = cmDspInstAlloc(cmDspAudioOut_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
1091 1095
 
1096
+  p->offSymId = cmSymTblRegisterStaticSymbol(ctx->stH,"off");
1097
+  p->onSymId  = cmSymTblRegisterStaticSymbol(ctx->stH,"on");
1098
+
1092 1099
 
1093 1100
   cmDspSetDefaultUInt(   ctx, &p->inst, kChAoId,   0,   0);
1094 1101
   cmDspSetDefaultDouble( ctx, &p->inst, kGainAoId, 0, 1.0);
1102
+  cmDspSetDefaultSymbol( ctx, &p->inst, kEnableAoId, p->onSymId );
1095 1103
 
1096 1104
   return &p->inst;
1097 1105
 }
@@ -1106,10 +1114,12 @@ cmDspRC_t _cmDspAudioOutReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
1106 1114
 
1107 1115
 cmDspRC_t _cmDspAudioOutExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
1108 1116
 {
1109
-  cmDspRC_t         rc     = kOkDspRC;
1110
-  unsigned          chIdx  = cmDspUInt(inst,kChAoId);
1111
-  unsigned          oChCnt = ctx->ctx->oChCnt;
1112
-  double            gain   = cmDspDouble(inst,kGainAoId);
1117
+  cmDspRC_t        rc       = kOkDspRC;
1118
+  cmDspAudioOut_t* p        = (cmDspAudioOut_t*)inst;
1119
+  unsigned         chIdx    = cmDspUInt(inst,kChAoId);
1120
+  bool             enableFl = cmDspSymbol(inst,kEnableAoId) == p->onSymId;
1121
+  unsigned         oChCnt   = ctx->ctx->oChCnt;
1122
+  double           gain     = cmDspDouble(inst,kGainAoId);
1113 1123
 
1114 1124
   if( chIdx >= oChCnt )
1115 1125
   {
@@ -1118,7 +1128,7 @@ cmDspRC_t _cmDspAudioOutExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
1118 1128
     return rc;
1119 1129
   }
1120 1130
 
1121
-  const cmSample_t* sp     = cmDspAudioBuf(ctx,inst,kInAoId,0);
1131
+  const cmSample_t* sp = cmDspAudioBuf(ctx,inst,kInAoId,0);
1122 1132
 
1123 1133
   if( sp == NULL )
1124 1134
   {
@@ -1132,7 +1142,7 @@ cmDspRC_t _cmDspAudioOutExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
1132 1142
   
1133 1143
   // if this channel is disabled or set to pass-through then chArray[chIdx] will be NULL
1134 1144
   if( ctx->ctx->oChArray[chIdx] != NULL )
1135
-    cmVOS_MultVVS(ctx->ctx->oChArray[chIdx],n,sp,(cmSample_t)gain);
1145
+    cmVOS_MultVVS(ctx->ctx->oChArray[chIdx],n,sp, (cmSample_t)(enableFl ? gain : 0));
1136 1146
 
1137 1147
   return kOkDspRC;
1138 1148
 }
@@ -1154,6 +1164,11 @@ cmDspRC_t _cmDspAudioOutRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
1154 1164
     case kGainAoId:
1155 1165
       cmDspSetEvent(ctx,inst,evt);
1156 1166
       break;
1167
+      
1168
+    case kEnableAoId:
1169
+      cmDspSetEvent(ctx,inst,evt);
1170
+      break;
1171
+
1157 1172
   }
1158 1173
   return rc;
1159 1174
 }
@@ -2907,6 +2922,7 @@ enum
2907 2922
   kLoopWtId,
2908 2923
   kBegWtId,
2909 2924
   kEndWtId,
2925
+  kChWtId,
2910 2926
   kCmdWtId,
2911 2927
   kOtWtId,
2912 2928
   kGainWtId,
@@ -2951,6 +2967,7 @@ typedef struct
2951 2967
   cmAudioFileH_t afH;           // current audio file handle
2952 2968
   int            nxtBegSmpIdx;  // the beg/end sample index to use with the next filename to arrive at port 'fn'
2953 2969
   int            nxtEndSmpIdx;  //
2970
+  unsigned       nxtChIdx;
2954 2971
   cmThreadH_t    thH;
2955 2972
   bool           loadFileFl;
2956 2973
   cmDspCtx_t*    ctx;
@@ -2976,6 +2993,7 @@ cmDspInst_t*  _cmDspWaveTableAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsi
2976 2993
     { "loop",   kLoopWtId,   0, 0, kInDsvFl  | kIntDsvFl  | kOptArgDsvFl, "-1=loop forever  >0=loop count (dflt:-1)"},
2977 2994
     { "beg",    kBegWtId,    0, 0, kInDsvFl  | kIntDsvFl  | kOptArgDsvFl, "File begin sample index" },
2978 2995
     { "end",    kEndWtId,    0, 0, kInDsvFl  | kIntDsvFl  | kOptArgDsvFl, "File end sample index (-1=play all)" },
2996
+    { "ch",     kChWtId,     0, 0, kInDsvFl  | kUIntDsvFl | kOptArgDsvFl, "File channel index 0=left, 1=right" },
2979 2997
     { "cmd",    kCmdWtId,    0, 0, kInDsvFl  | kSymDsvFl  | kOptArgDsvFl, "Command: on off"},
2980 2998
     { "ot",     kOtWtId,     0, 0, kInDsvFl  | kUIntDsvFl | kOptArgDsvFl, "Overtone count"},
2981 2999
     { "gain",   kGainWtId,   0, 0, kInDsvFl  | kDoubleDsvFl|kOptArgDsvFl, "Gain"},
@@ -3005,6 +3023,7 @@ cmDspInst_t*  _cmDspWaveTableAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsi
3005 3023
   cmDspSetDefaultInt(   ctx, &p->inst, kLoopWtId,  0,    -1 );
3006 3024
   cmDspSetDefaultInt(   ctx, &p->inst, kBegWtId,   0,     0 );
3007 3025
   cmDspSetDefaultInt(   ctx, &p->inst, kEndWtId,   0,    -1 );
3026
+  cmDspSetDefaultUInt(  ctx, &p->inst, kChWtId,    0,     0 );  
3008 3027
   cmDspSetDefaultSymbol(ctx, &p->inst, kCmdWtId,   p->onSymId );
3009 3028
   cmDspSetDefaultUInt(  ctx, &p->inst, kOtWtId,    0,     5 );
3010 3029
   cmDspSetDefaultDouble(ctx, &p->inst, kGainWtId,  0,     1.0 );
@@ -3038,10 +3057,9 @@ cmDspRC_t _cmDspWaveTableFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
3038 3057
 // mode then the the function will automatically begin reading from the begining of the
3039 3058
 // file segment.  If the end of the file segment is encountered and the wave table is not
3040 3059
 // in loop mode then the empty portion of wt[] will be set to zero.
3041
-cmDspRC_t _cmDspWaveTableReadBlock( cmDspCtx_t* ctx, cmDspWaveTable_t* p, cmSample_t* wt, unsigned rdSmpCnt, int begSmpIdx, int endSmpIdx, int maxLoopCnt  )
3060
+cmDspRC_t _cmDspWaveTableReadBlock( cmDspCtx_t* ctx, cmDspWaveTable_t* p, cmSample_t* wt, unsigned rdSmpCnt, unsigned chIdx, int begSmpIdx, int endSmpIdx, int maxLoopCnt  )
3042 3061
 {
3043 3062
   unsigned    actFrmCnt = 0;
3044
-  unsigned    chIdx     = 0;
3045 3063
   unsigned    chCnt     = 1;
3046 3064
   unsigned    fn        = endSmpIdx - p->fi + 1; // count of samples between p->fi and endSmpIdx
3047 3065
   unsigned    n0        = rdSmpCnt;
@@ -3117,9 +3135,10 @@ cmDspRC_t _cmDspWaveTableReadAudioFile( cmDspCtx_t* ctx, cmDspWaveTable_t* p, un
3117 3135
 {
3118 3136
   unsigned    n0        = rdSmpCnt;
3119 3137
   unsigned    n1        = 0;
3120
-  int         begSmpIdx = cmDspInt(&p->inst,kBegWtId);
3121
-  int         endSmpIdx = cmDspInt(&p->inst,kEndWtId);
3122
-  int         maxLoopCnt= cmDspInt(&p->inst,kLoopWtId);
3138
+  int         begSmpIdx = cmDspInt( &p->inst,kBegWtId);
3139
+  int         endSmpIdx = cmDspInt( &p->inst,kEndWtId);
3140
+  unsigned    chIdx     = cmDspUInt(&p->inst,kChWtId);
3141
+  int         maxLoopCnt= cmDspInt( &p->inst,kLoopWtId);
3123 3142
 
3124 3143
   if( endSmpIdx < begSmpIdx )
3125 3144
     endSmpIdx = p->fn-1;
@@ -3137,7 +3156,7 @@ cmDspRC_t _cmDspWaveTableReadAudioFile( cmDspCtx_t* ctx, cmDspWaveTable_t* p, un
3137 3156
   if( p->doneFl )
3138 3157
     cmVOS_Zero(p->wt + p->wti,n0);
3139 3158
   else
3140
-    if( _cmDspWaveTableReadBlock(ctx, p, p->wt+p->wti, n0,begSmpIdx,endSmpIdx,maxLoopCnt  ) != kOkDspRC )
3159
+    if( _cmDspWaveTableReadBlock(ctx, p, p->wt+p->wti, n0, chIdx, begSmpIdx,endSmpIdx,maxLoopCnt  ) != kOkDspRC )
3141 3160
       return cmDspInstErr(ctx,&p->inst,kVarNotValidDspRC,"An error occured while reading the wave table file.");
3142 3161
 
3143 3162
   p->wtn -= n0;   // decrease the count of available samples
@@ -3149,7 +3168,7 @@ cmDspRC_t _cmDspWaveTableReadAudioFile( cmDspCtx_t* ctx, cmDspWaveTable_t* p, un
3149 3168
     if( p->doneFl )
3150 3169
       cmVOS_Zero(p->wt,n1);
3151 3170
     else
3152
-      if( _cmDspWaveTableReadBlock(ctx, p, p->wt, n1,begSmpIdx,endSmpIdx,maxLoopCnt  ) != kOkDspRC )
3171
+      if( _cmDspWaveTableReadBlock(ctx, p, p->wt, n1, chIdx, begSmpIdx,endSmpIdx,maxLoopCnt  ) != kOkDspRC )
3153 3172
         return cmDspInstErr(ctx,&p->inst,kVarNotValidDspRC,"An error occured while reading the wave table file.");
3154 3173
 
3155 3174
     p->wtn -= n1;  // decrease the count of available samples
@@ -3382,6 +3401,7 @@ cmDspRC_t _cmDspWaveTableReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEv
3382 3401
 
3383 3402
   p->nxtBegSmpIdx = cmDspInt(&p->inst,kBegWtId);
3384 3403
   p->nxtEndSmpIdx = cmDspInt(&p->inst,kEndWtId);
3404
+  p->nxtChIdx     = cmDspUInt(&p->inst,kChWtId);
3385 3405
 
3386 3406
   return _cmDspWaveTableCreateTable(ctx,p);
3387 3407
 
@@ -3490,6 +3510,7 @@ cmDspRC_t _cmDspWaveTableRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
3490 3510
           cmDspSetEvent(ctx,inst,evt);                       // set the file name variable
3491 3511
           cmDspSetInt(ctx,inst,kBegWtId,p->nxtBegSmpIdx);    // set the beg/end smp idx var's from the stored nxtBeg/EndSmpIdx values
3492 3512
           cmDspSetInt(ctx,inst,kEndWtId,p->nxtEndSmpIdx);    // 
3513
+          cmDspSetUInt(ctx,inst,kChWtId, p->nxtChIdx);       // 
3493 3514
           cmDspSetUInt(ctx,inst,kShapeWtId,kFileWtId);       // switch to file mode 
3494 3515
           rc = _cmDspWaveTableCreateTable(ctx,p);            // reload the wavetable
3495 3516
         }
@@ -3506,6 +3527,11 @@ cmDspRC_t _cmDspWaveTableRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
3506 3527
       p->nxtEndSmpIdx = cmDsvGetInt(evt->valuePtr);
3507 3528
       break;
3508 3529
 
3530
+    case kChWtId:
3531
+      // store for next incoming file name msg
3532
+      p->nxtChIdx = cmDsvGetUInt(evt->valuePtr);
3533
+      break;
3534
+      
3509 3535
     case kShapeWtId:
3510 3536
       if( cmDsvGetUInt(evt->valuePtr) < kShapeWtCnt )
3511 3537
       {
@@ -5546,6 +5572,7 @@ cmDspClassConsFunc_t _cmDspClassBuiltInArray[] =
5546 5572
   cm1UpClassCons,
5547 5573
   cmGateToSymClassCons,
5548 5574
   cmPortToSymClassCons,
5575
+  cmIntToSymClassCons,
5549 5576
   cmRouterClassCons,
5550 5577
   cmAvailChClassCons,
5551 5578
 

+ 174
- 1
src/dsp/cmDspFx.c Bestand weergeven

@@ -5587,6 +5587,7 @@ cmDspInst_t*  _cmDspPortToSym_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, uns
5587 5587
     // register the symbol
5588 5588
     symIdArray[i] = cmSymTblRegisterSymbol(ctx->stH,symLabel);
5589 5589
 
5590
+    // input port - any msg in this port will generate an output from 'out' as well as the associated output port
5590 5591
     cmDspArgSetup(ctx, args+kBaseInPtsId+i, symLabel, cmInvalidId, kBaseInPtsId+i, 0, 0, kInDsvFl  | kTypeDsvMask, cmTsPrintfH(ctx->lhH,"%s Input.",symLabel) );
5591 5592
 
5592 5593
     cmDspArgSetup(ctx, args+baseOutPtsId+i, symLabel, cmInvalidId, baseOutPtsId+i, 0, 0, kOutDsvFl | kSymDsvFl,    cmTsPrintfH(ctx->lhH,"%s Output.",symLabel) );
@@ -5631,7 +5632,7 @@ cmDspRC_t _cmDspPortToSym_Recv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEv
5631 5632
     unsigned idx = evt->dstVarId - kBaseInPtsId;
5632 5633
     assert( idx < p->symIdCnt );
5633 5634
     cmDspSetSymbol(ctx,inst,p->baseOutPtsId + idx, p->symIdArray[idx]);
5634
-    return cmDspSetSymbol(ctx,inst,kOutPtsId,p->symIdArray[ evt->dstVarId - kBaseInPtsId ]);
5635
+    return cmDspSetSymbol(ctx,inst,kOutPtsId,      p->symIdArray[idx]);
5635 5636
   }
5636 5637
 
5637 5638
   return rc;
@@ -5654,6 +5655,178 @@ cmDspClass_t* cmPortToSymClassCons( cmDspCtx_t* ctx )
5654 5655
 
5655 5656
 //------------------------------------------------------------------------------------------------------------
5656 5657
 //)
5658
+//( { label:cmDspIntToSym file_desc:"Send a pre-defined symbol every time a message arrives a given input port." kw:[sunit] }
5659
+enum
5660
+{
5661
+ kInItsId,
5662
+ kOutItsId,
5663
+ kBaseInItsId
5664
+};
5665
+
5666
+cmDspClass_t _cmIntToSym_DC;
5667
+
5668
+typedef struct
5669
+{
5670
+  cmDspInst_t inst;
5671
+  int*        intArray;
5672
+  unsigned*   symIdArray;
5673
+  unsigned    symIdCnt;
5674
+  unsigned    baseIntItsId;
5675
+  unsigned    baseOutItsId;
5676
+  
5677
+} cmDspIntToSym_t;
5678
+
5679
+cmDspInst_t*  _cmDspIntToSym_Alloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
5680
+{
5681
+  va_list       vl1;
5682
+  va_copy(vl1,vl);
5683
+
5684
+  if( va_cnt < 2 || va_cnt % 2 !=0  )
5685
+  {
5686
+    va_end(vl1);
5687
+    cmDspClassErr(ctx,classPtr,kVarArgParseFailDspRC,"The 'IntToSym' constructor argument list must contain at least one int/symbol pair and all pairs must be complete.");
5688
+    return NULL;
5689
+  }
5690
+
5691
+  unsigned      symCnt    = va_cnt/2;
5692
+  unsigned      argCnt    = 2 + 3*symCnt;
5693
+  cmDspVarArg_t args[argCnt+1];
5694
+
5695
+  unsigned* symIdArray   = cmMemAllocZ(unsigned,symCnt);
5696
+  int*      intArray     = cmMemAllocZ(int,symCnt);
5697
+  unsigned  baseIntItsId = kBaseInItsId + symCnt;  
5698
+  unsigned  baseOutItsId = baseIntItsId + symCnt;
5699
+
5700
+  // setup the integer input and symbol output port arg recd
5701
+  cmDspArgSetup(ctx,args,  "in",  cmInvalidId, kInItsId,  0, 0, kInDsvFl  | kIntDsvFl, "Integer input" );
5702
+  cmDspArgSetup(ctx,args+1,"out", cmInvalidId, kOutItsId, 0, 0, kOutDsvFl | kSymDsvFl, "Output" );
5703
+
5704
+  unsigned i;
5705
+
5706
+  for(i=0; i<symCnt; ++i)
5707
+  {
5708
+    // get the integer value
5709
+    intArray[i] = va_arg(vl,int);
5710
+    
5711
+    // get the symbol label
5712
+    const cmChar_t* symLabel = va_arg(vl,const char*);
5713
+    assert( symLabel != NULL );
5714
+
5715
+    unsigned intLabelN = (symLabel==NULL ? 0 : strlen(symLabel)) + 5;
5716
+    cmChar_t intLabel[ intLabelN ];
5717
+    snprintf(intLabel,intLabelN,"%s%s", symLabel==NULL ? "" : symLabel, "-int" );
5718
+
5719
+    // register the symbol
5720
+    symIdArray[i] = cmSymTblRegisterSymbol(ctx->stH,symLabel);
5721
+
5722
+    // trigger port associated with this symbol (any msg on this port will trigger an output)
5723
+    cmDspArgSetup(ctx, args+kBaseInItsId+i, symLabel, cmInvalidId, kBaseInItsId+i, 0, 0, kInDsvFl  | kTypeDsvMask, cmTsPrintfH(ctx->lhH,"%s Input.",symLabel) );
5724
+
5725
+    // this port is used to set the integer value associated with this symbol
5726
+    cmDspArgSetup(ctx, args+baseIntItsId+i, intLabel, cmInvalidId, baseIntItsId+i, 0, 0, kInDsvFl  | kIntDsvFl,  cmTsPrintfH(ctx->lhH,"Set the integer value associated with %s.",symLabel) );
5727
+    
5728
+    // symbol output port - when ever this symbol is sent out it will go out this port as well as the 'out' port
5729
+    cmDspArgSetup(ctx, args+baseOutItsId+i, symLabel, cmInvalidId, baseOutItsId+i, 0, 0, kOutDsvFl | kSymDsvFl,    cmTsPrintfH(ctx->lhH,"%s Output.",symLabel) );
5730
+
5731
+    
5732
+  }
5733
+
5734
+  cmDspArgSetupNull(args + argCnt);
5735
+
5736
+  cmDspIntToSym_t* p = cmDspInstAlloc(cmDspIntToSym_t,ctx,classPtr,args,instSymId,id,storeSymId,0,vl1);
5737
+
5738
+  p->symIdCnt     = symCnt;
5739
+  p->intArray     = intArray;
5740
+  p->symIdArray   = symIdArray;
5741
+  p->baseOutItsId = baseOutItsId;
5742
+  p->baseIntItsId = baseIntItsId;
5743
+
5744
+  cmDspSetDefaultSymbol(ctx,&p->inst,kOutItsId,cmInvalidId);
5745
+
5746
+  va_end(vl1);
5747
+
5748
+  return &p->inst;
5749
+}
5750
+cmDspRC_t _cmDspIntToSym_Free(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
5751
+{
5752
+  cmDspIntToSym_t* p = (cmDspIntToSym_t*)inst;
5753
+  cmMemFree(p->symIdArray);
5754
+  return kOkDspRC;
5755
+}
5756
+
5757
+cmDspRC_t _cmDspIntToSym_Reset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
5758
+{
5759
+  return cmDspApplyAllDefaults(ctx,inst);
5760
+}
5761
+
5762
+cmDspRC_t _cmDspIntToSymSendOut( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned idx )
5763
+{
5764
+  cmDspIntToSym_t* p = (cmDspIntToSym_t*)inst;
5765
+  assert( idx < p->symIdCnt );
5766
+  cmDspSetSymbol(ctx,inst,p->baseOutItsId + idx, p->symIdArray[idx]);
5767
+  return cmDspSetSymbol(ctx, inst, kOutItsId, p->symIdArray[ idx ]);
5768
+}
5769
+
5770
+
5771
+cmDspRC_t _cmDspIntToSym_Recv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
5772
+{ 
5773
+  cmDspRC_t    rc = kOkDspRC;
5774
+  cmDspIntToSym_t* p = (cmDspIntToSym_t*)inst;
5775
+
5776
+  // if an integer arrived at 'in'
5777
+  if( evt->dstVarId == kInItsId )
5778
+  {
5779
+    cmDspSetEvent(ctx,inst,evt);
5780
+
5781
+    unsigned i;
5782
+    int      intVal = cmDspInt(inst,kInItsId);
5783
+    
5784
+    for(i=0; i<p->symIdCnt; ++i)
5785
+      if( intVal == p->intArray[i] )
5786
+      {
5787
+        rc = _cmDspIntToSymSendOut( ctx, inst, i );
5788
+        break;
5789
+      } 
5790
+  }
5791
+  else
5792
+  {  
5793
+    // if a msg of any type is recieved on an input port - send out the associated symbol
5794
+    if( kBaseInItsId <= evt->dstVarId && evt->dstVarId < kBaseInItsId + p->symIdCnt )
5795
+    {
5796
+      _cmDspIntToSymSendOut( ctx, inst, evt->dstVarId - kBaseInItsId );
5797
+    }
5798
+    else
5799
+      
5800
+      // if this is a new interger value for this symbol
5801
+      if( p->baseIntItsId <= evt->dstVarId && evt->dstVarId < p->baseIntItsId + p->symIdCnt )
5802
+      {
5803
+        cmDspSetEvent(ctx,inst,evt);
5804
+
5805
+        p->intArray[ evt->dstVarId - p->baseIntItsId ] = cmDspInt( inst, evt->dstVarId );
5806
+      }
5807
+  }
5808
+
5809
+  
5810
+  return rc;
5811
+}
5812
+
5813
+cmDspClass_t* cmIntToSymClassCons( cmDspCtx_t* ctx )
5814
+{
5815
+  cmDspClassSetup(&_cmIntToSym_DC,ctx,"IntToSym",
5816
+    NULL,
5817
+    _cmDspIntToSym_Alloc,
5818
+    _cmDspIntToSym_Free,
5819
+    _cmDspIntToSym_Reset,
5820
+    NULL,
5821
+    _cmDspIntToSym_Recv,
5822
+    NULL,NULL,
5823
+    "If a message of any kind is received on a port then send the symbol associated with the port.");
5824
+
5825
+  return &_cmIntToSym_DC;
5826
+}
5827
+
5828
+//------------------------------------------------------------------------------------------------------------
5829
+//)
5657 5830
 //( { label:cmDspRouter file_desc:"Route the input value to one of multiple output ports." kw:[sunit] }
5658 5831
  
5659 5832
 enum

+ 1
- 0
src/dsp/cmDspFx.h Bestand weergeven

@@ -36,6 +36,7 @@ extern "C" {
36 36
   struct cmDspClass_str* cm1UpClassCons(        cmDspCtx_t* ctx );
37 37
   struct cmDspClass_str* cmGateToSymClassCons(  cmDspCtx_t* ctx );
38 38
   struct cmDspClass_str* cmPortToSymClassCons(  cmDspCtx_t* ctx );
39
+  struct cmDspClass_str* cmIntToSymClassCons(   cmDspCtx_t* ctx );  
39 40
   struct cmDspClass_str* cmRouterClassCons(     cmDspCtx_t* ctx );
40 41
   struct cmDspClass_str* cmAvailChClassCons(    cmDspCtx_t* ctx );
41 42
   struct cmDspClass_str* cmPresetClassCons(     cmDspCtx_t* ctx );

+ 58
- 15
src/dsp/cmDspPgm.c Bestand weergeven

@@ -21,6 +21,7 @@
21 21
 #include "cmTime.h"
22 22
 #include "cmAudioSys.h"
23 23
 #include "cmProcObj.h"
24
+#include "cmPP_NARG.h"
24 25
 #include "cmDspCtx.h"
25 26
 #include "cmDspClass.h"
26 27
 #include "cmDspSys.h"
@@ -2870,36 +2871,77 @@ cmDspRC_t _cmDspSysPgm_PortToSym( cmDspSysH_t h, void** userPtrPtr )
2870 2871
 {
2871 2872
   cmDspRC_t rc = kOkDspRC;
2872 2873
 
2873
-  cmDspInst_t* btn0  = cmDspSysAllocButton( h, "Btn0", 0.0 );
2874
-  cmDspInst_t* btn1  = cmDspSysAllocButton( h, "Btn1", 0.0 );
2875
-  cmDspInst_t* btn2  = cmDspSysAllocButton( h, "Btn2", 0.0 );  
2874
+  inst_t* btn0  = button( "Btn0", 0.0 );
2875
+  inst_t* btn1  = button( "Btn1", 0.0 );
2876
+  inst_t* btn2  = button( "Btn2", 0.0 );  
2876 2877
 
2877
-  cmDspInst_t* pts   = cmDspSysAllocInst( h, "PortToSym", NULL, 3, "one", "two", "three");
2878
+  inst_t* pts   = inst( "PortToSym", NULL, "one", "two", "three");
2878 2879
 
2879
-  cmDspInst_t* pr0  = cmDspSysAllocInst( h, "Printer", NULL, 1, "0:" );
2880
-  cmDspInst_t* pr1  = cmDspSysAllocInst( h, "Printer", NULL, 1, "1:" );
2880
+  inst_t* pr0  = inst( "Printer", NULL,  "sym:" );
2881
+  inst_t* pr1  = inst( "Printer", NULL,  "btn:" );
2882
+  inst_t* pr2  = inst( "Printer", NULL,  "out:" );
2881 2883
 
2882 2884
   // check for allocation errors
2883 2885
   if((rc = cmDspSysLastRC(h)) != kOkDspRC )
2884 2886
     goto errLabel;
2885 2887
   
2886
-  cmDspSysInstallCb(   h, btn0, "out", pts, "one",NULL);
2887
-  cmDspSysInstallCb(   h, btn1, "out", pts, "two",NULL);
2888
-  cmDspSysInstallCb(   h, btn2, "out", pts, "three",NULL);
2888
+  event( btn0, out, pts, one );
2889
+  event( btn1, out, pts, two );
2890
+  event( btn2, out, pts, three );
2891
+
2892
+  event( btn0, out, pr1, in );
2893
+  event( btn1, out, pr1, in );
2894
+  event( btn2, out, pr1, in );
2895
+
2896
+  event( pts,  one,   pr0, in );
2897
+  event( pts,  two,   pr0, in );
2898
+  event( pts,  three, pr0, in );
2899
+  event( pts,  out,   pr2, in );
2900
+
2901
+ errLabel:
2902
+  return rc;
2903
+}
2904
+
2905
+//------------------------------------------------------------------------------
2906
+//)
2907
+//( { label:cmDspPgm_IntToSym file_desc:"IntToSym example program." kw:[spgm] }
2908
+cmDspRC_t _cmDspSysPgm_IntToSym( cmDspSysH_t h, void** userPtrPtr )
2909
+{
2910
+  cmDspRC_t rc = kOkDspRC;
2911
+
2912
+  inst_t* sel0   = scalar( "Sel0", 0.0, 10.0, 1.0, 1.0 );
2913
+  inst_t* sel1   = scalar( "Sel1", 0.0, 10.0, 1.0, 1.0 );
2914
+  inst_t* sel2   = scalar( "Sel2", 0.0, 10.0, 1.0, 1.0 );
2915
+  inst_t* val    = scalar( "Val",  0.0, 10.0, 1.0, 1.0 );
2889 2916
 
2890
-  cmDspSysInstallCb(   h, btn0, "out", pr1, "in",NULL);
2891
-  cmDspSysInstallCb(   h, btn1, "out", pr1, "in",NULL);
2892
-  cmDspSysInstallCb(   h, btn2, "out", pr1, "in",NULL);
2917
+  inst_t* pts   = inst( "IntToSym", NULL, 0, "one", 0, "two", 0, "three");
2893 2918
 
2894
-  cmDspSysInstallCb(   h, pts,  "one",   pr0, "in", NULL );
2895
-  cmDspSysInstallCb(   h, pts,  "two",   pr0, "in", NULL );
2896
-  cmDspSysInstallCb(   h, pts,  "three", pr0, "in", NULL );
2919
+  inst_t* pr0  = inst( "Printer", NULL,  "val:" );
2920
+  inst_t* pr1  = inst( "Printer", NULL,  "sym:" );
2921
+  inst_t* pr2  = inst( "Printer", NULL,  "out:" );
2897 2922
 
2923
+  // check for allocation errors
2924
+  if((rc = cmDspSysLastRC(h)) != kOkDspRC )
2925
+    goto errLabel;
2898 2926
 
2927
+  event( sel0, val, pts, one-int );
2928
+  event( sel1, val, pts, two-int );
2929
+  event( sel2, val, pts, three-int );
2930
+  
2931
+  event( val, val, pts, in );
2932
+  event( val, val, pr0, in );
2933
+
2934
+  event( pts,  one,   pr1, in );
2935
+  event( pts,  two,   pr1, in );
2936
+  event( pts,  three, pr1, in );
2937
+  
2938
+  event( pts, out, pr2, in );
2939
+  
2899 2940
  errLabel:
2900 2941
   return rc;
2901 2942
 }
2902 2943
 
2944
+
2903 2945
 //------------------------------------------------------------------------------
2904 2946
 //)
2905 2947
 //( { label:cmDspPgm_Line file_desc:"Line generator example program." kw:[spgm] }
@@ -3288,6 +3330,7 @@ _cmDspSysPgm_t _cmDspSysPgmArray[] =
3288 3330
   { "line",              _cmDspSysPgm_Line,           NULL, NULL },
3289 3331
   { "1Up",               _cmDspSysPgm_1Up,            NULL, NULL },
3290 3332
   { "PortToSym",         _cmDspSysPgm_PortToSym,      NULL, NULL },
3333
+  { "IntToSym",          _cmDspSysPgm_IntToSym,       NULL, NULL },
3291 3334
   { "preset",            _cmDspSysPgm_Preset,         NULL, NULL },
3292 3335
   { "rsrcWr",            _cmDspSysPgm_RsrcWr,         NULL, NULL },
3293 3336
   { "router",            _cmDspSysPgm_Router,         NULL, NULL },

+ 75
- 66
src/dsp/cmDspPgmKrTimeLineLiteAf.c Bestand weergeven

@@ -62,27 +62,22 @@ cmDspRC_t _cmDspSysPgm_TimeLineLiteAf(cmDspSysH_t h, void** userPtrPtr )
62 62
   //int baseAudioInCh =  0; // 2;
63 63
   int baseAudioOutCh = 0;//  2;
64 64
 
65
-  //cmDspInst_t* ai0 = cmDspSysAllocInst(h,"AudioIn",     NULL,  1, baseAudioInCh + 0);
66
-  //cmDspInst_t* ai1 = cmDspSysAllocInst(h,"AudioIn",     NULL,  1, baseAudioInCh + 1);
67
-  //cmDspInst_t* mip = cmDspSysAllocInst(h,"MidiIn",      NULL,  2, "MOTU - Traveler mk3", "MIDI Port");
68
-  //cmDspInst_t* mip = cmDspSysAllocInst(h,"MidiIn",      NULL,  2, "Apple Inc. - IAC Driver", "Bus 1");
69 65
   
70 66
   cmDspInst_t* tlp  = cmDspSysAllocInst(h,"TimeLine",    "tl",  2, r.tlFn, r.tlPrefixPath );
71 67
   cmDspInst_t* scp  = cmDspSysAllocInst(h,"Score",       "sc",  1, r.scFn );
72 68
   cmDspInst_t* pts  = cmDspSysAllocInst(h,"PortToSym",   NULL,  2, "on", "off" );
73 69
 
74
-  cmDspInst_t* php =  cmDspSysAllocInst(h,"Phasor",   NULL,  0 );
75
-  cmDspInst_t* wtp =  cmDspSysAllocInst(h,"WaveTable",NULL,  2, ((int)cmDspSysSampleRate(h)), 1 );
70
+  cmDspInst_t* php =  cmDspSysAllocInst(h,"Phasor",    NULL,  0 );
71
+  cmDspInst_t* wt0 =  cmDspSysAllocInst(h,"WaveTable", NULL,  7, ((int)cmDspSysSampleRate(h)), 1, NULL, -1, 0, -1, 0 );
72
+  cmDspInst_t* wt1 =  cmDspSysAllocInst(h,"WaveTable", NULL,  7, ((int)cmDspSysSampleRate(h)), 1, NULL, -1, 0, -1, 1 );
76 73
 
77 74
   
78 75
   cmDspInst_t* mfp  = cmDspSysAllocInst(h,"MidiFilePlay",NULL,  0 );
79 76
   cmDspInst_t* nmp  = cmDspSysAllocInst(h,"NanoMap",     NULL,  0 );
80
-  //cmDspInst_t* pic  = cmDspSysAllocInst(h,"Picadae",     NULL,  0 );
81
-  cmDspInst_t* mop  = cmDspSysAllocInst(h,"MidiOut",     NULL,  2, "Fastlane","Fastlane MIDI A" );
82
-  cmDspInst_t* mo2p = cmDspSysAllocInst(h,"MidiOut",     NULL,  2, "Fastlane","Fastlane MIDI B");
83 77
   cmDspInst_t* sfp  = cmDspSysAllocInst(h,"ScFol",       NULL,  5, r.scFn, sfBufCnt, sfMaxWndCnt, sfMinVel, sfEnaMeasFl );
84 78
   cmDspInst_t* amp  = cmDspSysAllocInst(h,"ActiveMeas",  NULL,  1, 100 );
85 79
   cmDspInst_t* modp = cmDspSysAllocInst(h,"ScMod",       NULL,  2, r.modFn, "m1" );
80
+  cmDspInst_t* its  = cmDspSysAllocInst(h,"IntToSym",    NULL,  2, 0, "off");
86 81
  
87 82
   unsigned   preGrpSymId     = cmDspSysPresetRegisterGroup(h,"tl");
88 83
   unsigned   cmpPreGrpSymId  = cmDspSysPresetRegisterGroup(h,"tl_cmp"); 
@@ -95,14 +90,14 @@ cmDspRC_t _cmDspSysPgm_TimeLineLiteAf(cmDspSysH_t h, void** userPtrPtr )
95 90
   cmDspSysNewPage(h,"Controls-1");
96 91
   _cmDspSys_TlXformChain(h, &c1, preGrpSymId, cmpPreGrpSymId, amp, modp, 1, 1 );
97 92
 
93
+  cmDspInst_t* lmix = cmDspSysAllocInst(h, "AMix",      NULL, 1, 2 );
94
+  cmDspInst_t* rmix = cmDspSysAllocInst(h, "AMix",      NULL, 1, 2 );
98 95
 
99
-  cmDspInst_t* ao0 = cmDspSysAllocInst(h,"AudioOut",    NULL,   1, baseAudioOutCh+2 ); // 4 Piano     1 Output
100
-  cmDspInst_t* ao1 = cmDspSysAllocInst(h,"AudioOut",    NULL,   1, baseAudioOutCh+3 ); // 5          2
101
-  cmDspInst_t* ao2 = cmDspSysAllocInst(h,"AudioOut",    NULL,   1, baseAudioOutCh+0 ); // 2 Transform 1 OUtput
102
-  cmDspInst_t* ao3 = cmDspSysAllocInst(h,"AudioOut",    NULL,   1, baseAudioOutCh+1 ); // 3          2
96
+  cmDspInst_t* ao0 = cmDspSysAllocInst(h,"AudioOut",    NULL,   1, baseAudioOutCh+0 ); 
97
+  cmDspInst_t* ao1 = cmDspSysAllocInst(h,"AudioOut",    NULL,   1, baseAudioOutCh+1 ); 
103 98
 
104 99
   cmDspSysNewPage(h,"Main");
105
-  cmDspInst_t* notesOffb= cmDspSysAllocInst(h,"Button", "notesOff",   2, kButtonDuiId, 1.0 );
100
+  //cmDspInst_t* notesOffb= cmDspSysAllocInst(h,"Button", "notesOff",   2, kButtonDuiId, 1.0 );
106 101
   cmDspInst_t* onb     = cmDspSysAllocInst(h,"Button", "start",   2, kButtonDuiId, 1.0 );
107 102
   cmDspInst_t* offb    = cmDspSysAllocInst(h,"Button", "stop",    2, kButtonDuiId, 1.0 );
108 103
   cmDspInst_t* mod_sel = cmDspSysAllocMsgList(h, NULL, "mod_sel", 1 );
@@ -115,11 +110,7 @@ cmDspRC_t _cmDspSysPgm_TimeLineLiteAf(cmDspSysH_t h, void** userPtrPtr )
115 110
   // Record <-> Live switches
116 111
   cmDspInst_t* tlRt  = cmDspSysAllocInst(h,"Router", NULL, 2, 2, 0);  // time line swich
117 112
   cmDspInst_t* mfpRt = cmDspSysAllocInst(h,"Router", NULL, 2, 2, 0);
118
-  //cmDspInst_t* amRt  = cmDspSysAllocInst(h,"Router", NULL, 2, 2, 0);
119 113
 
120
-  //cmDspSysNewColumn(h,0);
121
-  //cmDspInst_t* igain0 = cmDspSysAllocInst(h,"Scalar", "In Gain-0",    5, kNumberDuiId, 0.0,   100.0,0.01,   1.0 );  
122
-  //cmDspInst_t* igain1 = cmDspSysAllocInst(h,"Scalar", "In Gain-1",    5, kNumberDuiId, 0.0,   100.0,0.01,   1.0 );  
123 114
 
124 115
   //cmDspSysNewColumn(h,0);
125 116
   cmDspInst_t* ogain0 = cmDspSysAllocInst(h,"Scalar", "Dry Out Gain-0",   5, kNumberDuiId, 0.0,   10.0,0.01,   1.0 );  
@@ -127,6 +118,16 @@ cmDspRC_t _cmDspSysPgm_TimeLineLiteAf(cmDspSysH_t h, void** userPtrPtr )
127 118
   cmDspInst_t* ogain2 = cmDspSysAllocInst(h,"Scalar", "Wet Out Gain-2",   5, kNumberDuiId, 0.0,   10.0,0.01,   1.0 );  
128 119
   cmDspInst_t* ogain3 = cmDspSysAllocInst(h,"Scalar", "Wet Out Gain-3",   5, kNumberDuiId, 0.0,   10.0,0.01,   1.0 );  
129 120
 
121
+  cmDspInst_t* ogainW = cmDspSysAllocInst(h,"Scalar", "Wet Master",   5, kNumberDuiId, 0.0,   10.0,0.01,   1.0 );  
122
+  cmDspInst_t* ogainD = cmDspSysAllocInst(h,"Scalar", "Dry Master",   5, kNumberDuiId, 0.0,   10.0,0.01,   1.0 );  
123
+
124
+  cmDspInst_t* gmult0  = cmDspSysAllocInst(h,"ScalarOp", NULL, 6, 2, "*", "in-0", 1.0, "in-1", 1.0 );
125
+  cmDspInst_t* gmult1  = cmDspSysAllocInst(h,"ScalarOp", NULL, 6, 2, "*", "in-0", 1.0, "in-1", 1.0 );
126
+  cmDspInst_t* gmult2  = cmDspSysAllocInst(h,"ScalarOp", NULL, 6, 2, "*", "in-0", 1.0, "in-1", 1.0 );
127
+  cmDspInst_t* gmult3  = cmDspSysAllocInst(h,"ScalarOp", NULL, 6, 2, "*", "in-0", 1.0, "in-1", 1.0 );
128
+  
129
+ 
130
+  
130 131
   // Audio file recording
131 132
   cmDspInst_t* recdGain= cmDspSysAllocInst(h,"Scalar", "Recd Gain",  5, kNumberDuiId, 0.0,   100.0,0.01, 1.5 );  
132 133
   cmDspInst_t* recdChk = cmDspSysAllocInst(h,"Button", "Record",     2, kCheckDuiId, 0.0 );
@@ -135,10 +136,11 @@ cmDspRC_t _cmDspSysPgm_TimeLineLiteAf(cmDspSysH_t h, void** userPtrPtr )
135 136
   cmDspInst_t* mi0p    = cmDspSysAllocInst(h,"AMeter","In 0",  0);
136 137
   cmDspInst_t* mi1p    = cmDspSysAllocInst(h,"AMeter","In 1",  0);
137 138
 
138
-  cmDspInst_t* meas    = cmDspSysAllocInst(h,"Scalar", "Meas",    5, kNumberDuiId, 1.0,   59.0,1.0,   1.0 );  
139
+  cmDspInst_t* meas     = cmDspSysAllocInst(h,"Scalar", "Begin Meas", 5, kNumberDuiId, 1.0, 1000.0, 1.0, 1.0 );  
140
+  cmDspInst_t* emeas    = cmDspSysAllocInst(h,"Scalar", "End   Meas", 5, kNumberDuiId, 1.0, 1000.0, 1.0, 1.0 );  
139 141
   cmDspSysInstallCb( h, meas, "val", scp, "meas", NULL);
140 142
   cmDspSysInstallCb( h, meas, "val", tlp, "meas", NULL);
141
-
143
+  
142 144
 
143 145
 
144 146
 
@@ -173,37 +175,34 @@ cmDspRC_t _cmDspSysPgm_TimeLineLiteAf(cmDspSysH_t h, void** userPtrPtr )
173 175
   cmDspSysInstallCb(h, recdPtS, "out", afop,    "sel",   NULL );
174 176
 
175 177
   // Audio connections
176
-
177
-  cmDspSysConnectAudio(h, php, "out", wtp, "phs" );   // phasor -> wave table
178
-  cmDspSysConnectAudio(h, wtp, "out", ao0, "in" );    // wave table -> audio out (dry output)
179
-  cmDspSysConnectAudio(h, wtp, "out", ao1, "in" );    // 
178
+  cmDspSysConnectAudio(h, php, "out", wt0, "phs" );      // phasor -> wave table
179
+  cmDspSysConnectAudio(h, php, "out", wt1, "phs" );      // 
180 180
   
181
-  //cmDspSysConnectAudio( h, ai0,   "out", ao0,   "in" );  //  dry signal through 
182
-  //cmDspSysConnectAudio( h, ai1,   "out", ao1,   "in" );  //
183
-  
184
-  //cmDspSysConnectAudio( h, ai0,   "out", mi0p,   "in" );  //
185
-  //cmDspSysConnectAudio( h, ai0,   "out", c0.kr0, "in" );  // ain -> ch0.kr0
186
-  //cmDspSysConnectAudio( h, ai0,   "out", c0.kr1, "in" );  // ain -> ch0.kr1
181
+  cmDspSysConnectAudio(h, wt0, "out", lmix, "in-0" );    // wave table -> audio out (dry output)
182
+  cmDspSysConnectAudio(h, wt1, "out", rmix, "in-0" );    // 
183
+
184
+  //cmDspSysConnectAudio(h, wt0, "out", lmix, "in-1" );    // wave table -> audio out (dry output)
185
+  //cmDspSysConnectAudio(h, wt1, "out", rmix, "in-1" );    // 
187 186
 
188
-  cmDspSysConnectAudio( h, wtp,   "out", mi0p,   "in" );  //
189
-  cmDspSysConnectAudio( h, wtp,   "out", c0.kr0, "in" );  // ain -> ch0.kr0
190
-  cmDspSysConnectAudio( h, wtp,   "out", c0.kr1, "in" );  // ain -> ch0.kr1
187
+
188
+  cmDspSysConnectAudio( h, wt0,   "out", mi0p,   "in" );  //
189
+  cmDspSysConnectAudio( h, wt0,   "out", c0.kr0, "in" );  // ain -> ch0.kr0
190
+  cmDspSysConnectAudio( h, wt0,   "out", c0.kr1, "in" );  // ain -> ch0.kr1
191 191
 
192 192
   
193
-  cmDspSysConnectAudio( h, c0.cmp,"out", ao2,    "in" );  // ch0.cmp -> aout
193
+  cmDspSysConnectAudio( h, c0.cmp,"out", lmix,    "in-1" );  // ch0.cmp -> aout
194 194
   cmDspSysConnectAudio( h, c0.cmp,"out", afop,   "in0");  // ch0.cmp -> audio_file_out
195 195
 
196
-  //cmDspSysConnectAudio( h, ai1,   "out", mi1p,   "in" );  //
197
-  //cmDspSysConnectAudio( h, ai1,   "out", c1.kr0, "in" );  // ain -> ch1.kr0
198
-  //cmDspSysConnectAudio( h, ai1,   "out", c1.kr1, "in" );  // ain -> ch1.kr1
199 196
 
200
-  cmDspSysConnectAudio( h, wtp,   "out", mi1p,   "in" );  //
201
-  cmDspSysConnectAudio( h, wtp,   "out", c1.kr0, "in" );  // ain -> ch1.kr0
202
-  cmDspSysConnectAudio( h, wtp,   "out", c1.kr1, "in" );  // ain -> ch1.kr1
197
+  cmDspSysConnectAudio( h, wt1,   "out", mi1p,   "in" );  //
198
+  cmDspSysConnectAudio( h, wt1,   "out", c1.kr0, "in" );  // ain -> ch1.kr0
199
+  cmDspSysConnectAudio( h, wt1,   "out", c1.kr1, "in" );  // ain -> ch1.kr1
203 200
 
204
-  cmDspSysConnectAudio( h, c1.cmp,"out", ao3,    "in" );  // ch1.cmp -> aout
201
+  cmDspSysConnectAudio( h, c1.cmp,"out", rmix,    "in-1" );  // ch1.cmp -> aout
205 202
   cmDspSysConnectAudio( h, c1.cmp,"out", afop,   "in1");  // ch1.cmp ->audio_file_out
206 203
   
204
+  cmDspSysConnectAudio( h, lmix, "out", ao0, "in" );
205
+  cmDspSysConnectAudio( h, rmix, "out", ao1, "in" );
207 206
 
208 207
 
209 208
   cmDspSysInstallCb( h, clrBtn, "sym",    amp, "cmd",   NULL ); // clear active meas.
@@ -252,8 +251,9 @@ cmDspRC_t _cmDspSysPgm_TimeLineLiteAf(cmDspSysH_t h, void** userPtrPtr )
252 251
   cmDspSysInstallCb( h, sfp, "vcost",prt,   "in",  NULL ); //
253 252
   cmDspSysInstallCb( h, sfp, "vtyp", prc,   "in", NULL ); //
254 253
   */
254
+  
255 255
   // wave-table to time-line cursor
256
-  //cmDspSysInstallCb(   h, wtp, "fidx",tlp,  "curs", NULL); 
256
+  cmDspSysInstallCb(   h, wt0, "fidx",tlp,  "curs", NULL); 
257 257
 
258 258
   cmDspSysInstallCb(h, prePath, "out", tlp, "path", NULL );
259 259
 
@@ -267,7 +267,8 @@ cmDspRC_t _cmDspSysPgm_TimeLineLiteAf(cmDspSysH_t h, void** userPtrPtr )
267 267
   cmDspSysInstallCb(h, mfpRt,"s-out-0",mfp,  "sel",   NULL );
268 268
 
269 269
   cmDspSysInstallCb(h, onb, "sym",     pts,     "on",     NULL );
270
-  cmDspSysInstallCb(h, pts, "on",      wtp,     "cmd",    NULL );
270
+  cmDspSysInstallCb(h, pts, "on",      wt0,     "cmd",    NULL );
271
+  cmDspSysInstallCb(h, pts, "on",      wt1,     "cmd",    NULL );
271 272
   cmDspSysInstallCb(h, pts, "on",      modp,    "cmd",    NULL );
272 273
   cmDspSysInstallCb(h, onb, "sym",     amCmd,   "rewind", NULL );
273 274
   cmDspSysInstallCb(h, onb, "out",     c0.achan,"reset",  NULL );
@@ -278,11 +279,10 @@ cmDspRC_t _cmDspSysPgm_TimeLineLiteAf(cmDspSysH_t h, void** userPtrPtr )
278 279
   // stop connections
279 280
   cmDspSysInstallCb(h, tlp,  "mfn", pts, "off",   NULL ); // Prevents WT start on new audio file from TL.
280 281
   cmDspSysInstallCb(h, offb, "sym", mfp, "sel",   NULL ); 
281
-  cmDspSysInstallCb(h, offb, "sym", pts, "off",   NULL );
282
-  cmDspSysInstallCb(h, pts,  "off", wtp, "cmd",   NULL );
282
+  cmDspSysInstallCb(h, offb, "sym", pts, "off",   NULL );  
283
+  cmDspSysInstallCb(h, pts,  "off", wt0, "cmd",   NULL );
284
+  cmDspSysInstallCb(h, pts,  "off", wt1, "cmd",   NULL );
283 285
   cmDspSysInstallCb(h, pts,  "off", modp,"cmd",   NULL );
284
-  cmDspSysInstallCb(h, offb, "sym", mop, "reset", NULL );
285
-  cmDspSysInstallCb(h, offb, "sym", mo2p,"reset", NULL );
286 286
 
287 287
 
288 288
   // time-line to MIDI file player selection
@@ -292,9 +292,13 @@ cmDspRC_t _cmDspSysPgm_TimeLineLiteAf(cmDspSysH_t h, void** userPtrPtr )
292 292
 
293 293
 
294 294
   // time-line to Audio file player selection
295
-  cmDspSysInstallCb(h, tlp, "absi", wtp, "beg",   NULL );
296
-  cmDspSysInstallCb(h, tlp, "aesi", wtp, "end",   NULL );
297
-  cmDspSysInstallCb(h, tlp, "afn",  wtp, "fn",    NULL );
295
+  cmDspSysInstallCb(h, tlp, "absi", wt0, "beg",   NULL );
296
+  cmDspSysInstallCb(h, tlp, "aesi", wt0, "end",   NULL );
297
+  cmDspSysInstallCb(h, tlp, "afn",  wt0, "fn",    NULL );
298
+
299
+  cmDspSysInstallCb(h, tlp, "absi", wt1, "beg",   NULL );
300
+  cmDspSysInstallCb(h, tlp, "aesi", wt1, "end",   NULL );
301
+  cmDspSysInstallCb(h, tlp, "afn",  wt1, "fn",    NULL );
298 302
   
299 303
   // score to score follower - to set initial search location
300 304
   cmDspSysInstallCb(h, scp, "sel",    sfp, "index", NULL );
@@ -309,40 +313,45 @@ cmDspRC_t _cmDspSysPgm_TimeLineLiteAf(cmDspSysH_t h, void** userPtrPtr )
309 313
 
310 314
   cmDspSysInstallCb(h, msrc,   "d1",     sfp,  "d1",    NULL );
311 315
   cmDspSysInstallCb(h, msrc,   "d1",     nmp,  "d1",    NULL );
312
-  cmDspSysInstallCb(h, nmp,   "d1",     mop,  "d1",    NULL );
313
-  //cmDspSysInstallCb(h, nmp,   "d1",     pic, "d1",    NULL );
314
-  //cmDspSysInstallCb(h, pic,   "d1",     mo2p, "d1",    NULL );
315 316
 
316 317
   cmDspSysInstallCb(h, msrc,  "d0",      sfp,  "d0",   NULL );
317 318
   cmDspSysInstallCb(h, msrc,  "d0",      nmp,  "d0",   NULL );
318
-  cmDspSysInstallCb(h, nmp,  "d0",      mop,  "d0",   NULL );
319
-  //cmDspSysInstallCb(h, nmp,  "d0",      pic, "d0",   NULL );
320
-  //cmDspSysInstallCb(h, pic,   "d0",     mo2p, "d0",    NULL );
321 319
 
322 320
   cmDspSysInstallCb(h, msrc,  "status",  sfp,  "status",NULL );
323 321
   cmDspSysInstallCb(h, msrc,  "status",  nmp,  "status",NULL );
324
-  cmDspSysInstallCb(h, nmp,  "status",  mop,  "status",NULL );
325
-  //cmDspSysInstallCb(h, nmp,  "status",  pic, "status",NULL );
326
-  //cmDspSysInstallCb(h, pic,   "status",  mo2p, "status",    NULL );
327 322
 
328 323
 
329 324
   // score follower to recd_play,modulator and printers
330 325
   cmDspSysInstallCb(h, sfp, "out",     modp,    "index", NULL );
331 326
   cmDspSysInstallCb(h, sfp, "recent",  prp,     "in",  NULL );  // report 'recent' but only act on 'max' loc index
332 327
 
333
-  //cmDspSysInstallCb(h, igain0, "val", ai0, "gain", NULL );   // input gain control
334
-  //cmDspSysInstallCb(h, igain1, "val", ai1, "gain", NULL );
335
-
328
+  cmDspSysInstallCb( h, emeas, "val", its,  "off-int", NULL);
329
+  cmDspSysInstallCb( h, sfp,   "out", its,  "in",  NULL);
330
+  cmDspSysInstallCb( h, its,   "out", offb, "in",  NULL);
331
+  cmDspSysInstallCb( h, its,   "out", prp, "in",  NULL);
332
+  
336 333
 
337 334
   cmDspSysInstallCb(h, modp, "dgain0",  ogain0, "val",  NULL );
338 335
   cmDspSysInstallCb(h, modp, "dgain1",  ogain1, "val",  NULL );
339 336
   cmDspSysInstallCb(h, modp, "wgain0",  ogain2, "val",  NULL );
340 337
   cmDspSysInstallCb(h, modp, "wgain1",  ogain3, "val",  NULL );
341 338
 
342
-  cmDspSysInstallCb(h, ogain0, "val", ao0, "gain", NULL );   // output gain control - dry 0
343
-  cmDspSysInstallCb(h, ogain1, "val", ao1, "gain", NULL );   //                       dry 1
344
-  cmDspSysInstallCb(h, ogain2, "val", ao2, "gain", NULL );   //                       wet 0
345
-  cmDspSysInstallCb(h, ogain3, "val", ao3, "gain", NULL );   //                       wet 1
339
+
340
+  cmDspSysInstallCb(h, ogain0,  "val", gmult0, "in-0", NULL );
341
+  cmDspSysInstallCb(h, ogainD,  "val", gmult0, "in-1", NULL );
342
+  
343
+  cmDspSysInstallCb(h, ogain1,  "val", gmult1, "in-0", NULL );
344
+  cmDspSysInstallCb(h, ogainD,  "val", gmult1, "in-1", NULL );
345
+  
346
+  cmDspSysInstallCb(h, ogain2,  "val", gmult2, "in-0", NULL );
347
+  cmDspSysInstallCb(h, ogainW,  "val", gmult2, "in-1", NULL );
348
+  cmDspSysInstallCb(h, ogain3,  "val", gmult3, "in-0", NULL );
349
+  cmDspSysInstallCb(h, ogainW,  "val", gmult3, "in-1", NULL );
350
+  
351
+  cmDspSysInstallCb(h, gmult0, "out", lmix, "gain-0", NULL );   // output gain control - dry 0
352
+  cmDspSysInstallCb(h, gmult1, "out", rmix, "gain-0", NULL );   //                       dry 1
353
+  cmDspSysInstallCb(h, gmult2, "out", lmix, "gain-1", NULL );   //                       wet 0
354
+  cmDspSysInstallCb(h, gmult3, "out", rmix, "gain-1", NULL );   //                       wet 1
346 355
 
347 356
 
348 357
   return rc;

+ 13
- 2
src/dsp/cmDspSys.h Bestand weergeven

@@ -109,8 +109,7 @@ extern "C" {
109 109
   cmDspRC_t    cmDspSysInsertHorzBorder( cmDspSysH_t h );
110 110
 
111 111
   cmDspRC_t    cmDspSysNewPage( cmDspSysH_t h, const cmChar_t* title );
112
-
113
-
112
+  
114 113
   //----------------------------------------------------------------------------------------------------
115 114
   // Connection Functions.
116 115
   //
@@ -278,6 +277,18 @@ extern "C" {
278 277
 
279 278
   //)
280 279
 
280
+  typedef cmDspInst_t inst_t;
281
+  
282
+#define inst( classLabel, instLabel, ... )       cmDspSysAllocInst( h, classLabel, instLabel, PP_NARG(__VA_ARGS__), __VA_ARGS__ )
283
+#define button( label, real_val )                cmDspSysAllocButton(  h, label, real_val )
284
+#define scalar( label, rmin, rmax, rstep, rval ) cmDspSysAllocScalar(  h, label, rmin, rmax, rstep, rval )
285
+
286
+  
287
+#define audio( src, sarg, dst, darg )      cmDspSysConnectAudio( h, src, #sarg, dst, #darg )
288
+#define event( src, sarg, dst, darg )      cmDspSysInstallCb( h, src, #sarg, dst, #darg, NULL )
289
+
290
+  
291
+  
281 292
 #ifdef __cplusplus
282 293
   }
283 294
 #endif

Laden…
Annuleren
Opslaan