Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
24 
25 #include <exception>
26 #include <time.h>
27 #include "ardour/audiosource.h"
28 #include "ardour/file_source.h"
29 
30 namespace ARDOUR {
31 
33  float samplerate;
34  uint16_t channels;
35  int64_t length;
36  std::string format_name;
37  int64_t timecode;
38  bool seekable; // non-seekable files must be converted/imported
39 };
40 
42 public:
43  virtual ~AudioFileSource ();
44 
45  std::string construct_peak_filepath (const std::string& audio_path, const bool in_session = false, const bool old_peak_name = false) const;
46 
47  static bool get_soundfile_info (const std::string& path, SoundFileInfo& _info, std::string& error);
48 
49  bool safe_file_extension (const std::string& path) const {
50  return safe_audio_file_extension(path);
51  }
52 
53  virtual samplepos_t last_capture_start_sample() const { return 0; }
54  virtual void mark_capture_start (samplepos_t) {}
55  virtual void mark_capture_end () {}
56  virtual void clear_capture_marks() {}
57  virtual bool one_of_several_channels () const { return false; }
58 
59  virtual void flush () = 0;
60  virtual int update_header (samplepos_t when, struct tm&, time_t) = 0;
61  virtual int flush_header () = 0;
62 
63  void mark_streaming_write_completed (const WriterLock& lock, Temporal::timecnt_t const & duration);
64 
66  void set_gain (float g, bool temporarily = false);
67 
68  XMLNode& get_state () const;
69  int set_state (const XMLNode&, int version);
70 
71  bool can_truncate_peaks() const { return true; }
72  bool can_be_analysed() const { return _length.is_positive(); }
73 
74  static bool safe_audio_file_extension (const std::string& path);
75 
76  static bool is_empty (Session&, std::string path);
77 
78  static void set_bwf_serial_number (int);
80 
82 
83 protected:
85  AudioFileSource (Session&, const std::string& path, Source::Flag flags);
86 
88  AudioFileSource (Session&, const std::string& path, const std::string& origin, Source::Flag flags,
89  SampleFormat samp_format, HeaderFormat hdr_format);
90 
92  AudioFileSource (Session&, const XMLNode&, bool must_exist = true);
93 
98  AudioFileSource (Session&, const std::string& path, Source::Flag flags, bool);
99 
100  int init (const std::string& idstr, bool must_exist);
101 
102  virtual void set_header_natural_position () = 0;
103  virtual void handle_header_position_change () {}
104 
106 
108 
109  static char bwf_country_code[3];
110  static char bwf_organization_code[4];
111  static char bwf_serial_number[13];
112 
115 };
116 
117 } // namespace ARDOUR
118 
119 
static samplecnt_t header_position_offset
static PBD::Signal< void()> HeaderPositionOffsetChanged
int init(const std::string &idstr, bool must_exist)
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)
void mark_streaming_write_completed(const WriterLock &lock, Temporal::timecnt_t const &duration)
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