Kaynağa Gözat

cmDspPgm.c : Initial working version of 'Picadae' processor.

master
kevin.larke 4 yıl önce
ebeveyn
işleme
1dc08d75a2
1 değiştirilmiş dosya ile 334 ekleme ve 33 silme
  1. 334
    33
      dsp/cmDspKr.c

+ 334
- 33
dsp/cmDspKr.c Dosyayı Görüntüle

@@ -2809,72 +2809,371 @@ cmDspClass_t* cmNanoMapClassCons( cmDspCtx_t* ctx )
2809 2809
 
2810 2810
 enum
2811 2811
 {
2812
-  kPgmPcId,
2813 2812
   kStatusPcId,
2814 2813
   kD0PcId,
2815 2814
   kD1PcId,
2816
-  kThruPcId
2817 2815
 };
2818 2816
 
2819 2817
 cmDspClass_t _cmPicadaeDC;
2820 2818
 
2821 2819
 typedef struct
2822 2820
 {
2823
-  cmDspInst_t inst;
2821
+  unsigned pitch;
2822
+  unsigned velMapA[10];
2823
+} cmDspPicadaeVelMap_t;
2824
+
2825
+// This table is generated from picadae_ac_3/velTableToDataStruct.py 
2826
+
2827
+cmDspPicadaeVelMap_t cmDspPicadaeVelMap[] =
2828
+{
2829
+ { 21,{     0,     0,     0,     0,     0,     0,     0,     0,     0,     0, } },
2830
+ { 22,{     0,     0,     0,     0,     0,     0,     0,     0,     0,     0, } },
2831
+ { 23, { 12800, 12950, 13175, 13500, 13750, 14750, 15375, 17500, 23000, 37000, } },
2832
+ { 24, { 12425, 12800, 13175, 14225, 14750, 15500, 17500, 22500, 32000, 39000, } },
2833
+ { 25, { 14150, 14375, 14975, 14625, 15500, 16500, 20000, 28500, 40000, 40000, } },
2834
+ { 26, { 13000, 13175, 13500, 13700, 13925, 14250, 15000, 16250, 19000, 26500, } },
2835
+ { 27, { 13625, 13925, 14075, 14250, 14500, 14875, 15375, 16500, 18750, 25000, } },
2836
+ { 28, { 12625, 13750, 13775, 14225, 14500, 16500, 18000, 20000, 25500, 34000, } },
2837
+ { 29, { 12125, 12725, 13000, 12950, 14150, 15500, 16250, 17750, 21500, 28000, } },
2838
+ { 30, { 13175, 13325, 13550, 14450, 14875, 15500, 16250, 17750, 21500, 27000, } },
2839
+ { 31, { 13925, 14075, 14450, 14625, 15500, 16250, 16750, 17750, 19500, 23500, } },
2840
+ { 32, { 13250, 14150, 14975, 14750, 15250, 16000, 17500, 21000, 27000, 38000, } },
2841
+ { 33, { 11825, 13025, 14075, 14825, 14375, 14875, 16250, 17500, 22000, 28000, } },
2842
+ { 34, { 13025, 13375, 13325, 13775, 14375, 14500, 15250, 18000, 22000, 27000, } },
2843
+ { 35, { 11375, 12250, 12350, 12725, 14225, 13750, 15375, 17000, 20500, 25000, } },
2844
+ { 36, { 11750, 13875, 14125, 14225, 14675, 14750, 16500, 18500, 22500, 32000, } },
2845
+ { 37, { 12425, 12575, 13000, 13025, 13375, 15000, 16000, 18750, 25500, 35000, } },
2846
+ { 38, { 13750, 13875, 14075, 14600, 14750, 15500, 17750, 21500, 27500, 37000, } },
2847
+ { 39, { 11000, 12500, 12950, 13700, 14875, 15500, 16250, 20000, 26500, 37000, } },
2848
+ { 40, { 11525, 11750, 12125, 12500, 12875, 13500, 14625, 18250, 23500, 29000, } },
2849
+ { 41, { 11675, 11750, 12500, 13000, 13925, 15250, 17000, 20000, 26500, 36000, } },
2850
+ { 42, { 11875, 12000, 11975, 12050, 12275, 13375, 15000, 17250, 22000, 29000, } },
2851
+ { 43, { 11500, 11625, 11750, 11750, 12625, 12250, 13625, 16750, 19500, 25500, } },
2852
+ { 44, { 12425, 12500, 12750, 12650, 13000, 14000, 15250, 16500, 20000, 27000, } },
2853
+ { 45, { 11250, 11600, 11875, 12000, 12250, 13100, 14750, 15500, 18250, 25500, } },
2854
+ { 46, { 11450, 11525, 11600, 11625, 11875, 12250, 14000, 15750, 17750, 21500, } },
2855
+ { 47, { 11900, 11975, 12125, 12375, 13125, 14375, 15750, 18750, 22500, 28500, } },
2856
+ { 48, { 11750, 13100, 13325, 13625, 14300, 14975, 15750, 19000, 24000, 30000, } },
2857
+ { 49, { 11975, 12050, 12500, 12750, 13125, 14000, 17000, 20000, 25500, 40000, } },
2858
+ { 50, { 11625, 11525, 11750, 11825, 12125, 12375, 14750, 16250, 19000, 25500, } },
2859
+ { 51, { 12050, 12125, 12125, 12275, 12350, 12500, 12875, 16250, 18500, 22500, } },
2860
+ { 52, { 12950, 13025, 13125, 13175, 13250, 13500, 13875, 15750, 18000, 22000, } },
2861
+ { 53, { 10600, 10250, 10350, 10450, 10900, 11375, 13025, 14750, 18250, 26500, } },
2862
+ { 54, { 12650, 12625, 12725, 12800, 13000, 13625, 16250, 18500, 23000, 32000, } },
2863
+ { 55, { 11875, 12125, 12250, 12425, 12875, 13175, 13750, 17250, 20000, 26000, } },
2864
+ { 56, { 11625, 11750, 12000, 12200, 12500, 13125, 14375, 17000, 20500, 26500, } },
2865
+ { 57, { 11625, 11750, 12125, 12275, 12750, 14625, 16750, 20000, 25500, 39000, } },
2866
+ { 58, { 12000, 12500, 12750, 12875, 13100, 13375, 15000, 17750, 21000, 28000, } },
2867
+ { 59, { 11625, 11525, 12050, 13375, 13625, 14150, 16500, 21000, 24500, 30000, } },
2868
+ { 60, { 12250, 12250, 12375, 12350, 13000, 13500, 16000, 17750, 22000, 29000, } },
2869
+ { 61, { 11375, 11500, 11625, 11750, 12000, 12200, 12725, 13625, 17500, 21000, } },
2870
+ { 62, { 11600, 11675, 11825, 12125, 12650, 13375, 14375, 18500, 24500, 32000, } },
2871
+ { 63, { 12125, 12200, 12350, 12500, 13025, 13625, 16250, 18750, 24500, 36000, } },
2872
+ { 64, { 10550, 10650, 10850, 11250, 11875, 12250, 14000, 16250, 19500, 26500, } },
2873
+ { 65, { 12750, 12800, 12875, 13175, 13250, 14625, 14975, 17500, 20500, 26000, } },
2874
+ { 66, { 10750, 11000, 11250, 11500, 12000, 12875, 15375, 17000, 20500, 28500, } },
2875
+ { 67, { 10950, 11125, 11250, 11500, 11875, 13875, 15750, 17750, 23000, 37000, } },
2876
+ { 68, { 10150, 10300, 10550, 10800, 11125, 11875, 13000, 16000, 19000, 25000, } },
2877
+ { 69, { 11750, 11875, 12375, 12500, 12750, 13500, 16250, 18250, 23500, 31000, } },
2878
+ { 70, { 10700, 10850, 10950, 11125, 11625, 13875, 14500, 15750, 18750, 24500, } },
2879
+ { 71, { 10200, 10700, 11000, 11250, 11625, 14000, 14875, 16250, 22000, 27000, } },
2880
+ { 72, {  9800, 10100, 10400, 10550, 11000, 11625, 13000, 15500, 17750, 23000, } },
2881
+ { 73, { 10750, 10900, 11125, 11375, 11625, 12750, 14750, 15500, 18500, 23000, } },
2882
+ { 74, { 10300, 10450, 10600, 10850, 11250, 12000, 14250, 15000, 17500, 21000, } },
2883
+ { 75, { 10600, 10750, 10900, 11125, 12500, 14500, 14750, 15000, 21000, 31000, } },
2884
+ { 76, { 10200, 11625, 12375, 12875, 13500, 15750, 19000, 22500, 27500, 39000, } },
2885
+ { 77, { 10500, 10700, 11125, 11375, 11750, 14000, 14875, 16500, 20500, 27000, } },
2886
+ { 78, { 10450, 10800, 11000, 11625, 12000, 13125, 15500, 18250, 22000, 34000, } },
2887
+ { 79, { 12250, 13500, 14125, 14750, 16250, 17500, 19000, 24500, 31000, 40000, } },
2888
+ { 80, { 10400, 10450, 10750, 11125, 12125, 13375, 14750, 17750, 23000, 39000, } },
2889
+ { 81, { 10800, 10950, 11125, 11375, 12625, 13875, 14875, 16000, 19000, 23500, } },
2890
+ { 82, { 12000, 12375, 13750, 13750, 12625, 14000, 17000, 19000, 21000, 24500, } },
2891
+ { 83, { 12250, 12500, 13625, 13875, 14375, 16500, 17750, 20500, 25000, 35000, } },
2892
+ { 84, { 11500, 12000, 12250, 12500, 13125, 14250, 15375, 16750, 19500, 25500, } },
2893
+ { 85, { 10400, 10500, 10600, 11250, 12250, 13375, 15000, 16750, 20000, 26000, } },
2894
+ { 86, { 11500, 11750, 11875, 12000, 12250, 12500, 13500, 15000, 20500, 21000, } },
2895
+ { 87, { 10650, 11500, 13125, 13375, 13750, 14500, 16500, 18000, 20000, 24000, } },
2896
+ { 88, { 11375, 11375, 11500, 12375, 12000, 13375, 14500, 16500, 19000, 23000, } },
2897
+ { 89, {  9200, 10900, 11500, 12125, 22000, 12875, 14125, 16000, 19000, 26500, } },
2898
+ { 90, {     0,     0,     0,     0,     0,     0,     0,     0,     0,     0, } },
2899
+ { 91, {  9450,  9950, 10000, 10150, 10600, 11250, 12125, 13875, 15250, 19000, } },
2900
+ { 92, {  9050,  9500,  9600, 10100, 10900, 11875, 13000, 16000, 20500, 31000, } },
2901
+ { 93, { 11250, 11375, 12000, 12375, 12875, 13625, 14250, 17500, 21500, 39000, } },
2902
+ { 94, { 11125, 11375, 11750, 13500, 14000, 14875, 15750, 17750, 22000, 25500, } },
2903
+ { 95, { 10200, 10350, 11500, 12250, 12500, 13125, 13875, 15250, 19000, 21000, } },
2904
+ { 96, {  9050,  9550, 10100, 13875, 13000, 14000, 18500, 22000, 27000, 39000, } },
2905
+ { 97, { 11000, 12500, 13250, 13000, 13750, 15750, 15000, 18000, 19000, 22500, } },
2906
+ { 98, { 10400, 10850, 12125, 12125, 13250, 13875, 16000, 18750, 26500, 37000, } },
2907
+ { 99, { 11000, 12625, 13125, 14000, 15500, 16750, 19000, 21500, 25000, 36000, } },
2908
+ { 100,{  9650, 10450, 11500, 12375, 12500, 12875, 13500, 15500, 17500, 21500, } },
2909
+ { 101,{ 10950, 11250, 11500, 11875, 12250, 12875, 13500, 14375, 22500, 39000, } },
2910
+ { 102,{     0,     0,     0,     0,     0,     0,     0,     0,     0,     0, } },
2911
+ { 103,{     0,     0,     0,     0,     0,     0,     0,     0,     0,     0, } },
2912
+ { 104,{     0,     0,     0,     0,     0,     0,     0,     0,     0,     0, } },
2913
+ { 105,{     0,     0,     0,     0,     0,     0,     0,     0,     0,     0, } },
2914
+ { 106,{     0,     0,     0,     0,     0,     0,     0,     0,     0,     0, } },
2915
+ { 107,{     0,     0,     0,     0,     0,     0,     0,     0,     0,     0, } },
2916
+ { 108,{     0,     0,     0,     0,     0,     0,     0,     0,     0,     0, } },
2917
+ { 0,  {     0,     0,     0,     0,     0,     0,     0,     0,     0,     0, } }
2918
+};
2919
+
2920
+typedef struct
2921
+{
2922
+  int us;
2923
+  int dutyPct;
2924
+} cmDspPicadaeDutyMap_t;
2925
+
2926
+typedef struct
2927
+{
2928
+  unsigned  pitch;
2929
+  cmDspPicadaeDutyMap_t dutyMapA[5];
2930
+} cmDspPicadaeDuty_t;
2931
+
2932
+// This table is generated from picadae_ac_3/velTableToDataStruct.py 
2933
+
2934
+cmDspPicadaeDuty_t cmDspPicadaeDutyMap[] =
2935
+{
2936
+ 21, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2937
+ 22, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2938
+ 23, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2939
+ 24, {{ 0, 75 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2940
+ 25, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2941
+ 26, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2942
+ 27, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2943
+ 28, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2944
+ 29, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2945
+ 30, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2946
+ 31, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2947
+ 32, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2948
+ 33, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2949
+ 34, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2950
+ 35, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2951
+ 36, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2952
+ 37, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2953
+ 38, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2954
+ 39, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2955
+ 40, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2956
+ 41, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2957
+ 42, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2958
+ 43, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2959
+ 44, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2960
+ 45, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2961
+ 46, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2962
+ 47, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2963
+ 48, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2964
+ 49, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2965
+ 50, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2966
+ 51, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2967
+ 52, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2968
+ 53, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2969
+ 54, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2970
+ 55, {{ 0, 50 }, { 22000, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2971
+ 56, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2972
+ 57, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2973
+ 58, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2974
+ 59, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2975
+ 60, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2976
+ 61, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2977
+ 62, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2978
+ 63, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2979
+ 64, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2980
+ 65, {{ 0, 50 }, { 17000, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2981
+ 66, {{ 0, 53 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2982
+ 67, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2983
+ 68, {{ 0, 53 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2984
+ 69, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2985
+ 70, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2986
+ 71, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2987
+ 72, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2988
+ 73, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2989
+ 74, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2990
+ 75, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2991
+ 76, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2992
+ 77, {{ 0, 50 }, { 15000, 60 }, { 19000, 70 }, { -1, -1 }, { -1, -1 }, },
2993
+ 78, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2994
+ 79, {{ 0, 50 }, { 15000, 60 }, { 19000, 70 }, { -1, -1 }, { -1, -1 }, },
2995
+ 80, {{ 0, 45 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2996
+ 81, {{ 0, 50 }, { 15000, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2997
+ 82, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
2998
+ 83, {{ 0, 50 }, { 15000, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2999
+ 84, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
3000
+ 85, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
3001
+ 86, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
3002
+ 87, {{ 0, 50 }, { 14000, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3003
+ 88, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
3004
+ 89, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
3005
+ 90, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3006
+ 91, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, }, 
3007
+ 92, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3008
+ 93, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, },
3009
+ 94, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3010
+ 95, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, },
3011
+ 96, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, },
3012
+ 97, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3013
+ 98, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3014
+ 99, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3015
+ 100, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3016
+ 101, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3017
+ 102, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3018
+ 103, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3019
+ 104, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3020
+ 105, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3021
+ 106, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3022
+ 107, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3023
+ 108, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3024
+   0, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3025
+
3026
+};
2824 3027
 
3028
+typedef struct
3029
+{
3030
+  cmDspInst_t inst;
3031
+  unsigned    curDutyPctA[127];  
2825 3032
 } cmDspPicadae_t;
2826 3033
 
2827
-cmDspRC_t _cmDspPicadaeSend( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned st, unsigned d0, unsigned d1 )
3034
+
3035
+unsigned _cmDspPicadaeVelToMicroseconds( unsigned pitch, unsigned vel )
2828 3036
 {
2829
-  cmDspSetUInt(ctx,inst,kD1PcId,d1);
2830
-  cmDspSetUInt(ctx,inst,kD0PcId,d0);
2831
-  cmDspSetUInt(ctx,inst,kStatusPcId,st);
2832
-  return kOkDspRC;
3037
+  unsigned i;
3038
+
3039
+  unsigned velN = sizeof(cmDspPicadaeVelMap[i].velMapA)/sizeof(cmDspPicadaeVelMap[i].velMapA[0]);
3040
+
3041
+  long velIdx = lround( vel * velN / 127.0  );
3042
+
3043
+  assert( pitch >= cmDspPicadaeVelMap[0].pitch );
3044
+  long pitchIdx = pitch - cmDspPicadaeVelMap[0].pitch;
3045
+
3046
+  return cmDspPicadaeVelMap[pitchIdx].velMapA[velIdx];
2833 3047
 }
2834 3048
 
2835
-void _cmDspPicadaePgm( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned pgm )
3049
+int _cmDspPicadaeVelToDutyCycle( unsigned pitch, unsigned usec )
2836 3050
 {
2837
-  //cmDspPicadae_t* p = (cmDspPicadae_t*)inst;
3051
+  unsigned            i;
3052
+  int                 dutyPct  = -1;
3053
+  long                pitchIdx = pitch - cmDspPicadaeDutyMap[0].pitch;
3054
+  cmDspPicadaeDuty_t* r        = cmDspPicadaeDutyMap + pitchIdx;
2838 3055
 
2839
-  unsigned i;
2840
-        
2841
-  for(i=0; i<kMidiChCnt; ++i)
3056
+  for(i=0; r->dutyMapA[i].us != -1; ++i)
3057
+    if( r->dutyMapA[i].us <= usec )
3058
+      dutyPct = r->dutyMapA[i].dutyPct;
3059
+
3060
+  return dutyPct;
3061
+}
3062
+
3063
+void _cmDspPicadaeSerialXmitNoteOff( cmDspCtx_t* ctx, cmDspInst_t* inst, uint8_t pitch )
3064
+{
3065
+  const uint8_t note_off_op  = 3;
3066
+  uint8_t      serialBuf[]  = { 'w', pitch,  note_off_op, 1, 0 };
3067
+
3068
+  cmSeSend( cmDspSysSerialPort(ctx->dspH), serialBuf, sizeof(serialBuf) );
3069
+}
3070
+
3071
+void _cmDspPicadaeSerialXmitNoteOn( cmDspCtx_t* ctx, cmDspInst_t* inst, uint8_t pitch, uint8_t coarse_tick, uint8_t fine_tick )
3072
+{
3073
+  const uint8_t  note_on_usec_op   = 2;
3074
+  uint8_t serialBuf[] = { 'w', pitch,  note_on_usec_op, 2, coarse_tick, fine_tick };
3075
+
3076
+  cmSeSend( cmDspSysSerialPort(ctx->dspH), serialBuf, sizeof(serialBuf) );
3077
+}
3078
+
3079
+void _cmDspPicadaeSerialXmitDuty( cmDspCtx_t* ctx, cmDspPicadae_t* p, uint8_t pitch, uint8_t dutyPct )
3080
+{
3081
+  if( p->curDutyPctA[ pitch ] != dutyPct )
2842 3082
   {
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);
3083
+    uint8_t       duty_pct_op = 0;
3084
+    unsigned char serialBuf[] = { 'w', pitch,  duty_pct_op, 1, dutyPct };
3085
+  
3086
+    cmSeSend( cmDspSysSerialPort(ctx->dspH), serialBuf, sizeof(serialBuf) );
2848 3087
   }
2849 3088
   
2850 3089
 }
2851 3090
 
3091
+void _cmDspPicadaeSendNote( cmDspCtx_t* ctx, cmDspInst_t* inst )
3092
+{
3093
+  cmDspPicadae_t* p = (cmDspPicadae_t*)inst;
3094
+  unsigned prescaler_usec = 16;
3095
+
3096
+  unsigned status   = cmDspUInt(inst,kStatusPcId);
3097
+  uint8_t  pitch    = (uint8_t)cmDspUInt(inst,kD0PcId);
3098
+  unsigned velocity = cmDspUInt(inst,kD1PcId);
3099
+
3100
+  assert( 21<=pitch && pitch<=108 );
3101
+  
3102
+  // if this is a note-off
3103
+  if( status == kNoteOffMdId || velocity == 0 )
3104
+  {
3105
+    _cmDspPicadaeSerialXmitNoteOff( ctx, inst, pitch );
3106
+    return;
3107
+  }
3108
+  
3109
+  unsigned usec     = _cmDspPicadaeVelToMicroseconds(pitch, velocity );
3110
+
3111
+  // if the pitch is invalid then 'usec' will be set to 0
3112
+  if( usec == 0 )
3113
+    return;
3114
+  
3115
+  unsigned dutyPct    = _cmDspPicadaeVelToDutyCycle( pitch, usec );
3116
+
3117
+  // if the pitch is invalid then dutyPct will be set to -1
3118
+  if( dutyPct == -1 )
3119
+    return;
3120
+
3121
+  unsigned coarse_usec = prescaler_usec*255; // usec's in one coarse tick        
3122
+  uint8_t coarse_ticks = (uint8_t)(usec / coarse_usec);
3123
+  uint8_t fine_ticks   = (uint8_t)((usec - coarse_ticks*coarse_usec) / prescaler_usec);
3124
+
3125
+  
3126
+  _cmDspPicadaeSerialXmitDuty( ctx, p, pitch, dutyPct );
3127
+  
3128
+  _cmDspPicadaeSerialXmitNoteOn( ctx, inst, pitch, coarse_ticks, fine_ticks );
3129
+}
3130
+
2852 3131
 cmDspInst_t*  _cmDspPicadaeAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
2853 3132
 {
2854 3133
   cmDspVarArg_t args[] =
2855 3134
   {
2856
-    { "pgm",    kPgmPcId,    0,  0,              kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "Reprogram all channels to this pgm." },
2857 3135
     { "status", kStatusPcId, 0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI status" },
2858 3136
     { "d0",     kD0PcId,     0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI channel message d0" },
2859 3137
     { "d1",     kD1PcId,     0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI channel message d1" },
2860
-    { "thru",   kThruPcId,   0,  0,              kInDsvFl | kBoolDsvFl | kOptArgDsvFl, "Enable pass through."},
2861 3138
     { NULL, 0, 0, 0, 0 }
2862 3139
   };
2863 3140
 
2864 3141
   cmDspPicadae_t* p = cmDspInstAlloc(cmDspPicadae_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
2865 3142
   
2866
-  cmDspSetDefaultUInt(ctx,&p->inst, kPgmPcId, 0, 0 );
2867
-
2868 3143
   return &p->inst;
2869 3144
 }
2870 3145
 
3146
+void _cmDspPicadaReset( cmDspCtx_t* ctx, cmDspInst_t* inst )
3147
+{
3148
+  cmDspPicadae_t* p = (cmDspPicadae_t*)inst;
3149
+  
3150
+  memset(p->curDutyPctA,0,sizeof(p->curDutyPctA));
3151
+
3152
+  // send note-off messages to all keys 
3153
+  unsigned i = 0;
3154
+  for(i=0; cmDspPicadaeVelMap[i].pitch !=0; ++i)
3155
+    if( cmDspPicadaeVelMap[i].velMapA[0] != 0 )
3156
+    {
3157
+      _cmDspPicadaeSerialXmitNoteOff( ctx, inst, (uint8_t)cmDspPicadaeVelMap[i].pitch );
3158
+      cmSleepMs(10);
3159
+    }
3160
+
3161
+  // send pedal-up message
3162
+  cmDspSetUInt(ctx,inst,kD0PcId, kSustainCtlMdId );
3163
+  cmDspSetUInt(ctx,inst,kD0PcId, 0 );  
3164
+  cmDspSetUInt(ctx,inst,kStatusPcId,kCtlMdId);
3165
+
3166
+}
3167
+
2871 3168
 cmDspRC_t _cmDspPicadaeReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
2872 3169
 {
2873 3170
   cmDspRC_t      rc = kOkDspRC;
2874 3171
 
2875 3172
   cmDspApplyAllDefaults(ctx,inst);
3173
+  
3174
+
3175
+  
2876 3176
 
2877
-  _cmDspPicadaePgm(ctx,inst,cmDspUInt(inst,kPgmPcId));
2878 3177
 
2879 3178
   return rc;
2880 3179
 } 
@@ -2885,21 +3184,22 @@ cmDspRC_t _cmDspPicadaeRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
2885 3184
 
2886 3185
   switch( evt->dstVarId )
2887 3186
   {
2888
-    case kPgmPcId:
2889
-      cmDspSetEvent(ctx,inst,evt);
2890
-      _cmDspPicadaePgm(ctx,inst,cmDspUInt(inst,kPgmPcId));
2891
-      break;
2892 3187
 
2893
-    case kStatusPcId:
3188
+    case kStatusPcId:  
2894 3189
       {
2895
-        unsigned status = cmDsvGetUInt(evt->valuePtr);        
3190
+        // note: the status byte arrives last (after d0 and d1)
3191
+        unsigned status     = cmDsvGetUInt(evt->valuePtr);        
2896 3192
         unsigned stat_no_ch = status & 0xf0;
3193
+        
3194
+        // if this is a note-on or channel
2897 3195
         if( stat_no_ch == kNoteOnMdId || stat_no_ch == kNoteOffMdId || stat_no_ch == kCtlMdId  )
2898 3196
         {
2899
-          //unsigned d0 = cmDspUInt(inst,kD0PcId);
2900
-          unsigned ch = 0; //d0 % 8;
2901
-          status = (status & 0xf0) + ch;
2902
-          cmDspSetUInt(ctx,inst,kStatusPcId,status);
3197
+          
3198
+          cmDspSetUInt(ctx,inst,kStatusPcId,stat_no_ch);
3199
+          
3200
+          if( stat_no_ch == kNoteOnMdId || stat_no_ch == kNoteOffMdId )
3201
+            _cmDspPicadaeSendNote( ctx, inst );
3202
+          
2903 3203
         }
2904 3204
        
2905 3205
       }
@@ -2907,6 +3207,7 @@ cmDspRC_t _cmDspPicadaeRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
2907 3207
 
2908 3208
 
2909 3209
     default:
3210
+      // store 
2910 3211
       cmDspSetEvent(ctx,inst,evt);
2911 3212
       break;
2912 3213
   }

Loading…
İptal
Kaydet