ardour
audiofilesource.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 Paul Davis
3 
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.
8 
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.
13 
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.
17 
18 */
19 
20 #ifndef __ardour_audiofilesource_h__
21 #define __ardour_audiofilesource_h__
22 
23 #include <exception>
24 #include <time.h>
25 #include "ardour/audiosource.h"
26 #include "ardour/file_source.h"
27 
28 namespace ARDOUR {
29 
31  float samplerate;
32  uint16_t channels;
33  int64_t length;
34  std::string format_name;
35  int64_t timecode;
36 };
37 
39 public:
40  virtual ~AudioFileSource ();
41 
42  std::string peak_path (std::string audio_path);
43  std::string find_broken_peakfile (std::string missing_peak_path,
44  std::string audio_path);
45 
46  static void set_peak_dir (std::string dir) { peak_dir = dir; }
47 
48  static bool get_soundfile_info (std::string path, SoundFileInfo& _info, std::string& error);
49 
50  bool safe_file_extension (const std::string& path) const {
51  return safe_audio_file_extension(path);
52  }
53 
54  /* this block of methods do nothing for regular file sources, but are significant
55  for files used in destructive recording.
56  */
57  virtual framepos_t last_capture_start_frame() const { return 0; }
58  virtual void mark_capture_start (framepos_t) {}
59  virtual void mark_capture_end () {}
60  virtual void clear_capture_marks() {}
61  virtual bool one_of_several_channels () const { return false; }
62 
63  virtual void flush () = 0;
64  virtual int update_header (framepos_t when, struct tm&, time_t) = 0;
65  virtual int flush_header () = 0;
66 
67  void mark_streaming_write_completed (const Lock& lock);
68 
69  int setup_peakfile ();
70 
71  XMLNode& get_state ();
72  int set_state (const XMLNode&, int version);
73 
74  bool can_truncate_peaks() const { return !destructive(); }
75  bool can_be_analysed() const { return _length > 0; }
76 
77  static bool safe_audio_file_extension (const std::string& path);
78 
79  static bool is_empty (Session&, std::string path);
80 
81  static void set_bwf_serial_number (int);
82  static void set_header_position_offset (framecnt_t offset);
83 
84  static PBD::Signal0<void> HeaderPositionOffsetChanged;
85 
86 protected:
88  AudioFileSource (Session&, const std::string& path, Source::Flag flags);
89 
91  AudioFileSource (Session&, const std::string& path, const std::string& origin, Source::Flag flags,
92  SampleFormat samp_format, HeaderFormat hdr_format);
93 
95  AudioFileSource (Session&, const XMLNode&, bool must_exist = true);
96 
101  AudioFileSource (Session&, const std::string& path, Source::Flag flags, bool);
102 
103  int init (const std::string& idstr, bool must_exist);
104 
105  virtual void set_header_timeline_position () = 0;
106  virtual void handle_header_position_change () {}
107 
108  int move_dependents_to_trash();
109 
110  static Sample* get_interleave_buffer (framecnt_t size);
111 
112  static std::string peak_dir;
113 
114  static char bwf_country_code[3];
115  static char bwf_organization_code[4];
116  static char bwf_serial_number[13];
117 
120 
121  private:
122  std::string old_peak_path (std::string audio_path);
123  std::string broken_peak_path (std::string audio_path);
124 };
125 
126 } // namespace ARDOUR
127 
128 #endif /* __ardour_audiofilesource_h__ */
129 
bool can_be_analysed() const
HeaderFormat
Definition: types.h:475
bool can_truncate_peaks() const
static framecnt_t header_position_offset
virtual bool one_of_several_channels() const
virtual void handle_header_position_change()
LIBPBD_API Transmitter error
#define origin
static std::string peak_dir
int64_t framecnt_t
Definition: types.h:76
static PBD::Signal0< void > HeaderPositionOffsetChanged
float Sample
Definition: types.h:54
bool safe_file_extension(const std::string &path) const
Definition: amp.h:29
int64_t framepos_t
Definition: types.h:66
#define LIBARDOUR_API
virtual framepos_t last_capture_start_frame() const
SampleFormat
Definition: types.h:460
Definition: xml++.h:95
static void set_peak_dir(std::string dir)
virtual void mark_capture_start(framepos_t)
virtual void clear_capture_marks()
virtual void mark_capture_end()
LIBARDOUR_API bool init(bool with_vst, bool try_optimization, const char *localedir)
Definition: globals.cc:376