Pārlūkot izejas kodu

cmDspKr.h/c, cmDspBuiltIn.c : Initial implementation of shell for cmDspPicadae.

master
kevin.larke 4 gadus atpakaļ
vecāks
revīzija
0627387974
3 mainītis faili ar 132 papildinājumiem un 0 dzēšanām
  1. 1
    0
      dsp/cmDspBuiltIn.c
  2. 130
    0
      dsp/cmDspKr.c
  3. 1
    0
      dsp/cmDspKr.h

+ 1
- 0
dsp/cmDspBuiltIn.c Parādīt failu

@@ -5565,6 +5565,7 @@ cmDspClassConsFunc_t _cmDspClassBuiltInArray[] =
5565 5565
   cmActiveMeasClassCons,
5566 5566
   cmAmSyncClassCons,
5567 5567
   cmNanoMapClassCons,
5568
+  cmPicadaeClassCons,
5568 5569
   cmRecdPlayClassCons,
5569 5570
   cmGoertzelClassCons,
5570 5571
   cmSyncRecdClassCons,

+ 130
- 0
dsp/cmDspKr.c Parādīt failu

@@ -18,6 +18,8 @@
18 18
 #include "cmThread.h"
19 19
 #include "cmUdpPort.h"
20 20
 #include "cmUdpNet.h"
21
+#include "cmSerialPort.h"
22
+
21 23
 //( { file_desc:"'snap' audio effects performance analysis units." kw:[snap]}
22 24
 
23 25
 #include "cmTime.h"
@@ -2803,6 +2805,134 @@ cmDspClass_t* cmNanoMapClassCons( cmDspCtx_t* ctx )
2803 2805
 
2804 2806
 //------------------------------------------------------------------------------------------------------------
2805 2807
 //)
