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.

103 lines
3.2KB

  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_BUFFERED_PROCESSOR(ClassName) \
  34. { &Processors::ClassName ## Init, \
  35. NULL, \
  36. &Processors::ClassName ## FillBuffer, \
  37. &Processors::ClassName ## Configure },
  38. #define REGISTER_UNBUFFERED_PROCESSOR(ClassName) \
  39. { &Processors::ClassName ## Init, \
  40. &Processors::ClassName ## ProcessSingleSample, \
  41. NULL, \
  42. &Processors::ClassName ## Configure },
  43. /* static */
  44. const Processors::ProcessorCallbacks
  45. Processors::callbacks_table_[PROCESSOR_FUNCTION_LAST] = {
  46. REGISTER_UNBUFFERED_PROCESSOR(MultistageEnvelope)
  47. REGISTER_BUFFERED_PROCESSOR(Lfo)
  48. REGISTER_BUFFERED_PROCESSOR(Lfo)
  49. REGISTER_UNBUFFERED_PROCESSOR(BassDrum)
  50. REGISTER_UNBUFFERED_PROCESSOR(SnareDrum)
  51. REGISTER_UNBUFFERED_PROCESSOR(HighHat)
  52. REGISTER_BUFFERED_PROCESSOR(FmDrum)
  53. REGISTER_BUFFERED_PROCESSOR(PulseShaper)
  54. REGISTER_BUFFERED_PROCESSOR(PulseRandomizer)
  55. REGISTER_UNBUFFERED_PROCESSOR(BouncingBall)
  56. REGISTER_UNBUFFERED_PROCESSOR(MiniSequencer)
  57. REGISTER_BUFFERED_PROCESSOR(NumberStation)
  58. };
  59. void Processors::Init(uint8_t index) {
  60. input_buffer_.Init();
  61. output_buffer_.Init();
  62. for (uint16_t i = 0; i < kBlockSize; ++i) {
  63. output_buffer_.Overwrite(0);
  64. input_buffer_.Overwrite(0);
  65. }
  66. for (uint16_t i = 0; i < PROCESSOR_FUNCTION_LAST; ++i) {
  67. (this->*callbacks_table_[i].init_fn)();
  68. }
  69. bass_drum_.Init();
  70. snare_drum_.Init();
  71. fm_drum_.Init();
  72. fm_drum_.set_sd_range(index == 1);
  73. high_hat_.Init();
  74. bouncing_ball_.Init();
  75. lfo_.Init();
  76. envelope_.Init();
  77. pulse_shaper_.Init();
  78. pulse_randomizer_.Init();
  79. mini_sequencer_.Init();
  80. number_station_.Init();
  81. number_station_.set_voice(index == 1);
  82. control_mode_ = CONTROL_MODE_FULL;
  83. set_function(PROCESSOR_FUNCTION_ENVELOPE);
  84. std::fill(&parameter_[0], &parameter_[4], 32768);
  85. }
  86. /* extern */
  87. Processors processors[2];
  88. } // namespace peaks