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>
29 struct SoundFileInfo {
33 std::string format_name;
37 class AudioFileSource : public AudioSource {
44 RemovableIfEmpty = 0x10,
45 RemoveAtDestroy = 0x20,
50 virtual ~AudioFileSource ();
52 int set_name (string newname, bool destructive);
54 string path() const { return _path; }
55 string peak_path (string audio_path);
56 string old_peak_path (string audio_path);
58 static void set_peak_dir (string dir) { peak_dir = dir; }
60 static bool get_soundfile_info (string path, SoundFileInfo& _info, string& error);
62 void set_allow_remove_if_empty (bool yn);
63 void mark_for_remove();
65 /* this block of methods do nothing for regular file sources, but are significant
66 for files used in destructive recording.
69 virtual nframes_t last_capture_start_frame() const { return 0; }
70 virtual void mark_capture_start (nframes_t) {}
71 virtual void mark_capture_end () {}
72 virtual void clear_capture_marks() {}
74 virtual int update_header (nframes_t when, struct tm&, time_t) = 0;
75 virtual int flush_header () = 0;
77 int move_to_trash (const string trash_dir_name);
79 static bool is_empty (Session&, string path);
80 void mark_streaming_write_completed ();
82 void mark_take (string);
83 string take_id() const { return _take_id; }
85 bool is_embedded() const { return _is_embedded; }
87 static void set_bwf_serial_number (int);
89 static void set_search_path (string);
90 static void set_header_position_offset (nframes_t offset );
92 int setup_peakfile ();
94 static sigc::signal<void> HeaderPositionOffsetChanged;
96 XMLNode& get_state ();
97 int set_state (const XMLNode&);
99 bool destructive() const { return (_flags & Destructive); }
100 virtual bool set_destructive (bool yn) { return false; }
102 /* this should really be protected, but C++ is getting stricter
103 and creating slots from protected member functions is starting
107 virtual void handle_header_position_change ();
111 /* constructor to be called for existing external-to-session files */
113 AudioFileSource (Session&, std::string path, Flag flags);
115 /* constructor to be called for new in-session files */
117 AudioFileSource (Session&, std::string path, Flag flags,
118 SampleFormat samp_format, HeaderFormat hdr_format);
120 /* constructor to be called for existing in-session files */
122 AudioFileSource (Session&, const XMLNode&);
124 int init (string idstr, bool must_exist);
130 int64_t timeline_position;
134 static bool determine_embeddedness(string path);
136 static string peak_dir;
137 static string search_path;
139 static char bwf_country_code[3];
140 static char bwf_organization_code[4];
141 static char bwf_serial_number[13];
143 static uint64_t header_position_offset;
145 virtual void set_timeline_position (int64_t pos);
146 virtual void set_header_timeline_position () = 0;
148 bool find (std::string path, bool must_exist, bool& is_new);
149 bool removable() const;
150 bool writable() const { return _flags & Writable; }
153 } // namespace ARDOUR
155 #endif /* __ardour_audiofilesource_h__ */