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;
36 class AudioFileSource : public AudioSource {
43 RemovableIfEmpty = 0x10,
44 RemoveAtDestroy = 0x20,
49 virtual ~AudioFileSource ();
51 int set_name (string newname, bool destructive);
53 string path() const { return _path; }
54 string peak_path (string audio_path);
55 string old_peak_path (string audio_path);
57 static void set_peak_dir (string dir) { peak_dir = dir; }
59 /* factory for an existing but not-used-in-session audio file. this exists
60 because there maybe multiple back-end derivations of AudioFileSource,
61 some of which can handle formats that cannot be handled by others.
62 For example, CoreAudioFileSource can handle MP3 files, which SndFileSource
66 static AudioFileSource* create (const string& path_plus_channel, Flag flags = Flag (0));
67 static AudioFileSource* create (const XMLNode&);
69 static bool get_soundfile_info (string path, SoundFileInfo& _info, string& error);
71 void set_allow_remove_if_empty (bool yn);
72 void mark_for_remove();
74 /* this block of methods do nothing for regular file sources, but are significant
75 for files used in destructive recording.
78 virtual jack_nframes_t last_capture_start_frame() const { return 0; }
79 virtual void mark_capture_start (jack_nframes_t) {}
80 virtual void mark_capture_end () {}
81 virtual void clear_capture_marks() {}
83 virtual int update_header (jack_nframes_t when, struct tm&, time_t) = 0;
84 virtual int flush_header () = 0;
86 int move_to_trash (const string trash_dir_name);
88 static bool is_empty (string path);
89 void mark_streaming_write_completed ();
91 void mark_take (string);
92 string take_id() const { return _take_id; }
94 static void set_bwf_country_code (string x);
95 static void set_bwf_organization_code (string x);
96 static void set_bwf_serial_number (int);
98 static void set_search_path (string);
99 static void set_header_position_offset (jack_nframes_t offset );
101 static sigc::signal<void> HeaderPositionOffsetChanged;
103 XMLNode& get_state ();
104 int set_state (const XMLNode&);
106 /* this should really be protected, but C++ is getting stricter
107 and creating slots from protected member functions is starting
111 virtual void handle_header_position_change () {}
115 /* constructor to be called for existing external-to-session files */
117 AudioFileSource (std::string path, Flag flags);
119 /* constructor to be called for new in-session files */
121 AudioFileSource (std::string path, Flag flags,
122 SampleFormat samp_format, HeaderFormat hdr_format);
124 /* constructor to be called for existing in-session files */
126 AudioFileSource (const XMLNode&);
128 int init (string idstr, bool must_exist);
134 bool allow_remove_if_empty;
135 uint64_t timeline_position;
137 static string peak_dir;
138 static string search_path;
140 static char bwf_country_code[3];
141 static char bwf_organization_code[4];
142 static char bwf_serial_number[13];
144 static uint64_t header_position_offset;
146 virtual void set_timeline_position (jack_nframes_t pos);
147 virtual void set_header_timeline_position () = 0;
149 bool find (std::string path, bool must_exist, bool& is_new);
150 bool removable() const;
151 bool writable() const { return _flags & Writable; }
154 } // namespace ARDOUR
156 #endif /* __ardour_audiofilesource_h__ */