AudioPort.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * AudioPort.h - base-class for objects providing sound at a port
  3. *
  4. * Copyright (c) 2005-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 AUDIO_PORT_H
  25. #define AUDIO_PORT_H
  26. #include <QtCore/QString>
  27. #include <QtCore/QMutex>
  28. #include <QtCore/QMutexLocker>
  29. #include "MemoryManager.h"
  30. #include "PlayHandle.h"
  31. class EffectChain;
  32. class FloatModel;
  33. class BoolModel;
  34. class AudioPort : public ThreadableJob
  35. {
  36. MM_OPERATORS
  37. public:
  38. AudioPort( const QString & _name, bool _has_effect_chain = true,
  39. FloatModel * volumeModel = NULL, FloatModel * panningModel = NULL,
  40. BoolModel * mutedModel = NULL );
  41. virtual ~AudioPort();
  42. inline sampleFrame * buffer()
  43. {
  44. return m_portBuffer;
  45. }
  46. inline void lockBuffer()
  47. {
  48. m_portBufferLock.lock();
  49. }
  50. inline void unlockBuffer()
  51. {
  52. m_portBufferLock.unlock();
  53. }
  54. // indicate whether JACK & Co should provide output-buffer at ext. port
  55. inline bool extOutputEnabled() const
  56. {
  57. return m_extOutputEnabled;
  58. }
  59. void setExtOutputEnabled( bool _enabled );
  60. // next effect-channel after this audio-port
  61. // (-1 = none 0 = master)
  62. inline fx_ch_t nextFxChannel() const
  63. {
  64. return m_nextFxChannel;
  65. }
  66. inline EffectChain * effects()
  67. {
  68. return m_effects;
  69. }
  70. void setNextFxChannel( const fx_ch_t _chnl )
  71. {
  72. m_nextFxChannel = _chnl;
  73. }
  74. const QString & name() const
  75. {
  76. return m_name;
  77. }
  78. void setName( const QString & _new_name );
  79. bool processEffects();
  80. // ThreadableJob stuff
  81. virtual void doProcessing();
  82. virtual bool requiresProcessing() const
  83. {
  84. return true;
  85. }
  86. void addPlayHandle( PlayHandle * handle );
  87. void removePlayHandle( PlayHandle * handle );
  88. private:
  89. volatile bool m_bufferUsage;
  90. sampleFrame * m_portBuffer;
  91. QMutex m_portBufferLock;
  92. bool m_extOutputEnabled;
  93. fx_ch_t m_nextFxChannel;
  94. QString m_name;
  95. EffectChain * m_effects;
  96. PlayHandleList m_playHandles;
  97. QMutex m_playHandleLock;
  98. FloatModel * m_volumeModel;
  99. FloatModel * m_panningModel;
  100. BoolModel * m_mutedModel;
  101. friend class Mixer;
  102. friend class MixerWorkerThread;
  103. } ;
  104. #endif