Engine.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Engine.h - engine-system of LMMS
  3. *
  4. * Copyright (c) 2006-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 ENGINE_H
  25. #define ENGINE_H
  26. #include <QtCore/QString>
  27. #include <QtCore/QObject>
  28. #include "lmmsconfig.h"
  29. #include "lmms_export.h"
  30. #include "lmms_basics.h"
  31. class AudioEngine;
  32. class Mixer;
  33. class PatternStore;
  34. class ProjectJournal;
  35. class Song;
  36. class Ladspa2LMMS;
  37. // Note: This class is called 'LmmsCore' instead of 'Engine' because of naming
  38. // conflicts caused by ZynAddSubFX. See https://github.com/LMMS/lmms/issues/2269
  39. // and https://github.com/LMMS/lmms/pull/2118 for more details.
  40. //
  41. // The workaround was to rename Lmms' Engine so that it has a different symbol
  42. // name in the object files, but typedef it back to 'Engine' and keep it inside
  43. // of Engine.h so that the rest of the codebase can be oblivious to this issue
  44. // (and it could be fixed without changing every single file).
  45. class LmmsCore;
  46. typedef LmmsCore Engine;
  47. class LMMS_EXPORT LmmsCore : public QObject
  48. {
  49. Q_OBJECT
  50. public:
  51. static void init( bool renderOnly );
  52. static void destroy();
  53. // core
  54. static AudioEngine *audioEngine()
  55. {
  56. return s_audioEngine;
  57. }
  58. static Mixer * mixer()
  59. {
  60. return s_mixer;
  61. }
  62. static Song * getSong()
  63. {
  64. return s_song;
  65. }
  66. static PatternStore * patternStore()
  67. {
  68. return s_patternStore;
  69. }
  70. static ProjectJournal * projectJournal()
  71. {
  72. return s_projectJournal;
  73. }
  74. static bool ignorePluginBlacklist();
  75. #ifdef LMMS_HAVE_LV2
  76. static class Lv2Manager * getLv2Manager()
  77. {
  78. return s_lv2Manager;
  79. }
  80. #endif
  81. static Ladspa2LMMS * getLADSPAManager()
  82. {
  83. return s_ladspaManager;
  84. }
  85. static float framesPerTick()
  86. {
  87. return s_framesPerTick;
  88. }
  89. static float framesPerTick(sample_rate_t sample_rate);
  90. static void updateFramesPerTick();
  91. static inline LmmsCore * inst()
  92. {
  93. if( s_instanceOfMe == nullptr )
  94. {
  95. s_instanceOfMe = new LmmsCore();
  96. }
  97. return s_instanceOfMe;
  98. }
  99. static void setDndPluginKey(void* newKey);
  100. static void* pickDndPluginKey();
  101. signals:
  102. void initProgress(const QString &msg);
  103. private:
  104. // small helper function which sets the pointer to NULL before actually deleting
  105. // the object it refers to
  106. template<class T>
  107. static inline void deleteHelper( T * * ptr )
  108. {
  109. T * tmp = *ptr;
  110. *ptr = nullptr;
  111. delete tmp;
  112. }
  113. static float s_framesPerTick;
  114. // core
  115. static AudioEngine *s_audioEngine;
  116. static Mixer * s_mixer;
  117. static Song * s_song;
  118. static PatternStore * s_patternStore;
  119. static ProjectJournal * s_projectJournal;
  120. #ifdef LMMS_HAVE_LV2
  121. static class Lv2Manager* s_lv2Manager;
  122. #endif
  123. static Ladspa2LMMS * s_ladspaManager;
  124. static void* s_dndPluginKey;
  125. // even though most methods are static, an instance is needed for Qt slots/signals
  126. static LmmsCore * s_instanceOfMe;
  127. friend class GuiApplication;
  128. };
  129. #endif