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.

73 lines
1.8KB

  1. /*
  2. * Copyright 2012 Google Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef __SYNTH_H
  17. #define __SYNTH_H
  18. //#include <Arduino.h>
  19. //#define SUPER_PRECISE
  20. #include <Audio.h>
  21. // This IS not be present on MSVC.
  22. // See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio
  23. #include <stdint.h>
  24. #ifdef _MSC_VER
  25. typedef __int32 int32_t;
  26. typedef unsigned __int32 uint32_t;
  27. typedef __int16 SInt16;
  28. #endif
  29. #define LG_N 6
  30. #define _N_ (1 << LG_N)
  31. #if defined(__APPLE__)
  32. #include <libkern/OSAtomic.h>
  33. #define SynthMemoryBarrier() OSMemoryBarrier()
  34. #elif defined(__GNUC__)
  35. #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
  36. #define SynthMemoryBarrier() __sync_synchronize()
  37. #endif
  38. #endif
  39. // #undef SynthMemoryBarrier()
  40. #ifndef SynthMemoryBarrier
  41. // need to understand why this must be defined
  42. // #warning Memory barrier is not enabled
  43. #define SynthMemoryBarrier()
  44. #endif
  45. template<typename T>
  46. inline static T min(const T& a, const T& b) {
  47. return a < b ? a : b;
  48. }
  49. template<typename T>
  50. inline static T max(const T& a, const T& b) {
  51. return a > b ? a : b;
  52. }
  53. #define QER(n,b) ( ((float)n)/(1<<b) )
  54. #define FRAC_NUM float
  55. #define SIN_FUNC sinf
  56. #define COS_FUNC cosf
  57. #define LOG_FUNC logf
  58. #define EXP_FUNC expf
  59. #endif // __SYNTH_H