00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AUDIOCLIP_H
00023 #define AUDIOCLIP_H
00024
00025 #include <QString>
00026 #include <QList>
00027 #include <QDomNode>
00028
00029 #include "ContextItem.h"
00030 #include "AudioProcessingItem.h"
00031 #include "Snappable.h"
00032 #include "defines.h"
00033 #include "GainEnvelope.h"
00034
00035
00036 class Sheet;
00037 class ReadSource;
00038 class WriteSource;
00039 class Track;
00040 class Peak;
00041 class AudioBus;
00042 class FadeCurve;
00043 class PluginChain;
00044
00045 class AudioClip : public ContextItem, public AudioProcessingItem, public Snappable
00046 {
00047 Q_OBJECT
00048 Q_CLASSINFO("mute", tr("Mute"))
00049 Q_CLASSINFO("reset_fade_in", tr("In: Remove"))
00050 Q_CLASSINFO("reset_fade_out", tr("Out: Remove"))
00051 Q_CLASSINFO("reset_fade_both", tr("Both: Remove"))
00052 Q_CLASSINFO("normalize", tr("Normalize"))
00053 Q_CLASSINFO("lock", tr("Lock"))
00054
00055 public:
00056
00057 AudioClip(const QString& name);
00058 AudioClip(const QDomNode& node);
00059 ~AudioClip();
00060
00061 enum RecordingStatus {
00062 NO_RECORDING,
00063 RECORDING,
00064 FINISHING_RECORDING
00065 };
00066
00067 void set_audio_source(ReadSource* source);
00068 int init_recording(QByteArray bus);
00069 int process(nframes_t nframes);
00070
00071 void set_track_start_location(const TimeRef& location);
00072 void set_name(const QString& name);
00073 void set_fade_in(double range);
00074 void set_fade_out(double range);
00075 void set_track(Track* track);
00076 void set_sheet(Sheet* sheet);
00077
00078 void set_selected(bool selected);
00079 void set_as_moving(bool moving);
00080 int set_state( const QDomNode& node );
00081
00082 AudioClip* create_copy();
00083 Track* get_track() const;
00084 Sheet* get_sheet() const;
00085 Peak* get_peak() const {return m_peak;}
00086 QDomNode get_state(QDomDocument doc);
00087 FadeCurve* get_fade_in() const;
00088 FadeCurve* get_fade_out() const;
00089 PluginChain* get_plugin_chain() const {return m_pluginChain;}
00090
00091 TimeRef get_source_length() const;
00092 TimeRef get_length() const {return m_length;}
00093 TimeRef get_track_start_location() const {return m_trackStartLocation;}
00094 TimeRef get_track_end_location() const {return m_trackEndLocation;}
00095 TimeRef get_source_start_location() const {return m_sourceStartLocation;}
00096 TimeRef get_source_end_location() const {return m_sourceEndLocation;}
00097
00098 int get_channels() const;
00099 int get_rate() const;
00100 int get_bitdepth() const;
00101 qint64 get_readsource_id() const;
00102 qint64 get_sheet_id() const {return m_sheetId;}
00103 ReadSource* get_readsource() const;
00104
00105 QString get_name() const;
00106 QDomNode get_dom_node() const;
00107
00108 bool is_take() const;
00109 bool is_selected();
00110 bool is_locked() const {return m_isLocked;}
00111 bool has_sheet() const;
00112 bool is_readsource_invalid() const {return !m_isReadSourceValid;}
00113 bool is_smaller_then(APILinkedListNode* node) {return ((AudioClip*)node)->get_track_start_location() > get_track_start_location();}
00114 bool is_moving() const {return m_isMoving;}
00115
00116 int recording_state() const;
00117
00118 private:
00119 Track* m_track;
00120 Sheet* m_sheet;
00121 ReadSource* m_readSource;
00122 WriteSource* m_recorder;
00123 APILinkedList m_fades;
00124 Peak* m_peak;
00125 AudioBus* m_captureBus;
00126 FadeCurve* fadeIn;
00127 FadeCurve* fadeOut;
00128 QDomNode m_domNode;
00129
00130 QString m_name;
00131 QByteArray m_captureBusName;
00132
00133 TimeRef m_trackStartLocation;
00134 TimeRef m_trackEndLocation;
00135 TimeRef m_sourceEndLocation;
00136 TimeRef m_sourceStartLocation;
00137 TimeRef m_sourceLength;
00138 TimeRef m_length;
00139
00140 bool m_isTake;
00141 bool m_isLocked;
00142 bool m_isReadSourceValid;
00143 bool m_isMoving;
00144 RecordingStatus m_recordingStatus;
00145
00146 qint64 m_readSourceId;
00147 qint64 m_sheetId;
00148
00149 void create_fade_in();
00150 void create_fade_out();
00151 void init();
00152 void set_source_end_location(const TimeRef& location);
00153 void set_source_start_location(const TimeRef& location);
00154 void set_track_end_location(const TimeRef& location);
00155 void set_sources_active_state();
00156 void process_capture(nframes_t nframes);
00157
00158
00159 float calculate_normalization_factor(float targetdB = 0.0);
00160
00161 friend class ResourcesManager;
00162
00163 signals:
00164 void stateChanged();
00165 void muteChanged();
00166 void lockChanged();
00167 void positionChanged();
00168 void fadeAdded(FadeCurve*);
00169 void fadeRemoved(FadeCurve*);
00170 void recordingFinished(AudioClip*);
00171
00172 public slots:
00173 void finish_recording();
00174 void finish_write_source();
00175 void set_left_edge(TimeRef newLeftLocation);
00176 void set_right_edge(TimeRef newRightLocation);
00177 void track_audible_state_changed();
00178 void toggle_mute();
00179 void toggle_lock();
00180 void set_gain(float g);
00181
00182 float get_gain() const;
00183
00184 Command* mute();
00185 Command* reset_fade_in();
00186 Command* reset_fade_out();
00187 Command* reset_fade_both();
00188 Command* normalize();
00189 Command* lock();
00190
00191 private slots:
00192 void private_add_fade(FadeCurve* fade);
00193 void private_remove_fade(FadeCurve* fade);
00194 void get_capture_bus();
00195
00196 };
00197
00198
00199 inline qint64 AudioClip::get_readsource_id( ) const {return m_readSourceId;}
00200
00201 inline float AudioClip::get_gain( ) const
00202 {
00203 return m_fader->get_gain();
00204 }
00205
00206
00207 #endif