2 Copyright (C) 1998 Paul Barton-Davis
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.
20 #ifndef __midi_manager_h__
21 #define __midi_manager_h__
26 #include <midi++/types.h>
27 #include <midi++/port.h>
31 /** Creates, stores, and manages system MIDI ports.
37 void set_api_data(void* data) { api_data = data; }
39 /** Signal the start of an audio cycle.
40 * This MUST be called before any reading/writing for this cycle.
43 void cycle_start(nframes_t nframes);
45 /** Signal the end of an audio cycle.
46 * This signifies that the cycle began with @ref cycle_start has ended.
47 * This MUST be called at the end of each cycle.
52 Port *add_port (PortRequest &);
53 int remove_port (std::string port);
55 Port *port (std::string name);
56 Port *port (size_t number);
58 size_t nports () { return ports_by_device.size(); }
60 int foreach_port (int (*func)(const Port &, size_t n, void *),
63 typedef std::map<std::string, Port *> PortMap;
65 const PortMap& get_midi_ports() const { return ports_by_tag; }
67 static Manager *instance () {
68 if (theManager == 0) {
69 theManager = new Manager;
74 static int parse_port_request (std::string str, Port::Type type);
77 /* This is a SINGLETON pattern */
81 static Manager *theManager;
82 PortMap ports_by_device; /* canonical */
83 PortMap ports_by_tag; /* may contain duplicate Ports */
92 #endif // __midi_manager_h__