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.

81 lines
2.4KB

  1. // Copyright 2014 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. // Lorenz system.
  28. #ifndef STREAMS_LORENZ_GENERATOR_H_
  29. #define STREAMS_LORENZ_GENERATOR_H_
  30. #include "stmlib/stmlib.h"
  31. #include "streams/meta_parameters.h"
  32. namespace streams {
  33. class LorenzGenerator {
  34. public:
  35. LorenzGenerator() { }
  36. ~LorenzGenerator() { }
  37. void Init();
  38. void Process(
  39. int16_t audio,
  40. int16_t excite,
  41. uint16_t* gain,
  42. uint16_t* frequency);
  43. void set_index(uint8_t index) {
  44. index_ = index;
  45. }
  46. void Configure(bool alternate, int32_t* parameters, int32_t* globals) {
  47. rate_ = parameters[0] >> 8;
  48. int32_t vcf_amount = 65535 - parameters[1];
  49. int32_t vca_amount = parameters[1];
  50. if (vcf_amount >= 32767) vcf_amount = 32767;
  51. if (vca_amount >= 32767) vca_amount = 32767;
  52. target_vcf_amount_ = vcf_amount;
  53. target_vca_amount_ = vca_amount;
  54. }
  55. private:
  56. int32_t x_, y_, z_;
  57. int32_t rate_;
  58. int32_t vcf_amount_;
  59. int32_t vca_amount_;
  60. int32_t target_vcf_amount_;
  61. int32_t target_vca_amount_;
  62. uint8_t index_;
  63. DISALLOW_COPY_AND_ASSIGN(LorenzGenerator);
  64. };
  65. } // namespace streams
  66. #endif // STREAMS_LORENZ_GENERATOR_H_