MicroDexed is a compatible 6-operator-FM-synth based on the Teensy(-3.6/-4.0) Microcontroller. https://www.parasitstudio.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

213 lines
6.7KB

  1. /*
  2. MicroDexed
  3. MicroDexed is a port of the Dexed sound engine
  4. (https://github.com/asb2m10/dexed) for the Teensy-3.5/3.6 with audio shield.
  5. Dexed ist heavily based on https://github.com/google/music-synthesizer-for-android
  6. (c)2018,2019 H. Wirtz <wirtz@parasitstudio.de>
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 3 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software Foundation,
  17. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #ifndef CONFIG_H_INCLUDED
  20. #define CONFIG_H_INCLUDED
  21. #include "midinotes.h"
  22. // ATTENTION! For better latency you have to redefine AUDIO_BLOCK_SAMPLES from
  23. // 128 to 64 in <ARDUINO-IDE-DIR>/cores/teensy3/AudioStream.h
  24. // If you want to test the system with Linux and withous any keyboard and/or audio equipment, you can do the following:
  25. // 1. In Arduino-IDE enable "Tools->USB-Type->Serial + MIDI + Audio"
  26. // 2. Build the firmware with "MIDI_DEVICE_USB" enabled in config.h.
  27. // 3. Afterconnecting to a Linux system there should be a MIDI an audio device available that is called "MicroMDAEPiano", so you can start the following:
  28. // $ aplaymidi -p 20:0 <MIDI-File> # e.g. test.mid
  29. // $ arecord -f cd -Dhw:1,0 /tmp/bla.wav
  30. #define VERSION "0.9.5a"
  31. //*************************************************************************************************
  32. //* DEVICE SETTINGS
  33. //*************************************************************************************************
  34. // MIDI
  35. #define MIDI_DEVICE_DIN Serial1
  36. #define MIDI_DEVICE_USB 1
  37. #define MIDI_DEVICE_USB_HOST 1
  38. #define MIDI_DEVICE_NUMBER 0
  39. // AUDIO
  40. // If nothing is defined Teensy internal DAC is used as audio output device!
  41. // Left and right channel audio signal is presented on pins A21 and A22.
  42. // #define TEENSY_DAC
  43. #define TEENSY_AUDIO_BOARD 1
  44. // #define TGA_AUDIO_BOARD
  45. //*************************************************************************************************
  46. //* MIDI SETTINGS
  47. //*************************************************************************************************
  48. #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI
  49. #define MIDI_MERGE_THRU 1
  50. #define DEFAULT_SYSEXBANK 0
  51. #define DEFAULT_SYSEXSOUND 0
  52. //*************************************************************************************************
  53. //* DEXED AND EFECTS SETTINGS
  54. //*************************************************************************************************
  55. #define DEXED_ENGINE DEXED_ENGINE_MODERN // DEXED_ENGINE_MARKI // DEXED_ENGINE_OPL
  56. // EFFECTS
  57. #define FILTER_MAX_FREQ 10000
  58. //*************************************************************************************************
  59. //* AUDIO SETTINGS
  60. //*************************************************************************************************
  61. // https://rechneronline.de/funktionsgraphen/
  62. #define VOLUME 0.8
  63. #define VOLUME_CURVE 0.07
  64. #ifndef TEENSY_AUDIO_BOARD
  65. #if AUDIO_BLOCK_SAMPLES == 64
  66. #define AUDIO_MEM 450
  67. #else
  68. #define AUDIO_MEM 225
  69. #endif
  70. #define DELAY_MAX_TIME 600.0
  71. #define REDUCE_LOUDNESS 1
  72. #else
  73. #if AUDIO_BLOCK_SAMPLES == 64
  74. #define AUDIO_MEM 900
  75. #else
  76. #define AUDIO_MEM 450
  77. #endif
  78. #define DELAY_MAX_TIME 1200.0
  79. #define REDUCE_LOUDNESS 1
  80. #endif
  81. #define SAMPLE_RATE 44100
  82. #define SOFTEN_VALUE_CHANGE_STEPS 20
  83. #define NORMALIZE_DX_VELOCITY 1
  84. //*************************************************************************************************
  85. //* UI AND DATA-STORE SETTINGS
  86. //*************************************************************************************************
  87. #define CONTROL_RATE_MS 50
  88. #define TIMER_UI_HANDLING_MS 100
  89. //*************************************************************************************************
  90. //* DEBUG OUTPUT SETTINGS
  91. //*************************************************************************************************
  92. #define DEBUG 1
  93. #define SERIAL_SPEED 38400
  94. #define SHOW_XRUN 1
  95. #define SHOW_CPU_LOAD_MSEC 5000
  96. //*************************************************************************************************
  97. //* HARDWARE SETTINGS
  98. //*************************************************************************************************
  99. // Teensy Audio Shield:
  100. //#define SDCARD_CS_PIN 10
  101. //#define SDCARD_MOSI_PIN 7
  102. //#define SDCARD_SCK_PIN 14
  103. #define SGTL5000_LINEOUT_LEVEL 29
  104. // Teensy 3.5 & 3.6 SD card
  105. #define SDCARD_CS_PIN 4 //BUILTIN_SDCARD
  106. #define SDCARD_MOSI_PIN 11 // not actually used
  107. #define SDCARD_SCK_PIN 13 // not actually used
  108. // Encoder with button
  109. #define ENC_VOL_STEPS 43
  110. #define ENC_FILTER_RES_STEPS 100
  111. #define ENC_FILTER_CUT_STEPS 100
  112. #define ENC_DELAY_TIME_STEPS 50
  113. #define ENC_DELAY_FB_STEPS 35
  114. #define ENC_DELAY_VOLUME_STEPS 50
  115. #define NUM_ENCODER 2
  116. #define ENC_L_PIN_A 3
  117. #define ENC_L_PIN_B 2
  118. #define BUT_L_PIN 4
  119. #define INITIAL_ENC_L_VALUE 0
  120. #define ENC_R_PIN_A 28
  121. #define ENC_R_PIN_B 29
  122. #define BUT_R_PIN 30
  123. #define INITIAL_ENC_R_VALUE 0
  124. #define BUT_DEBOUNCE_MS 20
  125. #define LONG_BUTTON_PRESS 500
  126. // LCD Display
  127. #define I2C_DISPLAY 1
  128. // [I2C] SCL: Pin 19, SDA: Pin 18 (https://www.pjrc.com/teensy/td_libs_Wire.html)
  129. #define LCD_I2C_ADDRESS 0x27
  130. #define LCD_CHARS 16
  131. #define LCD_LINES 2
  132. #define UI_AUTO_BACK_MS 3000
  133. #define AUTOSTORE_MS 5000
  134. #define AUTOSTORE_FAST_MS 50
  135. // EEPROM address
  136. #define EEPROM_START_ADDRESS 0
  137. #define MAX_BANKS 100
  138. #define MAX_VOICES 32 // voices per bank
  139. #define BANK_NAME_LEN 13 // FAT12 filenames (plus '\0')
  140. #define VOICE_NAME_LEN 11 // 10 (plus '\0')
  141. //*************************************************************************************************
  142. //* DO NO CHANGE ANYTHING BEYOND IF YOU DON'T KNOW WHAT YOU ARE DOING !!!
  143. //*************************************************************************************************
  144. // MIDI
  145. #ifdef MIDI_DEVICE_USB
  146. #define USBCON 1
  147. #endif
  148. #if defined(__MK66FX1M0__) // Teensy-3.6
  149. // Teensy-3.6 settings
  150. #define MIDI_DEVICE_USB_HOST 1
  151. #define MAX_NOTES 16
  152. #else
  153. // Teensy-3.5 settings
  154. #undef MIDI_DEVICE_USB_HOST
  155. #define MAX_NOTES 11
  156. #endif
  157. #define TRANSPOSE_FIX 24
  158. // Audio
  159. #ifdef TGA_AUDIO_BOARD
  160. #define REDUCE_LOUDNESS 2
  161. #endif
  162. // Some optimizations
  163. #define USE_TEENSY_DSP 1
  164. #define SUM_UP_AS_INT 1
  165. // struct for holding the current configuration
  166. struct config_t {
  167. uint32_t checksum;
  168. uint8_t bank;
  169. uint8_t voice;
  170. float vol;
  171. float pan;
  172. uint8_t midi_channel;
  173. };
  174. // struct for smoothing value changes
  175. struct value_change_t {
  176. float diff;
  177. uint16_t steps;
  178. };
  179. #endif // CONFIG_H_INCLUDED