Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
20 
21 #include <vector>
22 #include <sndfile.h>
23 
24 #include <ltc.h>
25 
27 #include "ardour/types.h"
28 
29 namespace ARDOUR {
30 
32 {
33 public:
34  LTCReader (int expected_apv, LTC_TV_STANDARD tv_standard = LTC_TV_FILM_24);
36 
37  void write (float const*, samplecnt_t n_samples, samplepos_t pos = -1);
39 
40  samplepos_t read (uint32_t& hh, uint32_t& mm, uint32_t& ss, uint32_t& ff, samplecnt_t& len);
41 
42 private:
45 };
46 
48 {
49 public:
50  struct LTCMap {
51  double framepos_sec; // relative to start of file
52  double timecode_sec; // timecode
53 
54  LTCMap (double p, double t) {
55  framepos_sec = p;
56  timecode_sec = t;
57  }
58  };
59 
60  LTCFileReader (std::string path, double expected_fps, LTC_TV_STANDARD tv_standard = LTC_TV_FILM_24);
62 
63  uint32_t channels () const { return _info.channels; }
64  std::vector<LTCMap> read_ltc (uint32_t channel, uint32_t max_frames = 1);
65 
66 private:
67  int open();
68  void close ();
69 
70  std::string _path;
71 
72  double _expected_fps;
74 
75  SNDFILE* _sndfile;
76  SF_INFO _info;
77 
81  float _apv;
82 
83 };
84 
85 } // namespace ARDOUR
86 
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)