2 Copyright (C) 2008 Paul Davis
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.
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.
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.
21 #ifndef __ardour_export_utilities_h__
22 #define __ardour_export_utilities_h__
24 #include <samplerate.h>
26 #include <ardour/graph.h>
27 #include <ardour/types.h>
28 #include <ardour/ardour.h>
29 #include <ardour/export_format_base.h>
30 #include <ardour/runtime_functions.h>
37 /* Sample rate converter */
39 class SampleRateConverter : public GraphSinkVertex<float, float>
42 SampleRateConverter (uint32_t channels, nframes_t in_rate, nframes_t out_rate, int quality);
43 ~SampleRateConverter ();
46 nframes_t process (float * data, nframes_t frames);
52 nframes_t leftover_frames;
53 nframes_t max_leftover_frames;
58 float * leftover_data;
61 nframes_t data_out_size;
67 /* Sample format converter */
69 template <typename TOut>
70 class SampleFormatConverter : public GraphSinkVertex<float, TOut>
73 SampleFormatConverter (uint32_t channels, ExportFormatBase::DitherType type = ExportFormatBase::D_None, int data_width_ = 0);
74 ~SampleFormatConverter ();
76 void set_clip_floats (bool yn) { clip_floats = yn; }
79 nframes_t process (float * data, nframes_t frames);
85 nframes_t data_out_size;
94 class PeakReader : public GraphSinkVertex<float, float>
97 PeakReader (uint32_t channels) : channels (channels), peak (0) {}
100 float get_peak () { return peak; }
103 nframes_t process (float * data, nframes_t frames)
105 peak = compute_peak (data, channels * frames, peak);
106 return piped_to->write (data, frames);
116 class Normalizer : public GraphSinkVertex<float, float>
119 Normalizer (uint32_t channels, float target_dB);
122 void set_peak (float peak);
125 nframes_t process (float * data, nframes_t frames);
137 class NullSink : public GraphSink<float>
140 nframes_t write (float * data, nframes_t frames) { return frames; }
144 } // namespace ARDOUR
146 #endif /* __ardour_export_utilities_h__ */