Split pretty much the entire GUI in 3. Audio and Midi "editor strips" and
[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<Crossfade*> Crossfades;
41
42   private:
43         
44         struct State : public ARDOUR::StateManager::State {
45             RegionList regions;
46             std::list<UndoAction> region_states;
47             
48             Crossfades crossfades;
49             std::list<UndoAction> crossfade_states;
50             
51             State (std::string why) : ARDOUR::StateManager::State (why) {}
52             ~State ();
53         };
54         
55    public:
56         AudioPlaylist (Session&, const XMLNode&, bool hidden = false);
57         AudioPlaylist (Session&, string name, bool hidden = false);
58         AudioPlaylist (const AudioPlaylist&, string name, bool hidden = false);
59         AudioPlaylist (const AudioPlaylist&, jack_nframes_t start, jack_nframes_t cnt, string name, bool hidden = false);
60
61         void clear (bool with_delete = false, bool with_save = true);
62
63         jack_nframes_t read (Sample *dst, Sample *mixdown, float *gain_buffer, char * workbuf, jack_nframes_t start, jack_nframes_t cnt, uint32_t chan_n=0);
64
65         int set_state (const XMLNode&);
66         UndoAction get_memento() const;
67
68         sigc::signal<void,Crossfade *> NewCrossfade; 
69
70         template<class T> void foreach_crossfade (T *t, void (T::*func)(Crossfade *));
71         void crossfades_at (jack_nframes_t frame, Crossfades&);
72
73         template<class T> void apply_to_history (T& obj, void (T::*method)(const ARDOUR::StateManager::StateMap&, state_id_t)) {
74                 RegionLock rlock (this);
75                 (obj.*method) (states, _current_state_id);
76         }
77
78         bool destroy_region (Region*);
79
80         void drop_all_states ();
81
82     protected:
83
84         /* state management */
85
86         StateManager::State* state_factory (std::string) const;
87         Change restore_state (StateManager::State&);
88         void send_state_change (Change);
89
90         /* playlist "callbacks" */
91         void notify_crossfade_added (Crossfade *);
92         void flush_notifications ();
93
94                 void finalize_split_region (Region *orig, Region *left, Region *right);
95         
96         void refresh_dependents (Region& region);
97         void check_dependents (Region& region, bool norefresh);
98         void remove_dependents (Region& region);
99
100     protected:
101        ~AudioPlaylist (); /* public should use unref() */
102
103     private:
104        Crossfades      _crossfades;
105        Crossfades      _pending_xfade_adds;
106
107        void crossfade_invalidated (Crossfade*);
108        XMLNode& state (bool full_state);
109        void dump () const;
110
111        bool region_changed (Change, Region*);
112        void crossfade_changed (Change);
113        void add_crossfade (Crossfade&);
114 };
115
116 } /* namespace ARDOUR */
117
118 #endif  /* __ardour_audio_playlist_h__ */
119
120