Ardour  8.12
audiofilesource.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2013 John Emmas <john@creativepost.co.uk>
6  * Copyright (C) 2015-2016 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __ardour_audiofilesource_h__
24 #define __ardour_audiofilesource_h__
25 
26 #include <exception>
27 #include <time.h>
28 #include "ardour/audiosource.h"
29 #include "ardour/file_source.h"
30 
31 namespace ARDOUR {
32 
34  float samplerate;
35  uint16_t channels;
36  int64_t length;
37  std::string format_name;
38  int64_t timecode;
39  bool seekable; // non-seekable files must be converted/imported
40 };
41 
43 public:
44  virtual ~AudioFileSource ();
45 
46  std::string construct_peak_filepath (const std::string& audio_path, const bool in_session = false, const bool old_peak_name = false) const;
47 
48  static bool get_soundfile_info (const 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  virtual samplepos_t last_capture_start_sample() const { return 0; }
55  virtual void mark_capture_start (samplepos_t) {}
56  virtual void mark_capture_end () {}
57  virtual void clear_capture_marks() {}
58  virtual bool one_of_several_channels () const { return false; }
59 
60  virtual void flush () = 0;
61  virtual int update_header (samplepos_t when, struct tm&, time_t) = 0;
62  virtual int flush_header () = 0;
63 
65 
67  void set_gain (float g, bool temporarily = false);
68 
69  XMLNode& get_state () const;
70  int set_state (const XMLNode&, int version);
71 
72  bool can_truncate_peaks() const { return true; }
73  bool can_be_analysed() const { return _length.is_positive(); }
74 
75  static bool safe_audio_file_extension (const std::string& path);
76 
77  static bool is_empty (Session&, std::string path);
78 
79  static void set_bwf_serial_number (int);
81 
82  static PBD::Signal0<void> HeaderPositionOffsetChanged;
83 
84 protected:
86  AudioFileSource (Session&, const std::string& path, Source::Flag flags);
87 
89  AudioFileSource (Session&, const std::string& path, const std::string& origin, Source::Flag flags,
90  SampleFormat samp_format, HeaderFormat hdr_format);
91 
93  AudioFileSource (Session&, const XMLNode&, bool must_exist = true);
94 
99  AudioFileSource (Session&, const std::string& path, Source::Flag flags, bool);
100 
101  int init (const std::string& idstr, bool must_exist);
102 
103  virtual void set_header_natural_position () = 0;
104  virtual void handle_header_position_change () {}
105 
107 
109 
110  static char bwf_country_code[3];
111  static char bwf_organization_code[4];
112  static char bwf_serial_number[13];
113 
116 };
117 
118 } // namespace ARDOUR
119 
120 #endif /* __ardour_audiofilesource_h__ */
121 
static samplecnt_t header_position_offset
int init(const std::string &idstr, bool must_exist)
void mark_streaming_write_completed(const WriterLock &lock)
static PBD::Signal0< void > HeaderPositionOffsetChanged
bool can_be_analysed() const
AudioFileSource(Session &, const std::string &path, Source::Flag flags)
AudioFileSource(Session &, const XMLNode &, bool must_exist=true)
int set_state(const XMLNode &, int version)
void set_gain(float g, bool temporarily=false)
static bool get_soundfile_info(const std::string &path, SoundFileInfo &_info, std::string &error)
std::string construct_peak_filepath(const std::string &audio_path, const bool in_session=false, const bool old_peak_name=false) const
static void set_bwf_serial_number(int)
bool safe_file_extension(const std::string &path) const
virtual void mark_capture_start(samplepos_t)
virtual void set_header_natural_position()=0
virtual void flush()=0
virtual samplepos_t last_capture_start_sample() const
static bool safe_audio_file_extension(const std::string &path)
static bool is_empty(Session &, std::string path)
AudioFileSource(Session &, const std::string &path, const std::string &origin, Source::Flag flags, SampleFormat samp_format, HeaderFormat hdr_format)
static void set_header_position_offset(samplecnt_t offset)
virtual int flush_header()=0
virtual bool one_of_several_channels() const
static Sample * get_interleave_buffer(samplecnt_t size)
virtual void clear_capture_marks()
virtual void handle_header_position_change()
virtual void mark_capture_end()
virtual int update_header(samplepos_t when, struct tm &, time_t)=0
XMLNode & get_state() const
AudioFileSource(Session &, const std::string &path, Source::Flag flags, bool)
bool can_truncate_peaks() const
Glib::Threads::RWLock::WriterLock WriterLock
Definition: xml++.h:114
#define LIBARDOUR_API
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t
Transmitter error