White.cc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. White.cc
  3. Copyright 2004-7 Tim Goetze <tim@quitte.de>
  4. http://quitte.de/dsp/
  5. white noise generation.
  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 "basics.h"
  22. #include "White.h"
  23. #include "Descriptor.h"
  24. template <sample_func_t F>
  25. void
  26. White::one_cycle (int frames)
  27. {
  28. double g = (gain == *ports[0]) ?
  29. 1 : pow (getport(0) / gain, 1. / (double) frames);
  30. sample_t * d = ports[1];
  31. for (int i = 0; i < frames; ++i)
  32. {
  33. F (d, i, gain * white.get(), adding_gain);
  34. gain *= g;
  35. }
  36. gain = getport(0);
  37. }
  38. /* //////////////////////////////////////////////////////////////////////// */
  39. PortInfo
  40. White::port_info [] =
  41. {
  42. {
  43. "volume",
  44. INPUT | CONTROL,
  45. {BOUNDED | DEFAULT_MID, MIN_GAIN, 1}
  46. }, {
  47. "out",
  48. OUTPUT | AUDIO,
  49. {0}
  50. }
  51. };
  52. template <> void
  53. Descriptor<White>::setup()
  54. {
  55. UniqueID = 1785;
  56. Label = "White";
  57. Properties = HARD_RT;
  58. Name = CAPS "White - White noise generator";
  59. Maker = "Tim Goetze <tim@quitte.de>";
  60. Copyright = "GPL, 2004-7";
  61. /* fill port info and vtable */
  62. autogen();
  63. }