Browse Source

cmDspKr.h/c cmDspBuiltIn.c, cmDspPgmKr.c : Added 'NanoMap' DSP object.

master
kpl 10 years ago
parent
commit
edad3b99cd
4 changed files with 130 additions and 5 deletions
  1. 3
    2
      dsp/cmDspBuiltIn.c
  2. 119
    0
      dsp/cmDspKr.c
  3. 1
    0
      dsp/cmDspKr.h
  4. 7
    3
      dsp/cmDspPgmKr.c

+ 3
- 2
dsp/cmDspBuiltIn.c View File

@@ -1203,8 +1203,8 @@ cmDspRC_t _cmDspMidiOutRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
1203 1203
         
1204 1204
         for(i=0; i<kMidiChCnt; ++i)
1205 1205
         {          
1206
-          cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId,121,0); // reset all controllers
1207
-          cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId,123,0); // turn all notes off
1206
+          cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId+i,121,0); // reset all controllers
1207
+          cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId+i,123,0); // turn all notes off
1208 1208
           cmSleepMs(15);
1209 1209
         }
1210 1210
       }
@@ -5411,6 +5411,7 @@ cmDspClassConsFunc_t _cmDspClassBuiltInArray[] =
5411 5411
   cmScaleRangeClassCons,
5412 5412
   cmActiveMeasClassCons,
5413 5413
   cmAmSyncClassCons,
5414
+  cmNanoMapClassCons,
5414 5415
   NULL,
5415 5416
 };
5416 5417
 

+ 119
- 0
dsp/cmDspKr.c View File

@@ -2123,3 +2123,122 @@ struct cmDspClass_str* cmAmSyncClassCons( cmDspCtx_t* ctx )
2123 2123
   return &_cmAmSyncDC;
2124 2124
 }
2125 2125
 
