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 25 #ifndef SAMPLE_TRACK_H 26 #define SAMPLE_TRACK_H 27 28 #include <QDialog> 29 30 #include "AudioPort.h" 31 #include "Track.h" 32 33 class EffectRackView; 34 class Knob; 35 class SampleBuffer; 36 37 38 class SampleTCO : public TrackContentObject 39 { 40 Q_OBJECT 41 mapPropertyFromModel(bool,isRecord,setRecord,m_recordModel); 42 public: 43 SampleTCO( Track * _track ); 44 virtual ~SampleTCO(); 45 46 virtual void changeLength( const MidiTime & _length ); 47 const QString & sampleFile() const; 48 49 virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); 50 virtual void loadSettings( const QDomElement & _this ); nodeName()51 inline virtual QString nodeName() const 52 { 53 return "sampletco"; 54 } 55 sampleBuffer()56 SampleBuffer* sampleBuffer() 57 { 58 return m_sampleBuffer; 59 } 60 61 MidiTime sampleLength() const; 62 void setSampleStartFrame( f_cnt_t startFrame ); 63 void setSamplePlayLength( f_cnt_t length ); 64 virtual TrackContentObjectView * createView( TrackView * _tv ); 65 66 67 bool isPlaying() const; 68 void setIsPlaying(bool isPlaying); 69 70 public slots: 71 void setSampleBuffer( SampleBuffer* sb ); 72 void setSampleFile( const QString & _sf ); 73 void updateLength(); 74 void toggleRecord(); 75 void playbackPositionChanged(); 76 void updateTrackTcos(); 77 78 79 private: 80 SampleBuffer* m_sampleBuffer; 81 BoolModel m_recordModel; 82 bool m_isPlaying; 83 84 85 friend class SampleTCOView; 86 87 88 signals: 89 void sampleChanged(); 90 91 } ; 92 93 94 95 class SampleTCOView : public TrackContentObjectView 96 { 97 Q_OBJECT 98 99 public: 100 SampleTCOView( SampleTCO * _tco, TrackView * _tv ); 101 virtual ~SampleTCOView(); 102 103 104 public slots: 105 void updateSample(); 106 107 108 109 protected: 110 virtual void contextMenuEvent( QContextMenuEvent * _cme ); 111 virtual void mousePressEvent( QMouseEvent * _me ); 112 virtual void mouseReleaseEvent( QMouseEvent * _me ); 113 virtual void dragEnterEvent( QDragEnterEvent * _dee ); 114 virtual void dropEvent( QDropEvent * _de ); 115 virtual void mouseDoubleClickEvent( QMouseEvent * ); 116 virtual void paintEvent( QPaintEvent * ); 117 118 119 private: 120 SampleTCO * m_tco; 121 QPixmap m_paintPixmap; 122 } ; 123 124 125 126 127 class SampleTrack : public Track 128 { 129 Q_OBJECT 130 public: 131 SampleTrack( TrackContainer* tc ); 132 virtual ~SampleTrack(); 133 134 virtual bool play( const MidiTime & _start, const fpp_t _frames, 135 const f_cnt_t _frame_base, int _tco_num = -1 ); 136 virtual TrackView * createView( TrackContainerView* tcv ); 137 virtual TrackContentObject * createTCO( const MidiTime & _pos ); 138 139 140 virtual void saveTrackSpecificSettings( QDomDocument & _doc, 141 QDomElement & _parent ); 142 virtual void loadTrackSpecificSettings( const QDomElement & _this ); 143 audioPort()144 inline AudioPort * audioPort() 145 { 146 return &m_audioPort; 147 } 148 nodeName()149 virtual QString nodeName() const 150 { 151 return "sampletrack"; 152 } 153 154 public slots: 155 void updateTcos(); 156 void setPlayingTcos( bool isPlaying ); 157 158 private: 159 FloatModel m_volumeModel; 160 FloatModel m_panningModel; 161 AudioPort m_audioPort; 162 163 164 165 friend class SampleTrackView; 166 167 } ; 168 169 170 171 class SampleTrackView : public TrackView 172 { 173 Q_OBJECT 174 public: 175 SampleTrackView( SampleTrack* Track, TrackContainerView* tcv ); 176 virtual ~SampleTrackView(); 177 178 179 public slots: 180 void showEffects(); 181 182 183 protected: 184 void modelChanged(); nodeName()185 virtual QString nodeName() const 186 { 187 return "SampleTrackView"; 188 } 189 190 191 private: 192 EffectRackView * m_effectRack; 193 QWidget * m_effWindow; 194 Knob * m_volumeKnob; 195 Knob * m_panningKnob; 196 197 } ; 198 199 200 #endif 201