SpectrumAnalyzer.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * SpectrumAnalyzer.h - spectrum anaylzer effect plugin
  3. *
  4. * Copyright (c) 2008-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  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 GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef _SPECTRUM_ANALYZER_H
  25. #define _SPECTRUM_ANALYZER_H
  26. #include "Effect.h"
  27. #include "fft_helpers.h"
  28. #include "SpectrumAnalyzerControls.h"
  29. const int MAX_BANDS = 249;
  30. class SpectrumAnalyzer : public Effect
  31. {
  32. public:
  33. enum ChannelModes
  34. {
  35. MergeChannels,
  36. LeftChannel,
  37. RightChannel
  38. } ;
  39. SpectrumAnalyzer( Model * _parent,
  40. const Descriptor::SubPluginFeatures::Key * _key );
  41. virtual ~SpectrumAnalyzer();
  42. virtual bool processAudioBuffer( sampleFrame * _buf,
  43. const fpp_t _frames );
  44. virtual EffectControls * controls()
  45. {
  46. return( &m_saControls );
  47. }
  48. private:
  49. SpectrumAnalyzerControls m_saControls;
  50. fftwf_plan m_fftPlan;
  51. fftwf_complex * m_specBuf;
  52. float m_absSpecBuf[FFT_BUFFER_SIZE+1];
  53. float m_buffer[FFT_BUFFER_SIZE*2];
  54. int m_framesFilledUp;
  55. float m_bands[MAX_BANDS];
  56. float m_energy;
  57. friend class SpectrumAnalyzerControls;
  58. friend class SpectrumView;
  59. } ;
  60. #endif