2808
+//( { label:cmDspPicadae file_desc:"Control a MIDI synth." kw:[sunit] }
2809
+
2810
+enum
2811
+{
2812
+  kPgmPcId,
2813
+  kStatusPcId,
2814
+  kD0PcId,
2815
+  kD1PcId,
2816
+  kThruPcId
2817
+};
2818
+
2819
+cmDspClass_t _cmPicadaeDC;
2820
+
2821
+typedef struct
2822
+{
2823
+  cmDspInst_t inst;
2824
+
2825
+} cmDspPicadae_t;
2826
+
2827
+cmDspRC_t _cmDspPicadaeSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, unsigned d0, unsigned d1 )
2828
+{
2829
+  cmDspSetUInt(ctx,inst,kD1PcId,d1);
2830
+  cmDspSetUInt(ctx,inst,kD0PcId,d0);
2831
+  cmDspSetUInt(ctx,inst,kStatusPcId,st);
2832
+  return kOkDspRC;
2833
+}
2834
+
2835
+void _cmDspPicadaePgm( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned pgm )
2836
+{
2837
+  //cmDspPicadae_t* p = (cmDspPicadae_t*)inst;
2838
+
2839
+  unsigned i;
2840
+        
2841
+  for(i=0; i<kMidiChCnt; ++i)
2842
+  {
2843
+    _cmDspPicadaeSend(ctx,inst,kCtlMdId+i,121,0); // reset all controllers
2844
+    _cmDspPicadaeSend(ctx,inst,kCtlMdId+i,123,0); // turn all notes off
2845
+    _cmDspPicadaeSend(ctx,inst,kCtlMdId+i,0,0);   // switch to bank 0
2846
+    _cmDspPicadaeSend(ctx,inst,kPgmMdId+i,pgm,0); // send pgm change
2847
+    cmSleepMs(15);
2848
+  }
2849
+  
2850
+}
2851
+
2852
+cmDspInst_t*  _cmDspPicadaeAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
2853
+{
2854
+  cmDspVarArg_t args[] =
2855
+  {
2856
+    { "pgm",    kPgmPcId,    0,  0,              kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "Reprogram all channels to this pgm." },
2857
+    { "status", kStatusPcId, 0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI status" },
2858
+    { "d0",     kD0PcId,     0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI channel message d0" },
2859
+    { "d1",     kD1PcId,     0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI channel message d1" },
2860
+    { "thru",   kThruPcId,   0,  0,              kInDsvFl | kBoolDsvFl | kOptArgDsvFl, "Enable pass through."},
2861
+    { NULL, 0, 0, 0, 0 }
2862
+  };
2863
+
2864
+  cmDspPicadae_t* p = cmDspInstAlloc(cmDspPicadae_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
2865
+  
2866
+  cmDspSetDefaultUInt(ctx,&p->inst, kPgmPcId, 0, 0 );
2867
+
2868
+  return &p->inst;
2869
+}
2870
+
2871
+cmDspRC_t _cmDspPicadaeReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
2872
+{
2873
+  cmDspRC_t      rc = kOkDspRC;
2874
+
2875
+  cmDspApplyAllDefaults(ctx,inst);
2876
+
2877
+  _cmDspPicadaePgm(ctx,inst,cmDspUInt(inst,kPgmPcId));
2878
+
2879
+  return rc;
2880
+} 
2881
+
2882
+cmDspRC_t _cmDspPicadaeRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
2883
+{
2884
+  //cmDspPicadae_t* p = (cmDspPicadae_t*)inst;
2885
+
2886
+  switch( evt->dstVarId )
2887
+  {
2888
+    case kPgmPcId:
2889
+      cmDspSetEvent(ctx,inst,evt);
2890
+      _cmDspPicadaePgm(ctx,inst,cmDspUInt(inst,kPgmPcId));
2891
+      break;
2892
+
2893
+    case kStatusPcId:
2894
+      {
2895
+        unsigned status = cmDsvGetUInt(evt->valuePtr);        
2896
+        unsigned stat_no_ch = status & 0xf0;
2897
+        if( stat_no_ch == kNoteOnMdId || stat_no_ch == kNoteOffMdId || stat_no_ch == kCtlMdId  )
2898
+        {
2899
+          //unsigned d0 = cmDspUInt(inst,kD0PcId);
2900
+          unsigned ch = 0; //d0 % 8;
2901
+          status = (status & 0xf0) + ch;
2902
+          cmDspSetUInt(ctx,inst,kStatusPcId,status);
2903
+        }
2904
+       
2905
+      }
2906
+      break;
2907
+
2908
+
2909
+    default:
2910
+      cmDspSetEvent(ctx,inst,evt);
2911
+      break;
2912
+  }
2913
+
2914
+
2915
+  return kOkDspRC;
2916
+}
2917
+
2918
+cmDspClass_t* cmPicadaeClassCons( cmDspCtx_t* ctx )
2919
+{
2920
+  cmDspClassSetup(&_cmPicadaeDC,ctx,"Picadae",
2921
+    NULL,
2922
+    _cmDspPicadaeAlloc,
2923
+    NULL,
2924
+    _cmDspPicadaeReset,
2925
+    NULL,
2926
+    _cmDspPicadaeRecv,
2927
+    NULL,
2928
+    NULL,
2929
+    "Picadaesynth Mapper");
2930
+
2931
+  return &_cmPicadaeDC;
2932
+}
2933
+
2934
+//------------------------------------------------------------------------------------------------------------
2935
+//)
2806 2936
 //( { label:cmDspRecdPlay file_desc:"Record audio segments from a live perfromance and play them back at a later time" kw:[sunit] }
2807 2937
 
2808 2938
 enum

+ 1
- 0
dsp/cmDspKr.h Parādīt failu

@@ -17,6 +17,7 @@ extern "C" {
17 17
   struct cmDspClass_str* cmActiveMeasClassCons( cmDspCtx_t* ctx );
18 18
   struct cmDspClass_str* cmAmSyncClassCons( cmDspCtx_t* ctx );
19 19
   struct cmDspClass_str* cmNanoMapClassCons( cmDspCtx_t* ctx );
20
+  struct cmDspClass_str* cmPicadaeClassCons( cmDspCtx_t* ctx );
20 21
   struct cmDspClass_str* cmRecdPlayClassCons( cmDspCtx_t* ctx );
21 22
   struct cmDspClass_str* cmGoertzelClassCons( cmDspCtx_t* ctx );
22 23
   struct cmDspClass_str* cmSyncRecdClassCons( cmDspCtx_t* ctx );

Notiek ielāde…
Atcelt
Saglabāt