From 41ff645b3bc240ea669267598c4e0c1d63fc84fb Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Wed, 30 May 2018 14:25:46 +0200 Subject: [PATCH] Code cleanup. --- .dexed_sysex.cpp.swp | Bin 0 -> 16384 bytes .swp | Bin 0 -> 12288 bytes MicroDexed.ino | 116 +++++++++++++++---------------- config.h | 2 +- dexed.h | 126 ++++++++++++++++++++++++++-------- dexed_sysex.cpp | 160 +++++++++++++++++++++++++------------------ 6 files changed, 251 insertions(+), 153 deletions(-) create mode 100644 .dexed_sysex.cpp.swp create mode 100644 .swp diff --git a/.dexed_sysex.cpp.swp b/.dexed_sysex.cpp.swp new file mode 100644 index 0000000000000000000000000000000000000000..f4db4db0e61b6aaefb4d506ffab5f79e55cc3041 GIT binary patch literal 16384 zcmeI2+ixRR9mfwX3oX4t3q0`j+f+h!*6V9Fm(3={o7fw(PVCywF58tD#^d97$auz` z87Fa9ERWnJDj}hL*q2sCT&f~eAq46R5&|Ldzzap<4*;r_C`jCjDDXXJ#u?j*v+BMe z#2M-1%bef&&F_5AZ_a3bGtKms(k3k?(+u1D8TH5!!{dd`R z`(1ru;VwpKz9}81@@}hd+D>ZIG+bw$AMjSHB|bH8;PHc`(d*sam9kI@CQa~x76i^B%1(X6x0i}RaKq>IQtAO9TpM4hL-xm(S3%}nr z@%`^`tA+dhiT3-${~r#&e>%|~{#9Q}0i}RaKq;UUPzopolmbctrGQdEDWDWk3j7xo z&|8c>g5&;0-0$b)~u(QDuaxC}lH zPJtgi%vc}z;91ZE*Fgy^f*AM^_~%26{T}=dd>_0Dz5!kWUk0BC4tNGMKmvROJOmi{ z`}-Js9sB~^2G4^Xa0z@6y!9YszXiVmKL$Sl-v!?SFM$`q3*ghB1FnN-z&yx;#{dIw zJ^)?7>)==5W$;z-MWBNv@B#3~dvP3a3p@)-;52yaJ&gSld>z~b=fNLOG4^ZlJSc-4 zxbtqtz6m;@0v-TAN1^2_;B(+pUknNdSRMcb zVjkBEjqS0?ADhXAMHyr6o?@)8m9^TXjfS?iUAr!_&YXz{ zZQ_FEalRXy7bp9kV;Wqu``spYu^MKwi*cMo(o()tcy`rxeC}yZyDhG8vH>q2`iq(` zu7JUbGTdQ~{hg(7DP5t^mAD=X6A`7^rkGfu5M_Nm>GZfA3tnHe^)8Ra<8g7UqA(Cv z%j^bgI*vt_qlfP~YBKbgG?6_MG>l_(Q1BzJ3&FKvc!d~#5BHPYxb3@xq+vN80tki@ zG(_g&e-oGc-O*;EsXggvz|uBBV=<0_sccl^{QaanwU*JHEsgKE3Z2LIgm3(cooqHG&%%;zBolNlLq%7&cP-PV zy6%_9 zXUEmMST5Rx^FBfQuIY2~9W-+siF2wuZGT^P@z3eoIH65=7p|^3eeya^-)d1u-{XW- z;pQH1kxquw8<5kMJ}zx-(N+j6JqQMG#IxzlB5foIneRVG7vyX1AM5F^?wP*l_gkiu zY;oj1!jE-)zvrD#rFJmfeluw}-IVS%v)xQOcndx*Ger!p!I4*kv$^ECR4zFmq`5Af zAyG|kwS>Fq9eOc$I`tgaAL_9#UaH5CAQzU)9n%hSH0r`qvrOFo--mnjJs|G?htKbS zhI{<)f$xA@pa#m|3Gg=V_5TK51z!VC0|I}7k2~Op;6-p7+yY+!2S6O757edttZgR=F3S2!SlfO-h(OO(q7bx`j(fky`ndGVZW wDJ~1)QgnHjFYCU6yO?NSIdm9Q3Z)BK>>fTWx#yTUiU4B#GVZph2?R0!2N_lKWB>pF literal 0 HcmV?d00001 diff --git a/.swp b/.swp new file mode 100644 index 0000000000000000000000000000000000000000..2ff57aada4b620b8586e8c243334275cc75938d2 GIT binary patch literal 12288 zcmeI1&2H0B5QT5MLxL8;j@3Y=DsH3J*G_Rzl}aUXXjSJ2$M%xeB|(Zxr6>foV#6Ns z9J~Z?z#FjUC0H{4t8b$?$_gdYxzh2?B%U)f-*pyIF7@EFMb$lB@Om6wlGV5n;$}FW ze97LJvtNC_4lQfW4fqHIKwt?7Jn&6J#$WZV7tiVG6MqSMLJJ@O0w4eaAOHd&00JNY z0{@G^WV9x}auj4Fo^{1V8`;KmY_l00ck)1V8`;Kwt$4gnc2}4~6)_ zivIu4e*b^x7oS+WtUnt<{9=7$wOI$OzmJ6Y$+}^^V?AU2&U{vo16l?F5C8!X009sH z0T2KI5LgxhABGy6*%)B zj?OIdaqQ-OpBatjM}GH|D-U@3guAj#uE8={l`=UTI~+S4J5g*0alzN_8FjsKUc6y< My^|!4hl*qI4_-#rvH$=8 literal 0 HcmV?d00001 diff --git a/MicroDexed.ino b/MicroDexed.ino index aaf76e8..6d1f70d 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -1,26 +1,26 @@ /* - * MicroDexed - * - * MicroDexed is a port of the Dexed sound engine - * (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6 with audio shield - * - * (c)2018 H. Wirtz - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ + MicroDexed + + MicroDexed is a port of the Dexed sound engine + (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6 with audio shield + + (c)2018 H. Wirtz + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ #include #include @@ -125,7 +125,7 @@ void setup() void loop() { int16_t* audio_buffer; // pointer to 128 * int16_t (=256 bytes!) - bool break_for_calculation=false; + bool break_for_calculation = false; while (42 == 42) // DON'T PANIC! { @@ -249,85 +249,85 @@ void show_patch(void) Serial.print(6 - i, DEC); Serial.println(F(":")); Serial.println(F("R1|R2|R3|R4|L1|L2|L3|L4 LEV_SCL_BRK_PT|SCL_LEFT_DEPTH|SCL_RGHT_DEPTH")); - Serial.print(dexed->data[(i * 21) + 0], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_EG_R1], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 1], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_EG_R2], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 2], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_EG_R3], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 3], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_EG_R4], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 4], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_EG_L1], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 5], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_EG_L2], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 6], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_EG_L3], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 7], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_EG_L4], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 8], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_LEV_SCL_BRK_PT], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 9], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_SCL_LEFT_DEPTH], DEC); Serial.print(F(" ")); - Serial.println(dexed->data[(i * 21) + 10], DEC); + Serial.println(dexed->data[(i * 21) + DEXED_OP_SCL_RGHT_DEPTH], DEC); Serial.println(F("SCL_L_CURVE|SCL_R_CURVE|RT_SCALE| AMS | KVS |OUT_LEV|OP_MOD|FRQ_C|FRQ_F|DETUNE")); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 11], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_SCL_LEFT_CURVE], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 12], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_SCL_RGHT_CURVE], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 13], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_OSC_RATE_SCALE], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 14], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_AMP_MOD_SENS], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 15], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_KEY_VEL_SENS], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 16], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_OUTPUT_LEV], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 17], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_OSC_MODE], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 18], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_FREQ_COARSE], DEC); Serial.print(F(" ")); - Serial.print(dexed->data[(i * 21) + 19], DEC); + Serial.print(dexed->data[(i * 21) + DEXED_OP_FREQ_FINE], DEC); Serial.print(F(" ")); - Serial.println(dexed->data[(i * 21) + 20], DEC); + Serial.println(dexed->data[(i * 21) + DEXED_OP_OSC_DETUNE], DEC); } Serial.println(F("PR1|PR2|PR3|PR4|PL1|PL2|PL3|PL4")); Serial.print(F(" ")); for (i = 0; i < 8; i++) { - Serial.print(dexed->data[125 + i], DEC); + Serial.print(dexed->data[DEXED_VOICE_OFFSET + i], DEC); Serial.print(F(" ")); } Serial.println(); Serial.print(F("ALG: ")); - Serial.println(dexed->data[134], DEC); + Serial.println(dexed->data[DEXED_VOICE_OFFSET + DEXED_ALGORITHM], DEC); Serial.print(F("FB: ")); - Serial.println(dexed->data[135], DEC); + Serial.println(dexed->data[DEXED_VOICE_OFFSET + DEXED_FEEDBACK], DEC); Serial.print(F("OKS: ")); - Serial.println(dexed->data[136], DEC); + Serial.println(dexed->data[DEXED_VOICE_OFFSET + DEXED_OSC_KEY_SYNC], DEC); Serial.print(F("LFO SPD: ")); - Serial.println(dexed->data[137], DEC); + Serial.println(dexed->data[DEXED_VOICE_OFFSET + DEXED_LFO_SPEED], DEC); Serial.print(F("LFO_DLY: ")); - Serial.println(dexed->data[138], DEC); + Serial.println(dexed->data[DEXED_VOICE_OFFSET + DEXED_LFO_DELAY], DEC); Serial.print(F("LFO PMD: ")); - Serial.println(dexed->data[139], DEC); + Serial.println(dexed->data[DEXED_VOICE_OFFSET + DEXED_LFO_PITCH_MOD_DEP], DEC); Serial.print(F("LFO_AMD: ")); - Serial.println(dexed->data[140], DEC); + Serial.println(dexed->data[DEXED_VOICE_OFFSET + DEXED_LFO_AMP_MOD_DEP], DEC); Serial.print(F("LFO_SYNC: ")); - Serial.println(dexed->data[141], DEC); + Serial.println(dexed->data[DEXED_VOICE_OFFSET + DEXED_LFO_SYNC], DEC); Serial.print(F("LFO_WAVEFRM: ")); - Serial.println(dexed->data[142], DEC); + Serial.println(dexed->data[DEXED_VOICE_OFFSET + DEXED_LFO_WAVE], DEC); Serial.print(F("LFO_PMS: ")); - Serial.println(dexed->data[143], DEC); + Serial.println(dexed->data[DEXED_VOICE_OFFSET + DEXED_LFO_PITCH_MOD_SENS], DEC); Serial.print(F("TRNSPSE: ")); - Serial.println(dexed->data[144], DEC); + Serial.println(dexed->data[DEXED_VOICE_OFFSET + DEXED_TRANSPOSE], DEC); Serial.print(F("NAME: ")); - strncpy(voicename, (char *)&dexed->data[144], sizeof(voicename) - 1); + strncpy(voicename, (char *)&dexed->data[DEXED_VOICE_OFFSET + DEXED_NAME], sizeof(voicename) - 1); Serial.print(F("[")); Serial.print(voicename); Serial.println(F("]")); - for (i = 155; i < 173; i++) + for (i = DEXED_VOICE_OFFSET + DEXED_NAME; i < DEXED_VOICE_OFFSET + DEXED_NAME + 10 ; i++) { Serial.print(i, DEC); Serial.print(F(": ")); diff --git a/config.h b/config.h index c5e36e9..58c9d8c 100644 --- a/config.h +++ b/config.h @@ -10,7 +10,7 @@ #define TEST_VEL_MIN 60 #define TEST_VEL_MAX 110 -//#define DEBUG 1 +#define DEBUG 1 #define SERIAL_SPEED 38400 #define VOLUME 0.1 #define SAMPLE_RATE 44100 diff --git a/dexed.h b/dexed.h index 537fc5e..c69e2e2 100644 --- a/dexed.h +++ b/dexed.h @@ -1,26 +1,26 @@ /* - * MicroDexed - * - * MicroDexed is a port of the Dexed sound engine - * (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6 with audio shield - * - * (c)2018 H. Wirtz - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ + MicroDexed + + MicroDexed is a port of the Dexed sound engine + (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6 with audio shield + + (c)2018 H. Wirtz + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ #ifndef DEXED_H_INCLUDED #define DEXED_H_INCLUDED @@ -44,9 +44,79 @@ struct ProcessorVoice { }; enum DexedEngineResolution { - DEXED_ENGINE_MODERN, // 0 - DEXED_ENGINE_MARKI, // 1 - DEXED_ENGINE_OPL // 2 + DEXED_ENGINE_MODERN, // 0 + DEXED_ENGINE_MARKI, // 1 + DEXED_ENGINE_OPL // 2 +}; + +enum DexedVoiceOPParameters { + DEXED_OP_EG_R1, // 0 + DEXED_OP_EG_R2, // 1 + DEXED_OP_EG_R3, // 2 + DEXED_OP_EG_R4, // 3 + DEXED_OP_EG_L1, // 4 + DEXED_OP_EG_L2, // 5 + DEXED_OP_EG_L3, // 6 + DEXED_OP_EG_L4, // 7 + DEXED_OP_LEV_SCL_BRK_PT, // 8 + DEXED_OP_SCL_LEFT_DEPTH, // 9 + DEXED_OP_SCL_RGHT_DEPTH, // 10 + DEXED_OP_SCL_LEFT_CURVE, // 11 + DEXED_OP_SCL_RGHT_CURVE, // 12 + DEXED_OP_OSC_RATE_SCALE, // 13 + DEXED_OP_AMP_MOD_SENS, // 14 + DEXED_OP_KEY_VEL_SENS, // 15 + DEXED_OP_OUTPUT_LEV, // 16 + DEXED_OP_OSC_MODE, // 17 + DEXED_OP_FREQ_COARSE, // 18 + DEXED_OP_FREQ_FINE, // 19 + DEXED_OP_OSC_DETUNE // 20 +}; + +#define DEXED_VOICE_OFFSET 126 +enum DexedVoiceParameters { + DEXED_PITCH_EG_R1, // 0 + DEXED_PITCH_EG_R2, // 1 + DEXED_PITCH_EG_R3, // 2 + DEXED_PITCH_EG_R4, // 3 + DEXED_PITCH_EG_L1, // 4 + DEXED_PITCH_EG_L2, // 5 + DEXED_PITCH_EG_L3, // 6 + DEXED_PITCH_EG_L4, // 7 + DEXED_ALGORITHM, // 8 + DEXED_FEEDBACK, // 9 + DEXED_OSC_KEY_SYNC, // 10 + DEXED_LFO_SPEED, // 11 + DEXED_LFO_DELAY, // 12 + DEXED_LFO_PITCH_MOD_DEP, // 13 + DEXED_LFO_AMP_MOD_DEP, // 14 + DEXED_LFO_SYNC, // 15 + DEXED_LFO_WAVE, // 16 + DEXED_LFO_PITCH_MOD_SENS, // 17 + DEXED_TRANSPOSE, // 18 + DEXED_NAME // 19 +}; + +#define DEXED_GLOBAL_PARAMETER_OFFSET 155 +enum DexedGlobalParameters { + DEXED_PITCHBEND_RANGE, // 0 + DEXED_PITCHBEND_STEP, // 1 + DEXED_MODWHEEL_RANGE, // 2 + DEXED_MODWHEEL_ASSIGN, // 3 + DEXED_FOOTCTRL_RANGE, // 4 + DEXED_FOOTCTRL_ASSIGN, // 5 + DEXED_BREATHCTRL_RANGE, // 6 + DEXED_BREATHCTRL_ASSIGN, // 7 + DEXED_AT_RANGE, // 8 + DEXED_AT_ASSIGN, // 9 + DEXED_MASTER_TUNE, // 10 + DEXED_OP1_ENABLE, // 11 + DEXED_OP2_ENABLE, // 12 + DEXED_OP3_ENABLE, // 13 + DEXED_OP4_ENABLE, // 14 + DEXED_OP5_ENABLE, // 15 + DEXED_OP6_ENABLE, // 16 + DEXED_MAX_NOTES // 17 }; // GLOBALS @@ -71,11 +141,11 @@ class Dexed void setMaxNotes(uint8_t n); void doRefreshVoice(void); void setOPs(uint8_t ops); - + Controllers controllers; uint8_t data[173] = { - 95, 29, 20, 50, 99, 95, 00, 00, 41, 00, 19, 00, 00, 03, 00, 06, 79, 00, 01, 00, 14, // OP6 eg_rate_1-4, level_1-4, kbd_lev_scl_brk_pt, kbd_lev_scl_lft_depth, kbd_lev_scl_rht_depth, kbd_lev_scl_lft_curve, kbd_lev_scl_rht_curve, kbd_rate_scaling, amp_mod_sensitivity, key_vel_sensitivity, operator_output_level, osc_mode, osc_freq_coarse, osc_freq_fine, osc_detune + 95, 29, 20, 50, 99, 95, 00, 00, 41, 00, 19, 00, 00, 03, 00, 06, 79, 00, 01, 00, 14, // OP6 eg_rate_1-4, level_1-4, kbd_lev_scl_brk_pt, kbd_lev_scl_lft_depth, kbd_lev_scl_rht_depth, kbd_lev_scl_lft_curve, kbd_lev_scl_rht_curve, kbd_rate_scaling, amp_mod_sensitivity, key_vel_sensitivity, operator_output_level, osc_mode, osc_freq_coarse, osc_freq_fine, osc_detune 95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 00, 99, 00, 01, 00, 00, // OP5 95, 29, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 06, 89, 00, 01, 00, 07, // OP4 95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 02, 99, 00, 01, 00, 07, // OP3 @@ -91,7 +161,7 @@ class Dexed 01, 01, 01, 01, 01, 01, // OP1-6 enable 16 // number of voices }; // FM-Piano - + protected: //void onParam(uint8_t param_num,float param_val); void keyup(uint8_t pitch); diff --git a/dexed_sysex.cpp b/dexed_sysex.cpp index 67de995..bb2de2c 100644 --- a/dexed_sysex.cpp +++ b/dexed_sysex.cpp @@ -1,26 +1,26 @@ /* - * MicroDexed - * - * MicroDexed is a port of the Dexed sound engine - * (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6 with audio shield - * - * (c)2018 H. Wirtz - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ + MicroDexed + + MicroDexed is a port of the Dexed sound engine + (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6 with audio shield + + (c)2018 H. Wirtz + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ #include #include @@ -68,64 +68,92 @@ bool load_sysex_voice(File sysex, uint8_t voice_number) if (file = SD.open(sysex.name())) { uint8_t* p_data = dexed->data; - uint8_t i; + uint8_t op; uint8_t tmp; dexed->notes_off(); file.seek(6 + (voice_number * 128)); - for (i = 0; i < 6; i++) + for (op = 0; op < 6; op++) { - file.read(p_data + (i * 21), 11); // R1, R2, R3, R4, L1, L2, L3, L4, LEV SCL BRK PT, SCL LEFT DEPTH, SCL RGHT DEPTH + // DEXED_OP_EG_R1, // 0 + // DEXED_OP_EG_R2, // 1 + // DEXED_OP_EG_R3, // 2 + // DEXED_OP_EG_R4, // 3 + // DEXED_OP_EG_L1, // 4 + // DEXED_OP_EG_L2, // 5 + // DEXED_OP_EG_L3, // 6 + // DEXED_OP_EG_L4, // 7 + // DEXED_OP_LEV_SCL_BRK_PT, // 8 + // DEXED_OP_SCL_LEFT_DEPTH, // 9 + // DEXED_OP_SCL_RGHT_DEPTH, // 10 + file.read(p_data + (op * 21) + DEXED_OP_EG_R1, 11); tmp = file.read(); - *(p_data + 11 + (i * 21)) = (tmp & 0x3); // SCL LEFT CURVE - *(p_data + 12 + (i * 21)) = (tmp & 0x0c) >> 2; // SCL RGHT CURVE + *(p_data + DEXED_OP_SCL_LEFT_CURVE + (op * 21)) = (tmp & 0x3); + *(p_data + DEXED_OP_SCL_RGHT_CURVE + (op * 21)) = (tmp & 0x0c) >> 2; tmp = file.read(); - *(p_data + 20 + (i * 21)) = (tmp & 0x78) >> 3; // DETUNE - *(p_data + 13 + (i * 21)) = (tmp & 0x07); // RS + *(p_data + DEXED_OP_OSC_DETUNE + (op * 21)) = (tmp & 0x78) >> 3; + *(p_data + DEXED_OP_OSC_RATE_SCALE + (op * 21)) = (tmp & 0x07); tmp = file.read(); - *(p_data + 15 + (i * 21)) = (tmp & 0x1c) >> 2; // KVS - *(p_data + 14 + (i * 21)) = (tmp & 0x03); // AMS - *(p_data + 16 + (i * 21)) = file.read(); // OUTPUT LVL + *(p_data + DEXED_OP_KEY_VEL_SENS + (op * 21)) = (tmp & 0x1c) >> 2; + *(p_data + DEXED_OP_AMP_MOD_SENS + (op * 21)) = (tmp & 0x03); + *(p_data + DEXED_OP_OUTPUT_LEV + (op * 21)) = file.read(); tmp = file.read(); - *(p_data + 18 + (i * 21)) = (tmp & 0x3e) >> 1; // FREQ_CORSE - *(p_data + 17 + (i * 21)) = (tmp & 0x01); // OP MODE - file.read(p_data + 19 + (i * 21), 1); // FREQ FINE + *(p_data + DEXED_OP_FREQ_COARSE + (op * 21)) = (tmp & 0x3e) >> 1; + *(p_data + DEXED_OP_OSC_MODE + (op * 21)) = (tmp & 0x01); + file.read(p_data + DEXED_OP_FREQ_FINE + (op * 21), 1); } - file.read(p_data + 125, 8); // PR1, PR2, PR3, PR4, PL1, PL2, PL3, PL4 + // DEXED_PITCH_EG_R1, // 0 + // DEXED_PITCH_EG_R2, // 1 + // DEXED_PITCH_EG_R3, // 2 + // DEXED_PITCH_EG_R4, // 3 + // DEXED_PITCH_EG_L1, // 4 + // DEXED_PITCH_EG_L2, // 5 + // DEXED_PITCH_EG_L3, // 6 + // DEXED_PITCH_EG_L4, // 7 + file.read(p_data + DEXED_VOICE_OFFSET + DEXED_PITCH_EG_R1, 8); tmp = file.read(); - *(p_data + 134) = (tmp & 0x1f); // ALG + *(p_data + DEXED_VOICE_OFFSET + DEXED_ALGORITHM) = (tmp & 0x1f); tmp = file.read(); - *(p_data + 136) = (tmp & 0x08) >> 3; // OKS - *(p_data + 135) = (tmp & 0x07); // FB - file.read(p_data + 137, 4); // LFS, LFD, LPMD, LAMD + *(p_data + DEXED_VOICE_OFFSET + DEXED_OSC_KEY_SYNC) = (tmp & 0x08) >> 3; + *(p_data + DEXED_VOICE_OFFSET + DEXED_FEEDBACK) = (tmp & 0x07); + // DEXED_LFO_SPEED, // 11 + // DEXED_LFO_DELAY, // 12 + // DEXED_LFO_PITCH_MOD_DEP, // 13 + // DEXED_LFO_AMP_MOD_DEP, // 14 + file.read(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_SPEED, 4); tmp = file.read(); - *(p_data + 143) = (tmp & 0x30) >> 4; // LFO PITCH MOD SENS - *(p_data + 142) = (tmp & 0x0e) >> 1; // LFO WAV - *(p_data + 141) = (tmp & 0x01); // LFO SYNC - file.read(p_data + 144, 1); // TRNSP - file.read(p_data + 145, 10); // NAME - *(p_data + 155) = 1; // PBEND RANGE - *(p_data + 156) = 0; // PBEND STEP - *(p_data + 157) = 99; // MOD RANGE - *(p_data + 158) = 0; // MOD ASSIGN - *(p_data + 159) = 99; // FOOT CTRL RANGE - *(p_data + 160) = 0; // FOOT CTRL ASSIGN - *(p_data + 161) = 99; // BREATH CTRL RANGE - *(p_data + 162) = 0; // BREATH CTRL ASSIGN - *(p_data + 163) = 99; // AT RANGE - *(p_data + 164) = 0; // AT ASSIGN - *(p_data + 165) = 0; // MASTER TUNE - *(p_data + 166) = 1; // OP1 ENABLE - *(p_data + 167) = 1; // OP2 ENABLE - *(p_data + 168) = 1; // OP3 ENABLE - *(p_data + 169) = 1; // OP4 ENABLE - *(p_data + 170) = 1; // OP5 ENABLE - *(p_data + 171) = 1; // OP6 ENABLE - *(p_data + 172) = MAX_NOTES; - - dexed->setOPs((*(p_data + 166) << 5) | (*(p_data + 167) << 4) | (*(p_data + 168) << 3) | (*(p_data + 166) << 2) | (*(p_data + 170) << 1) | *(p_data + 171)); - dexed->setMaxNotes(*(p_data + 172)); + *(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_PITCH_MOD_SENS) = (tmp & 0x30) >> 4; + *(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_WAVE) = (tmp & 0x0e) >> 1; + *(p_data + DEXED_VOICE_OFFSET + DEXED_LFO_SYNC) = (tmp & 0x01); + file.read(p_data + DEXED_VOICE_OFFSET + DEXED_TRANSPOSE, 1); + file.read(p_data + DEXED_VOICE_OFFSET + DEXED_NAME, 10); + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_RANGE) = 1; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_PITCHBEND_STEP) = 0; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_RANGE) = 99; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MODWHEEL_ASSIGN) = 0; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_RANGE) = 99; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_FOOTCTRL_ASSIGN) = 0; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_RANGE) = 99; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_BREATHCTRL_ASSIGN) = 0; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_RANGE) = 99; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_AT_ASSIGN) = 0; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MASTER_TUNE) = 0; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP1_ENABLE) = 1; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP2_ENABLE) = 1; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP3_ENABLE) = 1; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP4_ENABLE) = 1; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP5_ENABLE) = 1; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP6_ENABLE) = 1; + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MAX_NOTES) = MAX_NOTES; + + dexed->setOPs((*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP1_ENABLE) << 5) | + (*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP2_ENABLE) << 4) | + (*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP3_ENABLE) << 3) | + (*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP4_ENABLE) << 2) | + (*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP5_ENABLE) << 1) | + *(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_OP6_ENABLE )); + dexed->setMaxNotes(*(p_data + DEXED_GLOBAL_PARAMETER_OFFSET + DEXED_MAX_NOTES)); dexed->doRefreshVoice(); dexed->activate();