VCO.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. VCO.h
  3. Copyright 2004-5 Tim Goetze <tim@quitte.de>
  4. http://quitte.de/dsp/
  5. an oversampled triangle/saw/square oscillator, and a combination of two
  6. such oscillators with hard sync.
  7. */
  8. /*
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License
  11. as published by the Free Software Foundation; either version 2
  12. of the License, or (at your option) any later version.
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  20. 02111-1307, USA or point your web browser to http://www.gnu.org.
  21. */
  22. #ifndef _VCO_H_
  23. #define _VCO_H_
  24. #include "dsp/util.h"
  25. #include "dsp/VCO.h"
  26. #include "dsp/FIR.h"
  27. #include "dsp/sinc.h"
  28. #include "dsp/windows.h"
  29. class VCOs
  30. : public Plugin
  31. {
  32. public:
  33. sample_t f, gain;
  34. /* ok to just change these as you please, 4/32 works ok, sortof. */
  35. enum {
  36. OVERSAMPLE = 8,
  37. FIR_SIZE = 64,
  38. };
  39. DSP::TriSawSquare vco;
  40. /* downsampling filter */
  41. DSP::FIR down;
  42. template <sample_func_t F>
  43. void one_cycle (int frames);
  44. public:
  45. static PortInfo port_info[];
  46. VCOs()
  47. : down (FIR_SIZE)
  48. { }
  49. void init();
  50. void activate()
  51. {
  52. gain = *ports[3];
  53. down.reset();
  54. vco.reset();
  55. }
  56. void run (int n)
  57. {
  58. one_cycle<store_func> (n);
  59. }
  60. void run_adding (int n)
  61. {
  62. one_cycle<adding_func> (n);
  63. }
  64. };
  65. /* //////////////////////////////////////////////////////////////////////// */
  66. class VCOd
  67. : public Plugin
  68. {
  69. public:
  70. double fs;
  71. sample_t f, gain;
  72. /* ok to just change these as you please, 4/32 works ok, sortof. */
  73. enum {
  74. OVERSAMPLE = 8,
  75. FIR_SIZE = 64,
  76. };
  77. DSP::VCO2 vco;
  78. /* downsampling filter */
  79. DSP::FIR down;
  80. template <sample_func_t F>
  81. void one_cycle (int frames);
  82. public:
  83. static PortInfo port_info[];
  84. VCOd()
  85. : down (FIR_SIZE)
  86. { }
  87. void init();
  88. void activate()
  89. {
  90. gain = *ports[8];
  91. down.reset();
  92. vco.reset();
  93. }
  94. void run (int n)
  95. {
  96. one_cycle<store_func> (n);
  97. }
  98. void run_adding (int n)
  99. {
  100. one_cycle<adding_func> (n);
  101. }
  102. };
  103. #endif /* _VCO_H_ */