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.

157 lines
3.6KB

  1. /*
  2. Copyright (C) 2011 Nasca Octavian Paul
  3. Author: Nasca Octavian Paul
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of version 2 of the GNU General Public License
  6. as published by the Free Software Foundation.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License (version 2) for more details.
  11. You should have received a copy of the GNU General Public License (version 2)
  12. along with this program; if not, write to the Free Software Foundation,
  13. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14. */
  15. #ifndef PROCESSED_STRETCH_H
  16. #define PROCESSED_STRETCH_H
  17. #include "FreeEdit.h"
  18. #include "Stretch.h"
  19. #include "XMLwrapper.h"
  20. struct ProcessParameters{
  21. ProcessParameters(){
  22. pitch_shift.enabled=false;
  23. pitch_shift.cents=0;
  24. octave.enabled=false;
  25. octave.om2=octave.om1=octave.o1=octave.o15=octave.o2=0;
  26. octave.o0=1.0;
  27. freq_shift.enabled=false;
  28. freq_shift.Hz=0;
  29. compressor.enabled=false;
  30. compressor.power=0.0;
  31. filter.enabled=false;
  32. filter.stop=false;
  33. filter.low=0.0;
  34. filter.high=22000.0;
  35. filter.hdamp=0.0;
  36. harmonics.enabled=false;
  37. harmonics.freq=440.0;
  38. harmonics.bandwidth=25.0;
  39. harmonics.nharmonics=10;
  40. harmonics.gauss=false;
  41. spread.enabled=false;
  42. spread.bandwidth=0.3;
  43. tonal_vs_noise.enabled=false;
  44. tonal_vs_noise.preserve=0.5;
  45. tonal_vs_noise.bandwidth=0.9;
  46. };
  47. ~ProcessParameters(){
  48. };
  49. void add2XML(XMLwrapper *xml);
  50. void getfromXML(XMLwrapper *xml);
  51. struct{
  52. bool enabled;
  53. int cents;
  54. }pitch_shift;
  55. struct{
  56. bool enabled;
  57. REALTYPE om2,om1,o0,o1,o15,o2;
  58. }octave;
  59. struct{
  60. bool enabled;
  61. int Hz;
  62. }freq_shift;
  63. struct{
  64. bool enabled;
  65. REALTYPE power;
  66. }compressor;
  67. struct{
  68. bool enabled;
  69. REALTYPE low,high;
  70. REALTYPE hdamp;
  71. bool stop;
  72. }filter;
  73. struct{
  74. bool enabled;
  75. REALTYPE freq;
  76. REALTYPE bandwidth;
  77. int nharmonics;
  78. bool gauss;
  79. }harmonics;
  80. struct{
  81. bool enabled;
  82. REALTYPE bandwidth;
  83. }spread;
  84. struct{
  85. bool enabled;
  86. REALTYPE preserve;
  87. REALTYPE bandwidth;
  88. }tonal_vs_noise;
  89. FreeEdit free_filter;
  90. FreeEdit stretch_multiplier;
  91. };
  92. class ProcessedStretch:public Stretch{
  93. public:
  94. //stereo_mode: 0=mono,1=left,2=right
  95. ProcessedStretch(REALTYPE rap_,int in_bufsize_,FFTWindow w=W_HAMMING,bool bypass_=false,REALTYPE samplerate_=44100,int stereo_mode=0);
  96. ~ProcessedStretch();
  97. void set_parameters(ProcessParameters *ppar);
  98. private:
  99. REALTYPE get_stretch_multiplier(REALTYPE pos_percents);
  100. // void process_output(REALTYPE *smps,int nsmps);
  101. void process_spectrum(REALTYPE *freq);
  102. void do_harmonics(REALTYPE *freq1,REALTYPE *freq2);
  103. void do_pitch_shift(REALTYPE *freq1,REALTYPE *freq2,REALTYPE rap);
  104. void do_freq_shift(REALTYPE *freq1,REALTYPE *freq2);
  105. void do_octave(REALTYPE *freq1,REALTYPE *freq2);
  106. void do_filter(REALTYPE *freq1,REALTYPE *freq2);
  107. void do_free_filter(REALTYPE *freq1,REALTYPE *freq2);
  108. void do_compressor(REALTYPE *freq1,REALTYPE *freq2);
  109. void do_spread(REALTYPE *freq1,REALTYPE *freq2);
  110. void do_tonal_vs_noise(REALTYPE *freq1,REALTYPE *freq2);
  111. void copy(REALTYPE *freq1,REALTYPE *freq2);
  112. void add(REALTYPE *freq2,REALTYPE *freq1,REALTYPE a=1.0);
  113. void mul(REALTYPE *freq1,REALTYPE a);
  114. void zero(REALTYPE *freq1);
  115. void spread(REALTYPE *freq1,REALTYPE *freq2,REALTYPE spread_bandwidth);
  116. void update_free_filter();
  117. int nfreq;
  118. REALTYPE *free_filter_freqs;
  119. ProcessParameters pars;
  120. REALTYPE *infreq,*sumfreq,*tmpfreq1,*tmpfreq2;
  121. //REALTYPE *fbfreq;
  122. };
  123. #endif