2 * Copyright (C) 2013-2014 Robin Gareus <robin@gareus.org>
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.
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.
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.
19 #ifndef __libardour_mididm_h__
20 #define __libardour_mididm_h__
22 #include "ardour/types.h"
23 #include "ardour/libardour_visibility.h"
29 class LIBARDOUR_API MIDIDM
33 MIDIDM (framecnt_t sample_rate);
35 int process (pframes_t nframes, PortEngine &pe, void *midi_in, void *midi_out);
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 ; }
44 int64_t parse_mclk (uint8_t* buf, pframes_t timestamp) const;
45 int64_t parse_mtc (uint8_t* buf, pframes_t timestamp) const;
47 framecnt_t _sample_rate;
49 uint64_t _monotonic_cnt;
50 uint64_t _last_signal_tme;
64 #endif /* __libardour_mididm_h__ */