SamplePlayHandle.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * SamplePlayHandle.h - play-handle for playing a sample
  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 SAMPLE_PLAY_HANDLE_H
  25. #define SAMPLE_PLAY_HANDLE_H
  26. #include "SampleBuffer.h"
  27. #include "AutomatableModel.h"
  28. #include "PlayHandle.h"
  29. class PatternTrack;
  30. class SampleClip;
  31. class Track;
  32. class AudioPort;
  33. class SamplePlayHandle : public PlayHandle
  34. {
  35. public:
  36. SamplePlayHandle( SampleBuffer* sampleBuffer , bool ownAudioPort = true );
  37. SamplePlayHandle( const QString& sampleFile );
  38. SamplePlayHandle( SampleClip* clip );
  39. virtual ~SamplePlayHandle();
  40. inline bool affinityMatters() const override
  41. {
  42. return true;
  43. }
  44. void play( sampleFrame * buffer ) override;
  45. bool isFinished() const override;
  46. bool isFromTrack( const Track * _track ) const override;
  47. f_cnt_t totalFrames() const;
  48. inline f_cnt_t framesDone() const
  49. {
  50. return( m_frame );
  51. }
  52. void setDoneMayReturnTrue( bool _enable )
  53. {
  54. m_doneMayReturnTrue = _enable;
  55. }
  56. void setPatternTrack(PatternTrack* pt)
  57. {
  58. m_patternTrack = pt;
  59. }
  60. void setVolumeModel( FloatModel * _model )
  61. {
  62. m_volumeModel = _model;
  63. }
  64. private:
  65. SampleBuffer * m_sampleBuffer;
  66. bool m_doneMayReturnTrue;
  67. f_cnt_t m_frame;
  68. SampleBuffer::handleState m_state;
  69. const bool m_ownAudioPort;
  70. FloatModel m_defaultVolumeModel;
  71. FloatModel * m_volumeModel;
  72. Track * m_track;
  73. PatternTrack* m_patternTrack;
  74. } ;
  75. #endif