SampleTrack.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * SampleTrack.h - class SampleTrack, a track which provides arrangement of samples
  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_TRACK_H
  25. #define SAMPLE_TRACK_H
  26. #include <QDialog>
  27. #include "AudioPort.h"
  28. #include "Track.h"
  29. class EffectRackView;
  30. class Knob;
  31. class SampleBuffer;
  32. class SampleTCO : public TrackContentObject
  33. {
  34. Q_OBJECT
  35. mapPropertyFromModel(bool,isRecord,setRecord,m_recordModel);
  36. public:
  37. SampleTCO( Track * _track );
  38. virtual ~SampleTCO();
  39. virtual void changeLength( const MidiTime & _length );
  40. const QString & sampleFile() const;
  41. virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
  42. virtual void loadSettings( const QDomElement & _this );
  43. inline virtual QString nodeName() const
  44. {
  45. return "sampletco";
  46. }
  47. SampleBuffer* sampleBuffer()
  48. {
  49. return m_sampleBuffer;
  50. }
  51. MidiTime sampleLength() const;
  52. void setSampleStartFrame( f_cnt_t startFrame );
  53. void setSamplePlayLength( f_cnt_t length );
  54. virtual TrackContentObjectView * createView( TrackView * _tv );
  55. bool isPlaying() const;
  56. void setIsPlaying(bool isPlaying);
  57. public slots:
  58. void setSampleBuffer( SampleBuffer* sb );
  59. void setSampleFile( const QString & _sf );
  60. void updateLength();
  61. void toggleRecord();
  62. void playbackPositionChanged();
  63. void updateTrackTcos();
  64. private:
  65. SampleBuffer* m_sampleBuffer;
  66. BoolModel m_recordModel;
  67. bool m_isPlaying;
  68. friend class SampleTCOView;
  69. signals:
  70. void sampleChanged();
  71. } ;
  72. class SampleTCOView : public TrackContentObjectView
  73. {
  74. Q_OBJECT
  75. public:
  76. SampleTCOView( SampleTCO * _tco, TrackView * _tv );
  77. virtual ~SampleTCOView();
  78. public slots:
  79. void updateSample();
  80. protected:
  81. virtual void contextMenuEvent( QContextMenuEvent * _cme );
  82. virtual void mousePressEvent( QMouseEvent * _me );
  83. virtual void mouseReleaseEvent( QMouseEvent * _me );
  84. virtual void dragEnterEvent( QDragEnterEvent * _dee );
  85. virtual void dropEvent( QDropEvent * _de );
  86. virtual void mouseDoubleClickEvent( QMouseEvent * );
  87. virtual void paintEvent( QPaintEvent * );
  88. private:
  89. SampleTCO * m_tco;
  90. QPixmap m_paintPixmap;
  91. } ;
  92. class SampleTrack : public Track
  93. {
  94. Q_OBJECT
  95. public:
  96. SampleTrack( TrackContainer* tc );
  97. virtual ~SampleTrack();
  98. virtual bool play( const MidiTime & _start, const fpp_t _frames,
  99. const f_cnt_t _frame_base, int _tco_num = -1 );
  100. virtual TrackView * createView( TrackContainerView* tcv );
  101. virtual TrackContentObject * createTCO( const MidiTime & _pos );
  102. virtual void saveTrackSpecificSettings( QDomDocument & _doc,
  103. QDomElement & _parent );
  104. virtual void loadTrackSpecificSettings( const QDomElement & _this );
  105. inline AudioPort * audioPort()
  106. {
  107. return &m_audioPort;
  108. }
  109. virtual QString nodeName() const
  110. {
  111. return "sampletrack";
  112. }
  113. public slots:
  114. void updateTcos();
  115. void setPlayingTcos( bool isPlaying );
  116. private:
  117. FloatModel m_volumeModel;
  118. FloatModel m_panningModel;
  119. AudioPort m_audioPort;
  120. friend class SampleTrackView;
  121. } ;
  122. class SampleTrackView : public TrackView
  123. {
  124. Q_OBJECT
  125. public:
  126. SampleTrackView( SampleTrack* Track, TrackContainerView* tcv );
  127. virtual ~SampleTrackView();
  128. public slots:
  129. void showEffects();
  130. protected:
  131. void modelChanged();
  132. virtual QString nodeName() const
  133. {
  134. return "SampleTrackView";
  135. }
  136. private:
  137. EffectRackView * m_effectRack;
  138. QWidget * m_effWindow;
  139. Knob * m_volumeKnob;
  140. Knob * m_panningKnob;
  141. } ;
  142. #endif