ardour
mididm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013-2014 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_mididm_h__
20 #define __libardour_mididm_h__
21 
22 #include "ardour/types.h"
24 
25 namespace ARDOUR {
26 
27 class PortEngine;
28 
30 {
31 public:
32 
33  MIDIDM (framecnt_t sample_rate);
34 
35  int process (pframes_t nframes, PortEngine &pe, void *midi_in, void *midi_out);
36 
37  framecnt_t latency (void) { return _cnt_total > 10 ? _avg_delay : 0; }
38  framecnt_t processed (void) { return _cnt_total; }
39  double deviation (void) { return _cnt_total > 1 ? sqrt(_var_s / ((double)(_cnt_total - 1))) : 0; }
40  bool ok (void) { return _cnt_total > 200; }
41  bool have_signal (void) { return (_monotonic_cnt - _last_signal_tme) < (uint64_t) _sample_rate ; }
42 
43 private:
44  int64_t parse_mclk (uint8_t* buf, pframes_t timestamp) const;
45  int64_t parse_mtc (uint8_t* buf, pframes_t timestamp) const;
46 
48 
49  uint64_t _monotonic_cnt;
50  uint64_t _last_signal_tme;
51 
52  uint64_t _cnt_total;
53  uint64_t _dly_total;
54  uint32_t _min_delay;
55  uint32_t _max_delay;
56  double _avg_delay;
57  double _var_m;
58  double _var_s;
59 
60 };
61 
62 }
63 
64 #endif /* __libardour_mididm_h__ */
uint64_t _dly_total
Definition: mididm.h:53
double _avg_delay
Definition: mididm.h:56
framecnt_t _sample_rate
Definition: mididm.h:47
framecnt_t latency(void)
Definition: mididm.h:37
bool ok(void)
Definition: mididm.h:40
uint32_t pframes_t
Definition: types.h:61
uint32_t _min_delay
Definition: mididm.h:54
bool have_signal(void)
Definition: mididm.h:41
framecnt_t processed(void)
Definition: mididm.h:38
uint64_t _last_signal_tme
Definition: mididm.h:50
double _var_s
Definition: mididm.h:58
int64_t framecnt_t
Definition: types.h:76
uint32_t _max_delay
Definition: mididm.h:55
Definition: amp.h:29
uint64_t _cnt_total
Definition: mididm.h:52
#define LIBARDOUR_API
uint64_t _monotonic_cnt
Definition: mididm.h:49
double deviation(void)
Definition: mididm.h:39
double _var_m
Definition: mididm.h:57