Engine.h 3.2 KB

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