Ardour  8.12
sndfilesource.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3  * Copyright (C) 2006-2008 Doug McLain <doug@nostar.net>
4  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
5  * Copyright (C) 2006-2017 Paul Davis <paul@linuxaudiosystems.com>
6  * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
7  * Copyright (C) 2013 John Emmas <john@creativepost.co.uk>
8  * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 
25 #ifndef __sndfile_source_h__
26 #define __sndfile_source_h__
27 
28 #include <sndfile.h>
29 
30 #include "ardour/audiofilesource.h"
31 #include "ardour/broadcast_info.h"
32 
33 namespace PBD {
34  class Progress;
35 }
36 
37 namespace ARDOUR {
38 
40  public:
42  SndFileSource (Session&, const std::string& path, int chn, Flag flags);
43 
44  /* Constructor to be called for new in-session files */
45  SndFileSource (Session&, const std::string& path, const std::string& origin,
46  SampleFormat samp_format, HeaderFormat hdr_format, samplecnt_t rate,
48 
49  /* Constructor to be called for recovering files being used for
50  * capture. They are in-session, they already exist, they should not
51  * be writable. They are an odd hybrid (from a constructor point of
52  * view) of the previous two constructors.
53  */
54  SndFileSource (Session&, const std::string& path, int chn);
55 
60 
62  SndFileSource (Session& s, const AudioFileSource& other, const std::string& path, bool use16bits = false, PBD::Progress* p = NULL);
63 
65 
66  float sample_rate () const;
67  int update_header (samplepos_t when, struct tm&, time_t);
68  int flush_header ();
69  void flush ();
70 
71  bool one_of_several_channels () const;
72  uint32_t channel_count () const { return _info.channels; }
73 
74  bool clamped_at_unity () const;
75 
77 
78  static int get_soundfile_info (const std::string& path, SoundFileInfo& _info, std::string& error_msg);
79 
80  protected:
81  void close ();
82 
83  void set_path (const std::string& p);
85 
89 
90  private:
91  SNDFILE* _sndfile;
92  SF_INFO _info;
94 
95  void init_sndfile ();
96  int open();
97  int setup_broadcast_info (samplepos_t when, struct tm&, time_t);
98  void file_closed ();
99 
103 };
104 
105 } // namespace ARDOUR
106 
107 #endif /* __sndfile_source_h__ */
108 
SndFileSource(Session &, const std::string &path, int chn, Flag flags)
samplecnt_t read_unlocked(Sample *dst, samplepos_t start, samplecnt_t cnt) const
samplecnt_t write_unlocked(Sample *dst, samplecnt_t cnt)
SndFileSource(Session &, const std::string &path, const std::string &origin, SampleFormat samp_format, HeaderFormat hdr_format, samplecnt_t rate, Flag flags=SndFileSource::default_writable_flags)
bool clamped_at_unity() const
int update_header(samplepos_t when, struct tm &, time_t)
void set_natural_position(timepos_t const &)
SndFileSource(Session &s, const AudioFileSource &other, const std::string &path, bool use16bits=false, PBD::Progress *p=NULL)
samplecnt_t write_float(Sample *data, samplepos_t pos, samplecnt_t cnt)
PBD::ScopedConnection header_position_connection
int setup_broadcast_info(samplepos_t when, struct tm &, time_t)
void set_path(const std::string &p)
samplecnt_t nondestructive_write_unlocked(Sample *dst, samplecnt_t cnt)
static int get_soundfile_info(const std::string &path, SoundFileInfo &_info, std::string &error_msg)
bool one_of_several_channels() const
uint32_t channel_count() const
Definition: sndfilesource.h:72
BroadcastInfo * _broadcast_info
Definition: sndfilesource.h:93
static const Source::Flag default_writable_flags
Definition: sndfilesource.h:76
SndFileSource(Session &, const std::string &path, int chn)
SndFileSource(Session &, const XMLNode &)
float sample_rate() const
void set_header_natural_position()
Definition: xml++.h:114
#define LIBARDOUR_API
PBD::PropertyDescriptor< timepos_t > start
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t
Definition: axis_view.h:42