continue with MTC debugging
[ardour.git] / libs / ardour / ardour / export.h
1 /*
2     Copyright (C) 2000-2007 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_export_h__
21 #define __ardour_export_h__
22
23 #include <map>
24 #include <vector>
25 #include <string>
26
27 #include <sigc++/signal.h>
28
29 #include <sndfile.h>
30 #include <samplerate.h>
31
32 #include "ardour/ardour.h"
33 #include "ardour/gdither.h"
34
35 namespace ARDOUR
36 {
37         class Port;
38
39         typedef std::pair<Port *, uint32_t> PortChannelPair;
40         typedef std::map<uint32_t, std::vector<PortChannelPair> > ExportPortMap;
41
42         struct ExportSpecification : public SF_INFO, public sigc::trackable {
43
44                 ExportSpecification();
45                 ~ExportSpecification ();
46
47                 void init ();
48                 void clear ();
49
50                 int prepare (nframes_t blocksize, nframes_t frame_rate);
51
52                 int process (nframes_t nframes);
53
54                 /* set by the user */
55
56                 std::string    path;
57                 nframes_t      sample_rate;
58
59                 int            src_quality;
60                 SNDFILE*       out;
61                 uint32_t       channels;
62                 ExportPortMap  port_map;
63                 nframes_t      start_frame;
64                 nframes_t      end_frame;
65                 GDitherType    dither_type;
66                 bool           do_freewheel;
67
68                 /* used exclusively during export */
69
70                 nframes_t      frame_rate;
71                 GDither        dither;
72                 float*         dataF;
73                 float*         dataF2;
74                 float*         leftoverF;
75                 nframes_t      leftover_frames;
76                 nframes_t      max_leftover_frames;
77                 void*          output_data;
78                 nframes_t      out_samples_max;
79                 uint32_t       sample_bytes;
80                 uint32_t       data_width;
81
82                 nframes_t      total_frames;
83                 SF_INFO        sfinfo;
84                 SRC_DATA       src_data;
85                 SRC_STATE*     src_state;
86                 nframes_t      pos;
87
88                 sigc::connection freewheel_connection;
89
90                 /* shared between UI thread and audio thread */
91
92                 volatile float progress;  /* audio thread sets this */
93                 volatile bool  stop;      /* UI sets this */
94                 volatile bool  running;   /* audio thread sets to false when export is done */
95
96                 int status;
97         };
98
99 } // namespace ARDOUR
100
101 #endif /* __ardour_export_h__ */