diff --git a/dsp/cmDspBuiltIn.c b/dsp/cmDspBuiltIn.c index c57b0a9..7864709 100644 --- a/dsp/cmDspBuiltIn.c +++ b/dsp/cmDspBuiltIn.c @@ -5565,6 +5565,7 @@ cmDspClassConsFunc_t _cmDspClassBuiltInArray[] = cmActiveMeasClassCons, cmAmSyncClassCons, cmNanoMapClassCons, + cmPicadaeClassCons, cmRecdPlayClassCons, cmGoertzelClassCons, cmSyncRecdClassCons, diff --git a/dsp/cmDspKr.c b/dsp/cmDspKr.c index 2d7ad22..b098311 100644 --- a/dsp/cmDspKr.c +++ b/dsp/cmDspKr.c @@ -18,6 +18,8 @@ #include "cmThread.h" #include "cmUdpPort.h" #include "cmUdpNet.h" +#include "cmSerialPort.h" + //( { file_desc:"'snap' audio effects performance analysis units." kw:[snap]} #include "cmTime.h" @@ -2801,6 +2803,134 @@ cmDspClass_t* cmNanoMapClassCons( cmDspCtx_t* ctx ) return &_cmNanoMapDC; } +//------------------------------------------------------------------------------------------------------------ +//) +//( { label:cmDspPicadae file_desc:"Control a MIDI synth." kw:[sunit] } + +enum +{ + kPgmPcId, + kStatusPcId, + kD0PcId, + kD1PcId, + kThruPcId +}; + +cmDspClass_t _cmPicadaeDC; + +typedef struct +{ + cmDspInst_t inst; + +} cmDspPicadae_t; + +cmDspRC_t _cmDspPicadaeSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, unsigned d0, unsigned d1 ) +{ + cmDspSetUInt(ctx,inst,kD1PcId,d1); + cmDspSetUInt(ctx,inst,kD0PcId,d0); + cmDspSetUInt(ctx,inst,kStatusPcId,st); + return kOkDspRC; +} + +void _cmDspPicadaePgm( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned pgm ) +{ + //cmDspPicadae_t* p = (cmDspPicadae_t*)inst; + + unsigned i; + + for(i=0; iinst, kPgmPcId, 0, 0 ); + + return &p->inst; +} + +cmDspRC_t _cmDspPicadaeReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt ) +{ + cmDspRC_t rc = kOkDspRC; + + cmDspApplyAllDefaults(ctx,inst); + + _cmDspPicadaePgm(ctx,inst,cmDspUInt(inst,kPgmPcId)); + + return rc; +} + +cmDspRC_t _cmDspPicadaeRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt ) +{ + //cmDspPicadae_t* p = (cmDspPicadae_t*)inst; + + switch( evt->dstVarId ) + { + case kPgmPcId: + cmDspSetEvent(ctx,inst,evt); + _cmDspPicadaePgm(ctx,inst,cmDspUInt(inst,kPgmPcId)); + break; + + case kStatusPcId: + { + unsigned status = cmDsvGetUInt(evt->valuePtr); + unsigned stat_no_ch = status & 0xf0; + if( stat_no_ch == kNoteOnMdId || stat_no_ch == kNoteOffMdId || stat_no_ch == kCtlMdId ) + { + //unsigned d0 = cmDspUInt(inst,kD0PcId); + unsigned ch = 0; //d0 % 8; + status = (status & 0xf0) + ch; + cmDspSetUInt(ctx,inst,kStatusPcId,status); + } + + } + break; + + + default: + cmDspSetEvent(ctx,inst,evt); + break; + } + + + return kOkDspRC; +} + +cmDspClass_t* cmPicadaeClassCons( cmDspCtx_t* ctx ) +{ + cmDspClassSetup(&_cmPicadaeDC,ctx,"Picadae", + NULL, + _cmDspPicadaeAlloc, + NULL, + _cmDspPicadaeReset, + NULL, + _cmDspPicadaeRecv, + NULL, + NULL, + "Picadaesynth Mapper"); + + return &_cmPicadaeDC; +} + //------------------------------------------------------------------------------------------------------------ //) //( { label:cmDspRecdPlay file_desc:"Record audio segments from a live perfromance and play them back at a later time" kw:[sunit] } diff --git a/dsp/cmDspKr.h b/dsp/cmDspKr.h index 05b3c1b..9a70cb6 100644 --- a/dsp/cmDspKr.h +++ b/dsp/cmDspKr.h @@ -17,6 +17,7 @@ extern "C" { struct cmDspClass_str* cmActiveMeasClassCons( cmDspCtx_t* ctx ); struct cmDspClass_str* cmAmSyncClassCons( cmDspCtx_t* ctx ); struct cmDspClass_str* cmNanoMapClassCons( cmDspCtx_t* ctx ); + struct cmDspClass_str* cmPicadaeClassCons( cmDspCtx_t* ctx ); struct cmDspClass_str* cmRecdPlayClassCons( cmDspCtx_t* ctx ); struct cmDspClass_str* cmGoertzelClassCons( cmDspCtx_t* ctx ); struct cmDspClass_str* cmSyncRecdClassCons( cmDspCtx_t* ctx );