Analyzer.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Analyzer.h - declaration of Analyzer class.
  2. *
  3. * Copyright (c) 2019 Martin Pavelek <he29/dot/HS/at/gmail/dot/com>
  4. *
  5. * Based partially on Eq plugin code,
  6. * Copyright (c) 2014-2017, David French <dave/dot/french3/at/googlemail/dot/com>
  7. *
  8. * This file is part of LMMS - https://lmms.io
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2 of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public
  21. * License along with this program (see COPYING); if not, write to the
  22. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  23. * Boston, MA 02110-1301 USA.
  24. *
  25. */
  26. #ifndef ANALYZER_H
  27. #define ANALYZER_H
  28. #include <QWaitCondition>
  29. #include "DataprocLauncher.h"
  30. #include "Effect.h"
  31. #include "LocklessRingBuffer.h"
  32. #include "SaControls.h"
  33. #include "SaProcessor.h"
  34. //! Top level class; handles LMMS interface and feeds data to the data processor.
  35. class Analyzer : public Effect
  36. {
  37. public:
  38. Analyzer(Model *parent, const Descriptor::SubPluginFeatures::Key *key);
  39. virtual ~Analyzer();
  40. bool processAudioBuffer(sampleFrame *buffer, const fpp_t frame_count) override;
  41. EffectControls *controls() override {return &m_controls;}
  42. SaProcessor *getProcessor() {return &m_processor;}
  43. private:
  44. SaProcessor m_processor;
  45. SaControls m_controls;
  46. // Maximum LMMS buffer size (hard coded, the actual constant is hard to get)
  47. const unsigned int m_maxBufferSize = 4096;
  48. // QThread::create() workaround
  49. // Replace DataprocLauncher by QThread and replace initializer in constructor
  50. // with the following commented line when LMMS CI starts using Qt > 5.9
  51. //m_processorThread = QThread::create([=]{m_processor.analyze(m_inputBuffer);});
  52. DataprocLauncher m_processorThread;
  53. LocklessRingBuffer<sampleFrame> m_inputBuffer;
  54. #ifdef SA_DEBUG
  55. int m_last_dump_time;
  56. int m_dump_count;
  57. float m_sum_execution;
  58. float m_max_execution;
  59. #endif
  60. };
  61. #endif // ANALYZER_H