From edad3b99cd0afe34636a862bc77aac233ba99ece Mon Sep 17 00:00:00 2001 From: kpl Date: Thu, 31 Oct 2013 18:07:00 -0700 Subject: [PATCH] cmDspKr.h/c cmDspBuiltIn.c, cmDspPgmKr.c : Added 'NanoMap' DSP object. --- dsp/cmDspBuiltIn.c | 5 +- dsp/cmDspKr.c | 119 +++++++++++++++++++++++++++++++++++++++++++++ dsp/cmDspKr.h | 1 + dsp/cmDspPgmKr.c | 10 ++-- 4 files changed, 130 insertions(+), 5 deletions(-) diff --git a/dsp/cmDspBuiltIn.c b/dsp/cmDspBuiltIn.c index 066675a..11c8552 100644 --- a/dsp/cmDspBuiltIn.c +++ b/dsp/cmDspBuiltIn.c @@ -1203,8 +1203,8 @@ cmDspRC_t _cmDspMidiOutRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t for(i=0; idevIdx,p->portIdx,kCtlMdId,121,0); // reset all controllers - cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId,123,0); // turn all notes off + cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId+i,121,0); // reset all controllers + cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId+i,123,0); // turn all notes off cmSleepMs(15); } } @@ -5411,6 +5411,7 @@ cmDspClassConsFunc_t _cmDspClassBuiltInArray[] = cmScaleRangeClassCons, cmActiveMeasClassCons, cmAmSyncClassCons, + cmNanoMapClassCons, NULL, }; diff --git a/dsp/cmDspKr.c b/dsp/cmDspKr.c index 5a831ca..917006f 100644 --- a/dsp/cmDspKr.c +++ b/dsp/cmDspKr.c @@ -2123,3 +2123,122 @@ struct cmDspClass_str* cmAmSyncClassCons( cmDspCtx_t* ctx ) return &_cmAmSyncDC; } +//========================================================================================================================================== +enum +{ + kPgmNmId, + kStatusNmId, + kD0NmId, + kD1NmId, + kThruNmId +}; + +cmDspClass_t _cmNanoMapDC; + +typedef struct +{ + cmDspInst_t inst; +} cmDspNanoMap_t; + +cmDspRC_t _cmDspNanoMapSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, unsigned d0, unsigned d1 ) +{ + cmDspSetUInt(ctx,inst,kD1NmId,d1); + cmDspSetUInt(ctx,inst,kD0NmId,d0); + cmDspSetUInt(ctx,inst,kStatusNmId,st); + return kOkDspRC; +} + +void _cmDspNanoMapPgm( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned pgm ) +{ + unsigned i; + + for(i=0; iinst, kPgmNmId, 0, 0 ); + + return &p->inst; +} + +cmDspRC_t _cmDspNanoMapReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt ) +{ + cmDspRC_t rc = kOkDspRC; + + cmDspApplyAllDefaults(ctx,inst); + + _cmDspNanoMapPgm(ctx,inst,cmDspUInt(inst,kPgmNmId)); + + return rc; +} + +cmDspRC_t _cmDspNanoMapRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt ) +{ + //cmDspNanoMap_t* p = (cmDspNanoMap_t*)inst; + + switch( evt->dstVarId ) + { + case kPgmNmId: + cmDspSetEvent(ctx,inst,evt); + _cmDspNanoMapPgm(ctx,inst,cmDspUInt(inst,kPgmNmId)); + break; + + case kStatusNmId: + { + unsigned status = cmDsvGetUInt(evt->valuePtr); + if( (status & 0xf0) == kNoteOnMdId ) + { + unsigned d0 = cmDspUInt(inst,kD0NmId); + unsigned ch = d0 % 8; + status = (status & 0xf0) + ch; + cmDspSetUInt(ctx,inst,kStatusNmId,status); + } + } + break; + + + default: + cmDspSetEvent(ctx,inst,evt); + break; + } + + + return kOkDspRC; +} + +struct cmDspClass_str* cmNanoMapClassCons( cmDspCtx_t* ctx ) +{ + cmDspClassSetup(&_cmNanoMapDC,ctx,"NanoMap", + NULL, + _cmDspNanoMapAlloc, + NULL, + _cmDspNanoMapReset, + NULL, + _cmDspNanoMapRecv, + NULL, + NULL, + "Nanosynth Mapper"); + + return &_cmNanoMapDC; +} diff --git a/dsp/cmDspKr.h b/dsp/cmDspKr.h index 6d9f320..454f85f 100644 --- a/dsp/cmDspKr.h +++ b/dsp/cmDspKr.h @@ -15,6 +15,7 @@ extern "C" { struct cmDspClass_str* cmScaleRangeClassCons( cmDspCtx_t* ctx ); struct cmDspClass_str* cmActiveMeasClassCons( cmDspCtx_t* ctx ); struct cmDspClass_str* cmAmSyncClassCons( cmDspCtx_t* ctx ); + struct cmDspClass_str* cmNanoMapClassCons( cmDspCtx_t* ctx ); #ifdef __cplusplus } diff --git a/dsp/cmDspPgmKr.c b/dsp/cmDspPgmKr.c index 001d172..0b9b996 100644 --- a/dsp/cmDspPgmKr.c +++ b/dsp/cmDspPgmKr.c @@ -117,6 +117,7 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr ) cmDspInst_t* pts = cmDspSysAllocInst(h,"PortToSym", NULL, 2, "on", "off" ); cmDspInst_t* mip = cmDspSysAllocInst(h,"MidiIn", NULL, 0 ); cmDspInst_t* mfp = cmDspSysAllocInst(h,"MidiFilePlay",NULL, 0 ); + cmDspInst_t* nmp = cmDspSysAllocInst(h,"NanoMap", NULL, 0 ); cmDspInst_t* mop = cmDspSysAllocInst(h,"MidiOut", NULL, 2, r.midiDevice,r.midiOutPort); cmDspInst_t* sfp = cmDspSysAllocInst(h,"ScFol", NULL, 1, r.scFn ); cmDspInst_t* amp = cmDspSysAllocInst(h,"ActiveMeas", NULL, 1, 100 ); @@ -466,15 +467,18 @@ cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr ) cmDspSysInstallCb(h, mfp, "d1", d1Rt, "f-in", NULL ); cmDspSysInstallCb(h, d1Rt, "f-out-0", sfp, "d1", NULL ); - cmDspSysInstallCb(h, d1Rt, "f-out-1", mop, "d1", NULL ); + cmDspSysInstallCb(h, d1Rt, "f-out-1", nmp, "d1", NULL ); + cmDspSysInstallCb(h, nmp, "d1", mop, "d1", NULL ); cmDspSysInstallCb(h, mfp, "d0", d0Rt, "f-in", NULL ); cmDspSysInstallCb(h, d0Rt, "f-out-0", sfp, "d0", NULL ); - cmDspSysInstallCb(h, d0Rt, "f-out-1", mop, "d0", NULL ); + cmDspSysInstallCb(h, d0Rt, "f-out-1", nmp, "d0", NULL ); + cmDspSysInstallCb(h, nmp, "d0", mop, "d0", NULL ); cmDspSysInstallCb(h, mfp, "status", stRt, "f-in", NULL ); cmDspSysInstallCb(h, stRt, "f-out-0", sfp, "status",NULL ); - cmDspSysInstallCb(h, stRt, "f-out-1", mop, "status",NULL ); + cmDspSysInstallCb(h, stRt, "f-out-1", nmp, "status",NULL ); + cmDspSysInstallCb(h, nmp, "status", mop, "status",NULL ); // MIDI input port cmDspSysInstallCb(h, mip, "smpidx", sfp, "smpidx", NULL );