Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
26 
27 #include <sndfile.h>
28 
29 #include "ardour/audiofilesource.h"
30 #include "ardour/broadcast_info.h"
31 
32 namespace PBD {
33  class Progress;
34 }
35 
36 namespace ARDOUR {
37 
39  public:
41  SndFileSource (Session&, const std::string& path, int chn, Flag flags);
42 
43  /* Constructor to be called for new in-session files */
44  SndFileSource (Session&, const std::string& path, const std::string& origin,
45  SampleFormat samp_format, HeaderFormat hdr_format, samplecnt_t rate,
47 
48  /* Constructor to be called for recovering files being used for
49  * capture. They are in-session, they already exist, they should not
50  * be writable. They are an odd hybrid (from a constructor point of
51  * view) of the previous two constructors.
52  */
53  SndFileSource (Session&, const std::string& path, int chn);
54 
59 
61  SndFileSource (Session& s, const AudioFileSource& other, const std::string& path, bool use16bits = false, PBD::Progress* p = NULL);
62 
64 
65  float sample_rate () const;
66  int update_header (samplepos_t when, struct tm&, time_t);
67  int flush_header ();
68  void flush ();
69 
70  bool one_of_several_channels () const;
71  uint32_t channel_count () const { return _info.channels; }
72 
73  bool clamped_at_unity () const;
74 
76 
77  static int get_soundfile_info (const std::string& path, SoundFileInfo& _info, std::string& error_msg);
78 
79  protected:
80  void close ();
81 
82  void set_path (const std::string& p);
84 
88 
89  private:
90  SNDFILE* _sndfile;
91  SF_INFO _info;
93 
94  void init_sndfile ();
95  int open();
96  int setup_broadcast_info (samplepos_t when, struct tm&, time_t);
97  void file_closed ();
98 
102 };
103 
104 } // namespace ARDOUR
105 
106 
SndFileSource(Session &, const std::string &path, int chn, Flag flags)
samplecnt_t read_unlocked(Sample *dst, samplepos_t start, samplecnt_t cnt) const
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)
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 const *src, 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:71
BroadcastInfo * _broadcast_info
Definition: sndfilesource.h:92
static const Source::Flag default_writable_flags
Definition: sndfilesource.h:75
SndFileSource(Session &, const std::string &path, int chn)
SndFileSource(Session &, const XMLNode &)
float sample_rate() const
samplecnt_t write_unlocked(Sample const *dst, samplecnt_t cnt)
samplecnt_t write_float(Sample const *data, samplepos_t pos, samplecnt_t cnt)
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