Merged with trunk R1304
[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     $Id$
19 */
20
21 #ifndef __ardour_audio_playlist_h__
22 #define __ardour_audio_playlist_h__
23
24 #include <vector>
25 #include <list>
26
27 #include <ardour/ardour.h>
28 #include <ardour/playlist.h>
29
30 namespace ARDOUR  {
31
32 class Session;
33 class Region;
34 class AudioRegion;
35 class Source;
36
37 class AudioPlaylist : public ARDOUR::Playlist
38 {
39   public:
40         typedef std::list<boost::shared_ptr<Crossfade> > Crossfades;
41         
42    public:
43         AudioPlaylist (Session&, const XMLNode&, bool hidden = false);
44         AudioPlaylist (Session&, string name, bool hidden = false);
45         AudioPlaylist (boost::shared_ptr<const AudioPlaylist>, string name, bool hidden = false);
46         AudioPlaylist (boost::shared_ptr<const AudioPlaylist>, nframes_t start, nframes_t cnt, string name, bool hidden = false);
47
48         ~AudioPlaylist ();
49
50         void clear (bool with_signals=true);
51
52         nframes_t read (Sample *dst, Sample *mixdown, float *gain_buffer, nframes_t start, nframes_t cnt, uint32_t chan_n=0);
53
54         int set_state (const XMLNode&);
55
56         sigc::signal<void,boost::shared_ptr<Crossfade> > NewCrossfade; 
57
58         template<class T> void foreach_crossfade (T *t, void (T::*func)(boost::shared_ptr<Crossfade>));
59         void crossfades_at (nframes_t frame, Crossfades&);
60
61         bool destroy_region (boost::shared_ptr<Region>);
62
63     protected:
64
65         /* playlist "callbacks" */
66         void notify_crossfade_added (boost::shared_ptr<Crossfade>);
67         void flush_notifications ();
68
69         void finalize_split_region (boost::shared_ptr<Region> orig, boost::shared_ptr<Region> left, boost::shared_ptr<Region> right);
70         
71         void refresh_dependents (boost::shared_ptr<Region> region);
72         void check_dependents (boost::shared_ptr<Region> region, bool norefresh);
73         void remove_dependents (boost::shared_ptr<Region> region);
74
75     private:
76        Crossfades      _crossfades;
77        Crossfades      _pending_xfade_adds;
78
79        void crossfade_invalidated (boost::shared_ptr<Crossfade>);
80        XMLNode& state (bool full_state);
81        void dump () const;
82
83        bool region_changed (Change, boost::shared_ptr<Region>);
84        void crossfade_changed (Change);
85        void add_crossfade (boost::shared_ptr<Crossfade>);
86
87        void source_offset_changed (boost::shared_ptr<AudioRegion> region);
88 };
89
90 } /* namespace ARDOUR */
91
92 #endif  /* __ardour_audio_playlist_h__ */
93
94