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.3KB

  1. /*
  2. * Copyright 2013 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 __PITCHENV_H
  17. #define __PITCHENV_H
  18. // Computation of the DX7 pitch envelope
  19. class PitchEnv {
  20. public:
  21. static void init(FRAC_NUM sample_rate);
  22. // The rates and levels arrays are calibrated to match the Dx7 parameters
  23. // (ie, value 0..99).
  24. void set(const int rates[4], const int levels[4]);
  25. // Result is in Q24/octave
  26. int32_t getsample();
  27. void keydown(bool down);
  28. void getPosition(char *step);
  29. private:
  30. static int unit_;
  31. int rates_[4];
  32. int levels_[4];
  33. int32_t level_;
  34. int targetlevel_;
  35. bool rising_;
  36. int ix_;
  37. int inc_;
  38. bool down_;
  39. void advance(int newix);
  40. };
  41. extern const uint8_t pitchenv_rate[];
  42. extern const int8_t pitchenv_tab[];
  43. #endif // __PITCHENV_H