Remove all use of nframes_t.
[ardour.git] / libs / midi++2 / midi++ / manager.h
1 /*
2     Copyright (C) 1998 Paul Barton-Davis
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
20 #ifndef __midi_manager_h__
21 #define __midi_manager_h__
22
23 #include <list>
24
25 #include <string>
26
27 #include "midi++/types.h"
28 #include "midi++/port.h"
29
30 namespace MIDI {
31
32 class MachineControl;   
33
34 class Manager {
35   public:
36         ~Manager ();
37         
38         /** Signal the start of an audio cycle.
39          * This MUST be called before any reading/writing for this cycle.
40          * Realtime safe.
41          */
42         void cycle_start (pframes_t nframes);
43         
44         /** Signal the end of an audio cycle.
45          * This signifies that the cycle began with @ref cycle_start has ended.
46          * This MUST be called at the end of each cycle.
47          * Realtime safe.
48          */
49         void cycle_end ();
50
51         MachineControl* mmc () const { return _mmc; }
52         Port *mtc_input_port() const { return _mtc_input_port; }
53         Port *mtc_output_port() const { return _mtc_output_port; }
54         Port *midi_input_port() const { return _midi_input_port; }
55         Port *midi_output_port() const { return _midi_output_port; }
56         Port *midi_clock_input_port() const { return _midi_clock_input_port; }
57         Port *midi_clock_output_port() const { return _midi_clock_output_port; }
58
59         Port* add_port (Port *);
60
61         Port* port (std::string const &);
62
63         void set_port_states (std::list<XMLNode*>);
64
65         typedef std::list<Port *> PortList;
66
67         const PortList& get_midi_ports() const { return _ports; } 
68
69         static void create (jack_client_t* jack);
70         
71         static Manager *instance () {
72                 return theManager;
73         }
74
75         void reestablish (jack_client_t *);
76         void reconnect ();
77
78         PBD::Signal0<void> PortsChanged;
79
80   private:
81         /* This is a SINGLETON pattern */
82         
83         Manager (jack_client_t *);
84         static Manager *theManager;
85
86         MIDI::MachineControl*   _mmc;
87         MIDI::Port*             _mtc_input_port;
88         MIDI::Port*             _mtc_output_port;
89         MIDI::Port*             _midi_input_port;
90         MIDI::Port*             _midi_output_port;
91         MIDI::Port*             _midi_clock_input_port;
92         MIDI::Port*             _midi_clock_output_port;
93         
94         std::list<Port*> _ports;
95 };
96
97 } // namespace MIDI
98
99 #endif  // __midi_manager_h__