Engine.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. #include "lmms_basics.h"
  30. class BBTrackContainer;
  31. class DummyTrackContainer;
  32. class FxMixer;
  33. class ProjectJournal;
  34. class Mixer;
  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 Mixer *mixer()
  55. {
  56. return s_mixer;
  57. }
  58. static FxMixer * fxMixer()
  59. {
  60. return s_fxMixer;
  61. }
  62. static Song * getSong()
  63. {
  64. return s_song;
  65. }
  66. static BBTrackContainer * getBBTrackContainer()
  67. {
  68. return s_bbTrackContainer;
  69. }
  70. static ProjectJournal * projectJournal()
  71. {
  72. return s_projectJournal;
  73. }
  74. static Ladspa2LMMS * getLADSPAManager()
  75. {
  76. return s_ladspaManager;
  77. }
  78. static DummyTrackContainer * dummyTrackContainer()
  79. {
  80. return s_dummyTC;
  81. }
  82. static float framesPerTick()
  83. {
  84. return s_framesPerTick;
  85. }
  86. static float framesPerTick(sample_rate_t sample_rate);
  87. static void updateFramesPerTick();
  88. static inline LmmsCore * inst()
  89. {
  90. if( s_instanceOfMe == NULL )
  91. {
  92. s_instanceOfMe = new LmmsCore();
  93. }
  94. return s_instanceOfMe;
  95. }
  96. static void setDndPluginKey(void* newKey);
  97. static void* pickDndPluginKey();
  98. signals:
  99. void initProgress(const QString &msg);
  100. private:
  101. // small helper function which sets the pointer to NULL before actually deleting
  102. // the object it refers to
  103. template<class T>
  104. static inline void deleteHelper( T * * ptr )
  105. {
  106. T * tmp = *ptr;
  107. *ptr = NULL;
  108. delete tmp;
  109. }
  110. static float s_framesPerTick;
  111. // core
  112. static Mixer *s_mixer;
  113. static FxMixer * s_fxMixer;
  114. static Song * s_song;
  115. static BBTrackContainer * s_bbTrackContainer;
  116. static ProjectJournal * s_projectJournal;
  117. static DummyTrackContainer * s_dummyTC;
  118. static Ladspa2LMMS * s_ladspaManager;
  119. static void* s_dndPluginKey;
  120. // even though most methods are static, an instance is needed for Qt slots/signals
  121. static LmmsCore * s_instanceOfMe;
  122. friend class GuiApplication;
  123. };
  124. #endif