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.

88 lines
2.7KB

  1. // Copyright 2013 Olivier Gillet.
  2. //
  3. // Author: Olivier Gillet (ol.gillet@gmail.com)
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. // See http://creativecommons.org/licenses/MIT/ for more information.
  24. //
  25. // -----------------------------------------------------------------------------
  26. //
  27. // LFO.
  28. #include "peaks/processors.h"
  29. #include <algorithm>
  30. namespace peaks {
  31. using namespace stmlib;
  32. using namespace std;
  33. #define REGISTER_PROCESSOR(ClassName) \
  34. { &Processors::ClassName ## Init, \
  35. &Processors::ClassName ## Process, \
  36. &Processors::ClassName ## Configure },
  37. /* static */
  38. const Processors::ProcessorCallbacks
  39. Processors::callbacks_table_[PROCESSOR_FUNCTION_LAST] = {
  40. REGISTER_PROCESSOR(MultistageEnvelope)
  41. REGISTER_PROCESSOR(Lfo)
  42. REGISTER_PROCESSOR(Lfo)
  43. REGISTER_PROCESSOR(BassDrum)
  44. REGISTER_PROCESSOR(SnareDrum)
  45. REGISTER_PROCESSOR(HighHat)
  46. REGISTER_PROCESSOR(FmDrum)
  47. REGISTER_PROCESSOR(PulseShaper)
  48. REGISTER_PROCESSOR(PulseRandomizer)
  49. REGISTER_PROCESSOR(BouncingBall)
  50. REGISTER_PROCESSOR(MiniSequencer)
  51. REGISTER_PROCESSOR(NumberStation)
  52. };
  53. void Processors::Init(uint8_t index) {
  54. for (uint16_t i = 0; i < PROCESSOR_FUNCTION_LAST; ++i) {
  55. (this->*callbacks_table_[i].init_fn)();
  56. }
  57. bass_drum_.Init();
  58. snare_drum_.Init();
  59. fm_drum_.Init();
  60. fm_drum_.set_sd_range(index == 1);
  61. high_hat_.Init();
  62. bouncing_ball_.Init();
  63. lfo_.Init();
  64. envelope_.Init();
  65. pulse_shaper_.Init();
  66. pulse_randomizer_.Init();
  67. mini_sequencer_.Init();
  68. number_station_.Init();
  69. number_station_.set_voice(index == 1);
  70. control_mode_ = CONTROL_MODE_FULL;
  71. set_function(PROCESSOR_FUNCTION_ENVELOPE);
  72. std::fill(&parameter_[0], &parameter_[4], 32768);
  73. }
  74. /* extern */
  75. Processors processors[2];
  76. } // namespace peaks