turn off relevant fade in/out before creating peakfiles for compound region sources
[ardour.git] / libs / ardour / ardour / audioplaylist.h
1 /*
2     Copyright (C) 2003 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_audio_playlist_h__
21 #define __ardour_audio_playlist_h__
22
23 #include <vector>
24 #include <list>
25
26 #include "ardour/ardour.h"
27 #include "ardour/playlist.h"
28
29 namespace ARDOUR  {
30
31 class Session;
32 class Region;
33 class AudioRegion;
34 class Source;
35
36 namespace Properties {
37         /* fake the type, since crossfades are handled by SequenceProperty which doesn't
38            care about such things.
39         */
40         extern PBD::PropertyDescriptor<bool> crossfades;
41 }
42
43 class AudioPlaylist;    
44
45 class CrossfadeListProperty : public PBD::SequenceProperty<std::list<boost::shared_ptr<Crossfade> > >
46 {
47 public:
48         CrossfadeListProperty (AudioPlaylist &);
49
50         void get_content_as_xml (boost::shared_ptr<Crossfade>, XMLNode &) const;
51         boost::shared_ptr<Crossfade> get_content_from_xml (XMLNode const &) const;
52
53 private:
54         CrossfadeListProperty* clone () const;
55         CrossfadeListProperty* create () const;
56
57         /* copy construction only by ourselves */
58         CrossfadeListProperty (CrossfadeListProperty const & p);
59
60         friend class AudioPlaylist;
61         /* we live and die with our playlist, no lifetime management needed */
62         AudioPlaylist& _playlist;
63 };
64
65         
66 class AudioPlaylist : public ARDOUR::Playlist
67 {
68 public:
69         typedef std::list<boost::shared_ptr<Crossfade> > Crossfades;
70         static void make_property_quarks ();
71
72         AudioPlaylist (Session&, const XMLNode&, bool hidden = false);
73         AudioPlaylist (Session&, std::string name, bool hidden = false);
74         AudioPlaylist (boost::shared_ptr<const AudioPlaylist>, std::string name, bool hidden = false);
75         AudioPlaylist (boost::shared_ptr<const AudioPlaylist>, framepos_t start, framecnt_t cnt, std::string name, bool hidden = false);
76
77         ~AudioPlaylist ();
78
79         void clear (bool with_signals=true);
80
81         framecnt_t read (Sample *dst, Sample *mixdown, float *gain_buffer, framepos_t start, framecnt_t cnt, uint32_t chan_n=0);
82
83         int set_state (const XMLNode&, int version);
84
85         PBD::Signal1<void,boost::shared_ptr<Crossfade> >  NewCrossfade;
86         
87         void foreach_crossfade (boost::function<void (boost::shared_ptr<Crossfade>)>);
88         void crossfades_at (framepos_t frame, Crossfades&);
89
90         bool destroy_region (boost::shared_ptr<Region>);
91
92         void update (const CrossfadeListProperty::ChangeRecord &);
93
94         boost::shared_ptr<Crossfade> find_crossfade (const PBD::ID &) const;
95         
96     protected:
97
98         /* playlist "callbacks" */
99         void notify_crossfade_added (boost::shared_ptr<Crossfade>);
100         void flush_notifications (bool);
101
102         void finalize_split_region (boost::shared_ptr<Region> orig, boost::shared_ptr<Region> left, boost::shared_ptr<Region> right);
103
104         void refresh_dependents (boost::shared_ptr<Region> region);
105         void check_dependents (boost::shared_ptr<Region> region, bool norefresh);
106         void remove_dependents (boost::shared_ptr<Region> region);
107         void copy_dependents (const std::vector<TwoRegions>&, boost::shared_ptr<Playlist>);
108
109         void pre_combine (std::vector<boost::shared_ptr<Region> >&);
110         void post_combine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>);
111         void pre_uncombine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>);
112
113     private:
114        CrossfadeListProperty _crossfades;
115        Crossfades      _pending_xfade_adds;
116
117        void crossfade_invalidated (boost::shared_ptr<Region>);
118        XMLNode& state (bool full_state);
119        void dump () const;
120
121        bool region_changed (const PBD::PropertyChange&, boost::shared_ptr<Region>);
122        void crossfade_changed (const PBD::PropertyChange&);
123        void add_crossfade (boost::shared_ptr<Crossfade>);
124
125        void source_offset_changed (boost::shared_ptr<AudioRegion> region);
126 };
127
128 } /* namespace ARDOUR */
129
130 #endif  /* __ardour_audio_playlist_h__ */
131
132