2126
+//==========================================================================================================================================
2127
+enum
2128
+{
2129
+  kPgmNmId,
2130
+  kStatusNmId,
2131
+  kD0NmId,
2132
+  kD1NmId,
2133
+  kThruNmId
2134
+};
2135
+
2136
+cmDspClass_t _cmNanoMapDC;
2137
+
2138
+typedef struct
2139
+{
2140
+  cmDspInst_t inst;
2141
+} cmDspNanoMap_t;
2142
+
2143
+cmDspRC_t _cmDspNanoMapSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, unsigned d0, unsigned d1 )
2144
+{
2145
+  cmDspSetUInt(ctx,inst,kD1NmId,d1);
2146
+  cmDspSetUInt(ctx,inst,kD0NmId,d0);
2147
+  cmDspSetUInt(ctx,inst,kStatusNmId,st);
2148
+  return kOkDspRC;
2149
+}
2150
+
2151
+void _cmDspNanoMapPgm( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned pgm )
2152
+{
2153
+  unsigned i;
2154
+        
2155
+  for(i=0; i<kMidiChCnt; ++i)
2156
+  {
2157
+    _cmDspNanoMapSend(ctx,inst,kCtlMdId+i,121,0); // reset all controllers
2158
+    _cmDspNanoMapSend(ctx,inst,kCtlMdId+i,123,0); // turn all notes off
2159
+    _cmDspNanoMapSend(ctx,inst,kCtlMdId+i,0,0);   // switch to bank 0
2160
+    _cmDspNanoMapSend(ctx,inst,kPgmMdId+i,pgm,0); // send pgm change
2161
+    cmSleepMs(15);
2162
+  }
2163
+  
2164
+}
2165
+
2166
+cmDspInst_t*  _cmDspNanoMapAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
2167
+{
2168
+  cmDspVarArg_t args[] =
2169
+  {
2170
+    { "pgm",    kPgmNmId,    0,  0,              kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "Reprogram all channels to this pgm." },
2171
+    { "status", kStatusNmId, 0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI status" },
2172
+    { "d0",     kD0NmId,     0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI channel message d0" },
2173
+    { "d1",     kD1NmId,     0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI channel message d1" },
2174
+    { "thru",   kThruNmId,   0,  0,              kInDsvFl | kBoolDsvFl | kOptArgDsvFl, "Enable pass through."},
2175
+    { NULL, 0, 0, 0, 0 }
2176
+  };
2177
+
2178
+  cmDspNanoMap_t* p = cmDspInstAlloc(cmDspNanoMap_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
2179
+  
2180
+  cmDspSetDefaultUInt(ctx,&p->inst, kPgmNmId, 0, 0 );
2181
+
2182
+  return &p->inst;
2183
+}
2184
+
2185
+cmDspRC_t _cmDspNanoMapReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
2186
+{
2187
+  cmDspRC_t      rc = kOkDspRC;
2188
+
2189
+  cmDspApplyAllDefaults(ctx,inst);
2190
+
2191
+  _cmDspNanoMapPgm(ctx,inst,cmDspUInt(inst,kPgmNmId));
2192
+
2193
+  return rc;
2194
+} 
2195
+
2196
+cmDspRC_t _cmDspNanoMapRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
2197
+{
2198
+  //cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst;
2199
+
2200
+  switch( evt->dstVarId )
2201
+  {
2202
+    case kPgmNmId:
2203
+      cmDspSetEvent(ctx,inst,evt);
2204
+      _cmDspNanoMapPgm(ctx,inst,cmDspUInt(inst,kPgmNmId));
2205
+      break;
2206
+
2207
+    case kStatusNmId:
2208
+      {
2209
+        unsigned status = cmDsvGetUInt(evt->valuePtr);
2210
+        if( (status & 0xf0) == kNoteOnMdId )
2211
+        {
2212
+          unsigned d0 = cmDspUInt(inst,kD0NmId);
2213
+          unsigned ch = d0 % 8;
2214
+          status = (status & 0xf0) + ch;
2215
+          cmDspSetUInt(ctx,inst,kStatusNmId,status);
2216
+        }
2217
+      }
2218
+      break;
2219
+
2220
+
2221
+    default:
2222
+      cmDspSetEvent(ctx,inst,evt);
2223
+      break;
2224
+  }
2225
+
2226
+
2227
+  return kOkDspRC;
2228
+}
2229
+
2230
+struct cmDspClass_str* cmNanoMapClassCons( cmDspCtx_t* ctx )
2231
+{
2232
+  cmDspClassSetup(&_cmNanoMapDC,ctx,"NanoMap",
2233
+    NULL,
2234
+    _cmDspNanoMapAlloc,
2235
+    NULL,
2236
+    _cmDspNanoMapReset,
2237
+    NULL,
2238
+    _cmDspNanoMapRecv,
2239
+    NULL,
2240
+    NULL,
2241
+    "Nanosynth Mapper");
2242
+
2243
+  return &_cmNanoMapDC;
2244
+}

+ 1
- 0
dsp/cmDspKr.h View File

@@ -15,6 +15,7 @@ extern "C" {
15 15
   struct cmDspClass_str* cmScaleRangeClassCons( cmDspCtx_t* ctx );
16 16
   struct cmDspClass_str* cmActiveMeasClassCons( cmDspCtx_t* ctx );
17 17
   struct cmDspClass_str* cmAmSyncClassCons( cmDspCtx_t* ctx );
18
+  struct cmDspClass_str* cmNanoMapClassCons( cmDspCtx_t* ctx );
18 19
 
19 20
 #ifdef __cplusplus
20 21
 }

+ 7
- 3
dsp/cmDspPgmKr.c View File

@@ -117,6 +117,7 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
117 117
   cmDspInst_t* pts  = cmDspSysAllocInst(h,"PortToSym",   NULL,  2, "on", "off" );
118 118
   cmDspInst_t* mip  = cmDspSysAllocInst(h,"MidiIn",      NULL,  0 );
119 119
   cmDspInst_t* mfp  = cmDspSysAllocInst(h,"MidiFilePlay",NULL,  0 );
120
+  cmDspInst_t* nmp  = cmDspSysAllocInst(h,"NanoMap",     NULL,  0 );
120 121
   cmDspInst_t* mop  = cmDspSysAllocInst(h,"MidiOut",     NULL,  2, r.midiDevice,r.midiOutPort);
121 122
   cmDspInst_t* sfp  = cmDspSysAllocInst(h,"ScFol",       NULL,  1, r.scFn );
122 123
   cmDspInst_t* amp  = cmDspSysAllocInst(h,"ActiveMeas",  NULL,  1, 100 );
@@ -466,15 +467,18 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
466 467
 
467 468
   cmDspSysInstallCb(h, mfp,  "d1",      d1Rt, "f-in",  NULL );
468 469
   cmDspSysInstallCb(h, d1Rt, "f-out-0", sfp,  "d1",    NULL );
469
-  cmDspSysInstallCb(h, d1Rt, "f-out-1", mop,  "d1",    NULL );
470
+  cmDspSysInstallCb(h, d1Rt, "f-out-1", nmp,  "d1",    NULL );
471
+  cmDspSysInstallCb(h, nmp,   "d1",     mop,  "d1",    NULL );
470 472
 
471 473
   cmDspSysInstallCb(h, mfp,  "d0",      d0Rt,  "f-in", NULL );
472 474
   cmDspSysInstallCb(h, d0Rt, "f-out-0", sfp,   "d0",   NULL );
473
-  cmDspSysInstallCb(h, d0Rt, "f-out-1", mop,   "d0",   NULL );
475
+  cmDspSysInstallCb(h, d0Rt, "f-out-1", nmp,  "d0",   NULL );
476
+  cmDspSysInstallCb(h, nmp,  "d0",      mop,  "d0",   NULL );
474 477
 
475 478
   cmDspSysInstallCb(h, mfp, "status",   stRt, "f-in",  NULL );
476 479
   cmDspSysInstallCb(h, stRt, "f-out-0", sfp,  "status",NULL );
477
-  cmDspSysInstallCb(h, stRt, "f-out-1", mop,  "status",NULL );
480
+  cmDspSysInstallCb(h, stRt, "f-out-1", nmp,  "status",NULL );
481
+  cmDspSysInstallCb(h, nmp,  "status",  mop,  "status",NULL );
478 482
 
479 483
   // MIDI input port
480 484
   cmDspSysInstallCb(h, mip, "smpidx", sfp, "smpidx", NULL );

Loading…
Cancel
Save