Roessler.cc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. Roessler.cc
  3. Copyright 2002-11 Tim Goetze <tim@quitte.de>
  4. http://quitte.de/dsp/
  5. the sound of a Roessler attractor.
  6. */
  7. /*
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public License
  10. as published by the Free Software Foundation; either version 2
  11. of the License, or (at your option) any later version.
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. 02111-1307, USA or point your web browser to http://www.gnu.org.
  20. */
  21. #include <stdlib.h>
  22. #include "basics.h"
  23. #include "Roessler.h"
  24. #include "Descriptor.h"
  25. void
  26. Roessler::init()
  27. {
  28. roessler.init (h = .001, frandom());
  29. gain = 0;
  30. }
  31. template <sample_func_t F>
  32. void
  33. Roessler::one_cycle (int frames)
  34. {
  35. roessler.set_rate (getport(0));
  36. double g = (gain == getport(4)) ?
  37. 1 : pow (getport(4) / gain, 1. / (double) frames);
  38. sample_t * d = ports[5];
  39. sample_t x,
  40. sx = .043 * getport(1),
  41. sy = .051 * getport(2),
  42. sz = .018 * getport(3);
  43. for (int i = 0; i < frames; ++i)
  44. {
  45. roessler.get();
  46. x =
  47. sx * (roessler.get_x() - .515) +
  48. sy * (roessler.get_y() + 2.577) +
  49. sz * (roessler.get_z() - 2.578);
  50. F (d, i, gain * x, adding_gain);
  51. gain *= g;
  52. }
  53. gain = getport(4);
  54. }
  55. /* //////////////////////////////////////////////////////////////////////// */
  56. PortInfo
  57. Roessler::port_info [] =
  58. {
  59. {
  60. "h",
  61. INPUT | CONTROL,
  62. {BOUNDED | DEFAULT_LOW, 0, 1}
  63. }, {
  64. "x",
  65. INPUT | CONTROL,
  66. {BOUNDED | DEFAULT_1, 0, 1}
  67. }, {
  68. "y",
  69. INPUT | CONTROL,
  70. {BOUNDED | DEFAULT_MID, 0, 1}
  71. }, {
  72. "z",
  73. INPUT | CONTROL,
  74. {BOUNDED | DEFAULT_0, 0, 1}
  75. }, {
  76. "volume",
  77. INPUT | CONTROL,
  78. {BOUNDED | DEFAULT_MID, MIN_GAIN, 1}
  79. }, {
  80. "out",
  81. OUTPUT | AUDIO,
  82. {0}
  83. }
  84. };
  85. template <> void
  86. Descriptor<Roessler>::setup()
  87. {
  88. UniqueID = 1780;
  89. Label = "Roessler";
  90. Properties = HARD_RT;
  91. Name = CAPS "Roessler - The sound of a Roessler attractor";
  92. Maker = "Tim Goetze <tim@quitte.de>";
  93. Copyright = "GPL, 2004-7";
  94. /* fill port info and vtable */
  95. autogen();
  96. }