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.

48 lines
1.6KB

  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 __FM_OP_KERNEL_H
  17. #define __FM_OP_KERNEL_H
  18. struct FmOpParams {
  19. int32_t level_in; // value to be computed (from level to gain[0])
  20. int32_t gain_out; // computed value (gain[1] to gain[0])
  21. int32_t freq;
  22. int32_t phase;
  23. };
  24. class FmOpKernel {
  25. public:
  26. // gain1 and gain2 represent linear step: gain for sample i is
  27. // gain1 + (1 + i) / 64 * (gain2 - gain1)
  28. // This is the basic FM operator. No feedback.
  29. static void compute(int32_t *output, const int32_t *input,
  30. int32_t phase0, int32_t freq,
  31. int32_t gain1, int32_t gain2, bool add);
  32. // This is a sine generator, no feedback.
  33. static void compute_pure(int32_t *output, int32_t phase0, int32_t freq,
  34. int32_t gain1, int32_t gain2, bool add);
  35. // One op with feedback, no add.
  36. static void compute_fb(int32_t *output, int32_t phase0, int32_t freq,
  37. int32_t gain1, int32_t gain2,
  38. int32_t *fb_buf, int fb_gain, bool add);
  39. };
  40. #endif