2 Copyright (C) 2006 Paul Davis
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.
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.
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.
20 #ifndef __sndfile_source_h__
21 #define __sndfile_source_h__
25 #include "ardour/audiofilesource.h"
26 #include "ardour/broadcast_info.h"
27 #include "pbd/sndfile_manager.h"
31 class LIBARDOUR_API SndFileSource : public AudioFileSource {
33 /** Constructor to be called for existing external-to-session files */
34 SndFileSource (Session&, const std::string& path, int chn, Flag flags);
36 /* Constructor to be called for new in-session files */
37 SndFileSource (Session&, const std::string& path, const std::string& origin,
38 SampleFormat samp_format, HeaderFormat hdr_format, framecnt_t rate,
39 Flag flags = SndFileSource::default_writable_flags);
41 /* Constructor to be called for recovering files being used for
42 * capture. They are in-session, they already exist, they should not
43 * be writable. They are an odd hybrid (from a constructor point of
44 * view) of the previous two constructors.
46 SndFileSource (Session&, const std::string& path, int chn);
48 /** Constructor to be called for existing in-session files during
51 SndFileSource (Session&, const XMLNode&);
55 float sample_rate () const;
56 int update_header (framepos_t when, struct tm&, time_t);
60 framepos_t natural_position () const;
62 framepos_t last_capture_start_frame() const;
63 void mark_capture_start (framepos_t);
64 void mark_capture_end ();
65 void clear_capture_marks();
67 bool set_destructive (bool yn);
69 bool one_of_several_channels () const;
71 bool clamped_at_unity () const;
73 static void setup_standard_crossfades (Session const &, framecnt_t sample_rate);
74 static const Source::Flag default_writable_flags;
76 static int get_soundfile_info (const std::string& path, SoundFileInfo& _info, std::string& error_msg);
78 void release_descriptor ();
81 void set_path (const std::string& p);
82 void set_header_timeline_position ();
84 framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const;
85 framecnt_t write_unlocked (Sample *dst, framecnt_t cnt);
86 framecnt_t write_float (Sample* data, framepos_t pos, framecnt_t cnt);
89 PBD::SndFileDescriptor* _descriptor;
91 BroadcastInfo *_broadcast_info;
95 int setup_broadcast_info (framepos_t when, struct tm&, time_t);
100 static framecnt_t xfade_frames;
101 static gain_t* out_coefficient;
102 static gain_t* in_coefficient;
106 framepos_t capture_start_frame;
107 framepos_t file_pos; // unit is frames
110 framecnt_t crossfade (Sample* data, framecnt_t cnt, int dir);
111 void set_timeline_position (framepos_t);
112 framecnt_t destructive_write_unlocked (Sample *dst, framecnt_t cnt);
113 framecnt_t nondestructive_write_unlocked (Sample *dst, framecnt_t cnt);
114 void handle_header_position_change ();
115 PBD::ScopedConnection header_position_connection;
116 PBD::ScopedConnection file_manager_connection;
119 } // namespace ARDOUR
121 #endif /* __sndfile_source_h__ */