Ardour  8.12
ltc_file_reader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2019 Robin Gareus <robin@gareus.org>
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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef __libardour_ltc_file_reader_h__
20 #define __libardour_ltc_file_reader_h__
21 
22 #include <vector>
23 #include <sndfile.h>
24 
25 #include <ltc.h>
26 
28 #include "ardour/types.h"
29 
30 namespace ARDOUR {
31 
33 {
34 public:
35  LTCReader (int expected_apv, LTC_TV_STANDARD tv_standard = LTC_TV_FILM_24);
37 
38  void write (float const*, samplecnt_t n_samples, samplepos_t pos = -1);
40 
41  samplepos_t read (uint32_t& hh, uint32_t& mm, uint32_t& ss, uint32_t& ff, samplecnt_t& len);
42 
43 private:
46 };
47 
49 {
50 public:
51  struct LTCMap {
52  double framepos_sec; // relative to start of file
53  double timecode_sec; // timecode
54 
55  LTCMap (double p, double t) {
56  framepos_sec = p;
57  timecode_sec = t;
58  }
59  };
60 
61  LTCFileReader (std::string path, double expected_fps, LTC_TV_STANDARD tv_standard = LTC_TV_FILM_24);
63 
64  uint32_t channels () const { return _info.channels; }
65  std::vector<LTCMap> read_ltc (uint32_t channel, uint32_t max_frames = 1);
66 
67 private:
68  int open();
69  void close ();
70 
71  std::string _path;
72 
73  double _expected_fps;
75 
76  SNDFILE* _sndfile;
77  SF_INFO _info;
78 
82  float _apv;
83 
84 };
85 
86 } // namespace ARDOUR
87 
88 #endif /* __libardour_ltc_file_reader_h__ */
std::vector< LTCMap > read_ltc(uint32_t channel, uint32_t max_frames=1)
LTCFileReader(std::string path, double expected_fps, LTC_TV_STANDARD tv_standard=LTC_TV_FILM_24)
uint32_t channels() const
LTC_TV_STANDARD _ltc_tv_standard
void raw_write(ltcsnd_sample_t *, size_t, ltc_off_t)
LTCDecoder * _decoder
void write(float const *, samplecnt_t n_samples, samplepos_t pos=-1)
LTCReader(int expected_apv, LTC_TV_STANDARD tv_standard=LTC_TV_FILM_24)
samplepos_t read(uint32_t &hh, uint32_t &mm, uint32_t &ss, uint32_t &ff, samplecnt_t &len)
samplecnt_t _position
#define LIBARDOUR_API
libltc - en+decode linear timecode
unsigned char ltcsnd_sample_t
Definition: ltc.h:82
long long int ltc_off_t
Definition: ltc.h:87
LTC_TV_STANDARD
Definition: ltc.h:257
@ LTC_TV_FILM_24
24fps
Definition: ltc.h:261
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t
LTCMap(double p, double t)