|
@@ -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
|
+}
|