File indexing completed on 2024-05-12 04:51:02
0001 /* 0002 SPDX-FileCopyrightText: 2010 Michal Malek <michalm@jabster.pl> 0003 SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 0009 #ifndef K3BAUDIOTRACK_H 0010 #define K3BAUDIOTRACK_H 0011 0012 #include "k3bmsf.h" 0013 #include "k3bcdtext.h" 0014 #include "k3btrack.h" 0015 #include "k3b_export.h" 0016 0017 #include <KIO/Global> 0018 0019 #include <QObject> 0020 #include <QString> 0021 0022 namespace K3b { 0023 class AudioDataSource; 0024 class AudioDoc; 0025 0026 0027 /** 0028 * @author Sebastian Trueg 0029 */ 0030 class LIBK3B_EXPORT AudioTrack : public QObject 0031 { 0032 Q_OBJECT 0033 0034 friend class AudioDataSource; 0035 friend class AudioDoc; 0036 0037 public: 0038 AudioTrack(); 0039 explicit AudioTrack( AudioDoc* parent ); 0040 ~AudioTrack() override; 0041 0042 AudioDoc* doc() const; 0043 0044 Device::Track toCdTrack() const; 0045 0046 /** 0047 * @return length of track in frames 0048 */ 0049 Msf length() const; 0050 KIO::filesize_t size() const; 0051 0052 QString artist() const; 0053 QString performer() const; 0054 QString title() const; 0055 QString arranger() const; 0056 QString songwriter() const; 0057 QString composer() const; 0058 QString isrc() const; 0059 QString cdTextMessage() const; 0060 Device::TrackCdText cdText() const; 0061 0062 bool copyProtection() const; 0063 bool preEmp() const; 0064 0065 /** 0066 * @obsolete use setPerformer 0067 **/ 0068 void setArtist( const QString& a ); 0069 void setPerformer( const QString& a ); 0070 void setTitle( const QString& t ); 0071 void setArranger( const QString& t ); 0072 void setSongwriter( const QString& t ); 0073 void setComposer( const QString& t ); 0074 void setIsrc( const QString& t ); 0075 void setCdTextMessage( const QString& t ); 0076 0077 void setCdText( const Device::TrackCdText& cdtext ); 0078 0079 void setPreEmp( bool b ); 0080 void setCopyProtection( bool b ); 0081 0082 Msf index0() const; 0083 /** 0084 * The length of the postgap, ie. the number of blocks with index0. 0085 * This is always 0 for the last track. 0086 */ 0087 Msf postGap() const; 0088 void setIndex0( const Msf& ); 0089 0090 /** 0091 * \return The track number starting at 1. 0092 */ 0093 unsigned int trackNumber() const; 0094 0095 /** 0096 * Remove this track from the list and return it. 0097 */ 0098 AudioTrack* take(); 0099 0100 /** 0101 * Move this track after @p track. 0102 * If @p track is null this track will be merged into the beginning 0103 * of the docs list. 0104 */ 0105 void moveAfter( AudioTrack* track ); 0106 0107 /** 0108 * Move this track ahead of @p track. 0109 * If @p track is null this track will be appended to the end 0110 * of the docs list. 0111 */ 0112 void moveAhead( AudioTrack* track ); 0113 0114 /** 0115 * Merge @p trackToMerge into this one. 0116 */ 0117 void merge( AudioTrack* trackToMerge, AudioDataSource* sourceAfter = 0 ); 0118 0119 AudioTrack* prev() const; 0120 AudioTrack* next() const; 0121 0122 /** 0123 * Use with care. 0124 */ 0125 void setFirstSource( AudioDataSource* source ); 0126 AudioDataSource* firstSource() const; 0127 AudioDataSource* lastSource() const; 0128 int numberSources() const; 0129 0130 /** 0131 * Append source to the end of the sources list. 0132 */ 0133 void addSource( AudioDataSource* source ); 0134 0135 /** 0136 * called by AudioDataSource because of the lack of signals 0137 */ 0138 void sourceChanged( AudioDataSource* ); 0139 0140 /** 0141 * Create a copy of this track containing copies of all the sources 0142 * but not being part of some list. 0143 */ 0144 AudioTrack* copy() const; 0145 0146 /** 0147 * Split the track at position pos and return the split track 0148 * on success. 0149 * The new track will be moved after this track. 0150 * 0151 * \param pos The position at which to split. \a pos will be the 0152 * first frame in the new track. 0153 */ 0154 AudioTrack* split( const Msf& pos ); 0155 0156 /** 0157 * Create reader associated with the track 0158 */ 0159 virtual QIODevice* createReader( QObject* parent = 0 ); 0160 0161 /** 0162 * Is this track in a list 0163 */ 0164 bool inList() const; 0165 0166 /** 0167 * Get the source at index. 0168 * \return the requested source or 0 if index is out 0169 * of bounds. 0170 */ 0171 AudioDataSource* getSource( int index ) const; 0172 0173 Q_SIGNALS: 0174 void sourceAboutToBeRemoved( int position ); 0175 void sourceRemoved( int position ); 0176 void sourceAboutToBeAdded( int position ); 0177 void sourceAdded( int position ); 0178 void changed(); 0179 0180 protected: 0181 /** 0182 * Tells the audio doc one source is about to be removed 0183 */ 0184 void emitSourceAboutToBeRemoved( AudioDataSource* source ); 0185 0186 /** 0187 * Tells the audio doc one source was removed from the list. 0188 */ 0189 void emitSourceRemoved( AudioDataSource* source ); 0190 0191 /** 0192 * Tells the audio doc one source is about to be added 0193 */ 0194 void emitSourceAboutToBeAdded( int position ); 0195 0196 /** 0197 * Tells the audio doc one source was added to the list. 0198 */ 0199 void emitSourceAdded( AudioDataSource* source ); 0200 0201 void setIndex0Offset( const Msf& msf ); 0202 void setParent( AudioDoc* parent ); 0203 0204 private: 0205 /** 0206 * Tells the doc that the track has changed 0207 */ 0208 void emitChanged(); 0209 0210 void debug(); 0211 0212 class Private; 0213 Private* d; 0214 }; 0215 } 0216 0217 #endif