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.

54 lines
1.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 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. // Idea from: https://playground.arduino.cc/Code/EEPROMWriteAnything/
  20. #include <EEPROM.h>
  21. #include <Arduino.h> // for type definitions
  22. uint32_t crc32(uint8_t* calc_start, uint16_t calc_bytes);
  23. template <class T> int EEPROM_writeAnything(int ee, const T& value)
  24. {
  25. uint8_t* p = (uint8_t*)(const void*)&value;
  26. uint16_t i;
  27. uint32_t checksum=crc32(p+4,sizeof(value)-4);
  28. *p=checksum;
  29. for (i = 0; i < sizeof(value); i++)
  30. EEPROM.update(ee++, *p++);
  31. return i;
  32. }
  33. template <class T> int EEPROM_readAnything(int ee, T& value)
  34. {
  35. uint8_t* p = (uint8_t*)(void*)&value;
  36. unsigned int i;
  37. for (i = 0; i < sizeof(value); i++)
  38. *p++ = EEPROM.read(ee++);
  39. return i;
  40. }