Fix the horrible mess that was anything related to sources and paths.
[ardour.git] / libs / ardour / ardour / export_processor.h
1 /*
2     Copyright (C) 2008 Paul Davis
3     Author: Sakari Bergen
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __ardour_export_processor_h__
22 #define __ardour_export_processor_h__
23
24 #include <vector>
25
26 #include <boost/smart_ptr.hpp>
27 #include <glibmm/ustring.h>
28
29 #include <ardour/graph.h>
30 #include <ardour/export_file_io.h>
31 #include <ardour/export_utilities.h>
32
33 using Glib::ustring;
34 using std::list;
35
36 namespace ARDOUR
37 {
38
39 class Session;
40 class ExportStatus;
41 class ExportFilename;
42 class ExportFormatSpecification;
43
44 /// Sets up components for export post processing
45 class ExportProcessor
46 {
47   private:
48         /* Typedefs for utility processors */
49         
50         typedef boost::shared_ptr<SampleRateConverter> SRConverterPtr;
51         typedef boost::shared_ptr<PeakReader> PReaderPtr;
52         typedef boost::shared_ptr<Normalizer> NormalizerPtr;
53         typedef boost::shared_ptr<ExportTempFile> TempFilePtr;
54         
55         typedef GraphSink<float> FloatSink;
56         typedef boost::shared_ptr<FloatSink> FloatSinkPtr;
57         typedef std::vector<FloatSinkPtr> FloatSinkVect;
58         
59         typedef boost::shared_ptr<ExportFilename> FilenamePtr;
60         typedef boost::shared_ptr<ExportFormatSpecification const> FormatPtr;
61         
62         typedef boost::shared_ptr<ExportFileWriter> FileWriterPtr;
63         typedef std::list<FileWriterPtr> FileWriterList;
64         
65   public:
66
67         ExportProcessor (Session & session);
68         ~ExportProcessor ();
69         ExportProcessor * copy() { return new ExportProcessor (session); }
70
71         /// Do preparations for exporting
72         /** Should be called before process
73          * @return 0 on success
74          */
75         int prepare (FormatPtr format, FilenamePtr fname, uint32_t chans, bool split = false, nframes_t start = 0);
76         
77         /// Process data
78         /** @param frames frames to process @return frames written **/
79         nframes_t process (float * data, nframes_t frames);
80         
81         /** should be called after all data is given to process **/
82         void prepare_post_processors ();
83         
84         void write_files ();
85         
86         static sigc::signal<void, Glib::ustring> WritingFile;
87         
88   private:
89         
90         void reset ();
91         
92         Session &                       session;
93         boost::shared_ptr<ExportStatus> status;
94         
95         /* these are initalized in prepare() */
96         
97         FilenamePtr      filename;
98         NormalizerPtr    normalizer;
99         SRConverterPtr   src;
100         PReaderPtr       peak_reader;
101         TempFilePtr      temp_file;
102         FloatSinkVect    file_sinks;
103         FileWriterList   writer_list;
104         
105         /* general info */
106         
107         uint32_t         channels;
108         nframes_t        blocksize;
109         nframes_t        frame_rate;
110         
111         /* Processing */
112         
113         bool             tag;
114         bool             broadcast_info;
115         bool             split_files;
116         bool             normalize;
117         bool             trim_beginning;
118         bool             trim_end;
119         nframes_t        silence_beginning;
120         nframes_t        silence_end;
121         
122         /* Progress info */
123         
124         nframes_t        temp_file_position;
125         nframes_t        temp_file_length;
126 };
127
128 } // namespace ARDOUR
129
130 #endif /* __ardour_export_processor_h__ */