Make some musical operations on music-locked regions operate in beats.
[ardour.git] / libs / ardour / ardour / ltc_file_reader.h
1 /*
2     Copyright (C) 2015 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
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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
27 #include "ardour/libardour_visibility.h"
28 #include "ardour/types.h"
29
30 namespace ARDOUR {
31
32 class LIBARDOUR_API LTCFileReader
33 {
34 public:
35         struct LTCMap {
36                 double framepos_sec; // relative to start of file
37                 double timecode_sec; // timecode
38
39                 LTCMap (double p, double t) {
40                         framepos_sec = p;
41                         timecode_sec = t;
42                 }
43         };
44
45         LTCFileReader (std::string path, double expected_fps, LTC_TV_STANDARD tv_standard = LTC_TV_FILM_24);
46         ~LTCFileReader ();
47
48         uint32_t channels () const { return _info.channels; }
49         std::vector<LTCMap> read_ltc (uint32_t channel, uint32_t max_frames = 1);
50
51 private:
52         int open();
53         void close ();
54
55         std::string _path;
56
57         double          _expected_fps;
58         LTC_TV_STANDARD _ltc_tv_standard;
59
60         SNDFILE* _sndfile;
61         SF_INFO  _info;
62
63         LTCDecoder*  decoder;
64         float*      _interleaved_audio_buffer;
65         uint32_t    _frames_decoded;
66         framecnt_t  _samples_read;
67
68 };
69
70 } // namespace ARDOUR
71
72 #endif /* __libardour_ltc_file_reader_h__ */