73e5046ac39089609bfd31fe8da4630a0a8efee6
[ardour.git] / libs / ardour / ardour / ticker.h
1 /*
2     Copyright (C) 2008 Hans Baier 
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     $Id$
19 */
20 #include <sigc++/sigc++.h>
21
22 #include "ardour/types.h"
23 #include "midi++/jack.h"
24
25 #ifndef TICKER_H_
26 #define TICKER_H_
27
28 namespace ARDOUR
29 {
30
31 class Session;
32
33 class Ticker : public sigc::trackable
34 {
35 public:
36         Ticker() : _session(0) {};
37         virtual ~Ticker() {};
38         
39         virtual void tick(
40                 const nframes_t& transport_frames, 
41                 const BBT_Time& transport_bbt, 
42                 const SMPTE::Time& transport_smpte) = 0;
43         
44         virtual void set_session(Session& s);
45         virtual void going_away() { _session = 0; }
46
47 private:
48         Session* _session;
49 };
50
51 class MidiClockTicker : public Ticker
52 {
53         MidiClockTicker() : _jack_port(0) {};
54         virtual ~MidiClockTicker() {};
55         
56         
57         void tick(
58                 const nframes_t& transport_frames, 
59                 const BBT_Time& transport_bbt, 
60                 const SMPTE::Time& transport_smpte);
61         
62         
63         void going_away() { Ticker::going_away(); _jack_port = 0;}
64         
65         void set_midi_port(MIDI::JACK_MidiPort &port);
66
67 private:        
68         MIDI::JACK_MidiPort* _jack_port;
69         
70 };
71
72 }
73
74 #endif /* TICKER_H_ */