Remove random crazy comment fragment.
[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 namespace ARDOUR
34 {
35
36 class Session;
37 class ExportStatus;
38 class ExportFilename;
39 class ExportFormatSpecification;
40
41 /// Sets up components for export post processing
42 class ExportProcessor
43 {
44   private:
45         /* Typedefs for utility processors */
46
47         typedef boost::shared_ptr<SampleRateConverter> SRConverterPtr;
48         typedef boost::shared_ptr<PeakReader> PReaderPtr;
49         typedef boost::shared_ptr<Normalizer> NormalizerPtr;
50         typedef boost::shared_ptr<ExportTempFile> TempFilePtr;
51
52         typedef GraphSink<float> FloatSink;
53         typedef boost::shared_ptr<FloatSink> FloatSinkPtr;
54         typedef std::vector<FloatSinkPtr> FloatSinkVect;
55
56         typedef boost::shared_ptr<ExportFilename> FilenamePtr;
57         typedef boost::shared_ptr<ExportFormatSpecification const> FormatPtr;
58
59         typedef boost::shared_ptr<ExportFileWriter> FileWriterPtr;
60         typedef std::list<FileWriterPtr> FileWriterList;
61
62   public:
63
64         ExportProcessor (Session & session);
65         ~ExportProcessor ();
66         ExportProcessor * copy() { return new ExportProcessor (session); }
67
68         /// Do preparations for exporting
69         /** Should be called before process
70          * @return 0 on success
71          */
72         int prepare (FormatPtr format, FilenamePtr fname, uint32_t chans, bool split = false, nframes_t start = 0);
73
74         /// Process data
75         /** @param frames frames to process @return frames written **/
76         nframes_t process (float * data, nframes_t frames);
77
78         /** should be called after all data is given to process **/
79         void prepare_post_processors ();
80
81         void write_files ();
82
83         static sigc::signal<void, Glib::ustring> WritingFile;
84
85   private:
86
87         void reset ();
88
89         Session &                       session;
90         boost::shared_ptr<ExportStatus> status;
91
92         /* these are initalized in prepare() */
93
94         FilenamePtr      filename;
95         NormalizerPtr    normalizer;
96         SRConverterPtr   src;
97         PReaderPtr       peak_reader;
98         TempFilePtr      temp_file;
99         FloatSinkVect    file_sinks;
100         FileWriterList   writer_list;
101
102         /* general info */
103
104         uint32_t         channels;
105         nframes_t        blocksize;
106         nframes_t        frame_rate;
107
108         /* Processing */
109
110         bool             tag;
111         bool             broadcast_info;
112         bool             split_files;
113         bool             normalize;
114         bool             trim_beginning;
115         bool             trim_end;
116         nframes_t        silence_beginning;
117         nframes_t        silence_end;
118
119         /* Progress info */
120
121         nframes_t        temp_file_position;
122         nframes_t        temp_file_length;
123 };
124
125 } // namespace ARDOUR
126
127 #endif /* __ardour_export_processor_h__ */