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.

79 lines
2.2KB

  1. /*
  2. * Copyright 2016-2017 Pascal Gauthier.
  3. * Copyright 2012 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. #ifndef SYNTH_DX7NOTE_H_
  18. #define SYNTH_DX7NOTE_H_
  19. // This is the logic to put together a note from the MIDI description
  20. // and run the low-level modules.
  21. // It will continue to evolve a bit, as note-stealing logic, scaling,
  22. // and real-time control of parameters live here.
  23. #include <Arduino.h>
  24. #include "env.h"
  25. #include "pitchenv.h"
  26. #include "fm_core.h"
  27. struct VoiceStatus {
  28. uint32_t amp[6];
  29. char ampStep[6];
  30. char pitchStep;
  31. };
  32. class Dx7Note {
  33. public:
  34. Dx7Note();
  35. void init(const uint8_t patch[156], int midinote, int velocity);
  36. // Note: this _adds_ to the buffer. Interesting question whether it's
  37. // worth it...
  38. void compute(int32_t *buf, int32_t lfo_val, int32_t lfo_delay,
  39. const Controllers *ctrls);
  40. void keyup();
  41. // TODO: some way of indicating end-of-note. Maybe should be a return
  42. // value from the compute method? (Having a count return from keyup
  43. // is also tempting, but if there's a dynamic parameter change after
  44. // keyup, that won't work.
  45. // PG:add the update
  46. void update(const uint8_t patch[156], int midinote, int velocity);
  47. void peekVoiceStatus(VoiceStatus &status);
  48. void transferState(Dx7Note& src);
  49. void transferSignal(Dx7Note &src);
  50. void oscSync();
  51. private:
  52. Env env_[6];
  53. FmOpParams params_[6];
  54. PitchEnv pitchenv_;
  55. int32_t basepitch_[6];
  56. int32_t fb_buf_[2];
  57. int32_t fb_shift_;
  58. int32_t ampmodsens_[6];
  59. int32_t opMode[6];
  60. int ampmoddepth_;
  61. int algorithm_;
  62. int pitchmoddepth_;
  63. int pitchmodsens_;
  64. };
  65. #endif // SYNTH_DX7NOTE_H_