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 __ardour_audiofilesource_h__
21 #define __ardour_audiofilesource_h__
25 #include "ardour/audiosource.h"
26 #include "ardour/file_source.h"
30 struct SoundFileInfo {
34 std::string format_name;
38 class AudioFileSource : public AudioSource, public FileSource {
40 virtual ~AudioFileSource ();
42 bool set_name (const std::string& newname) {
43 return (set_source_name(newname, destructive()) == 0);
46 std::string peak_path (std::string audio_path);
47 std::string find_broken_peakfile (std::string missing_peak_path,
48 std::string audio_path);
50 static void set_peak_dir (std::string dir) { peak_dir = dir; }
52 static bool get_soundfile_info (std::string path, SoundFileInfo& _info, std::string& error);
54 bool safe_file_extension (const std::string& path) const {
55 return safe_audio_file_extension(path);
58 /* this block of methods do nothing for regular file sources, but are significant
59 for files used in destructive recording.
61 virtual framepos_t last_capture_start_frame() const { return 0; }
62 virtual void mark_capture_start (framepos_t) {}
63 virtual void mark_capture_end () {}
64 virtual void clear_capture_marks() {}
65 virtual bool one_of_several_channels () const { return false; }
67 virtual void flush () = 0;
68 virtual int update_header (framepos_t when, struct tm&, time_t) = 0;
69 virtual int flush_header () = 0;
71 void mark_streaming_write_completed ();
73 int setup_peakfile ();
75 XMLNode& get_state ();
76 int set_state (const XMLNode&, int version);
78 bool can_truncate_peaks() const { return !destructive(); }
79 bool can_be_analysed() const { return _length > 0; }
81 static bool safe_audio_file_extension (const std::string& path);
83 static bool is_empty (Session&, std::string path);
85 static void set_bwf_serial_number (int);
86 static void set_header_position_offset (framecnt_t offset);
88 static PBD::Signal0<void> HeaderPositionOffsetChanged;
91 /** Constructor to be called for existing external-to-session files */
92 AudioFileSource (Session&, const std::string& path, Source::Flag flags);
94 /** Constructor to be called for new in-session files */
95 AudioFileSource (Session&, const std::string& path, const std::string& origin, Source::Flag flags,
96 SampleFormat samp_format, HeaderFormat hdr_format);
98 /** Constructor to be called for existing in-session files */
99 AudioFileSource (Session&, const XMLNode&, bool must_exist = true);
101 int init (const std::string& idstr, bool must_exist);
103 virtual void set_header_timeline_position () = 0;
104 virtual void handle_header_position_change () {}
106 int move_dependents_to_trash();
108 static Sample* get_interleave_buffer (framecnt_t size);
110 static std::string peak_dir;
112 static char bwf_country_code[3];
113 static char bwf_organization_code[4];
114 static char bwf_serial_number[13];
116 /** Kept up to date with the position of the session location start */
117 static framecnt_t header_position_offset;
120 std::string old_peak_path (std::string audio_path);
121 std::string broken_peak_path (std::string audio_path);
124 } // namespace ARDOUR
126 #endif /* __ardour_audiofilesource_h__ */