#define MIDI_PATCH_MANAGER_H_
#include "midi++/midnam_patch.h"
-#include "pbd/scoped_connections.h"
-#include "ardour/session_handle.h"
-namespace ARDOUR {
- class Session;
-}
+#include "pbd/signals.h"
+#include "pbd/search_path.h"
+
+#include "ardour/libardour_visibility.h"
namespace MIDI
{
namespace Name
{
-class MidiPatchManager : public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr
+class LIBARDOUR_API MidiPatchManager
{
/// Singleton
private:
- MidiPatchManager() {};
+ MidiPatchManager();
MidiPatchManager( const MidiPatchManager& );
MidiPatchManager& operator= (const MidiPatchManager&);
static MidiPatchManager* _manager;
public:
- typedef std::map<std::string, boost::shared_ptr<MIDINameDocument> > MidiNameDocuments;
+ typedef std::map<std::string, boost::shared_ptr<MIDINameDocument> > MidiNameDocuments;
+ typedef std::map<std::string, MIDINameDocument::MasterDeviceNamesList> DeviceNamesByMaker;
virtual ~MidiPatchManager() { _manager = 0; }
return *_manager;
}
- void set_session (ARDOUR::Session*);
+ PBD::Signal0<void> PatchesChanged;
+
+ bool add_custom_midnam (const std::string& id, const std::string& midnam);
+ bool update_custom_midnam (const std::string& id, const std::string& midnam);
+ bool remove_custom_midnam (const std::string& id);
+
+ void add_search_path (const PBD::Searchpath& search_path);
- boost::shared_ptr<MIDINameDocument> document_by_model(std::string model_name)
- { return _documents[model_name]; }
+ void remove_search_path (const PBD::Searchpath& search_path);
+
+ boost::shared_ptr<MIDINameDocument> document_by_model(std::string model_name) const;
boost::shared_ptr<MasterDeviceNames> master_device_by_model(std::string model_name)
{ return _master_devices_by_model[model_name]; }
boost::shared_ptr<MIDI::Name::MasterDeviceNames> master_device = master_device_by_model(model);
if (master_device != 0 && custom_device_mode != "") {
- return master_device->channel_name_set_by_device_mode_and_channel(custom_device_mode, channel);
+ return master_device->channel_name_set_by_channel(custom_device_mode, channel);
} else {
return boost::shared_ptr<ChannelNameSet>();
}
std::list<std::string> custom_device_mode_names_by_model(std::string model_name) {
if (model_name != "") {
- return master_device_by_model(model_name)->custom_device_mode_names();
- } else {
- return std::list<std::string>();
+ if (master_device_by_model(model_name)) {
+ return master_device_by_model(model_name)->custom_device_mode_names();
+ }
}
+ return std::list<std::string>();
}
const MasterDeviceNames::Models& all_models() const { return _all_models; }
+ const DeviceNamesByMaker& devices_by_manufacturer() const { return _devices_by_manufacturer; }
+
+private:
+ bool load_midi_name_document(const std::string& file_path);
+ bool add_midi_name_document(boost::shared_ptr<MIDINameDocument>);
+ bool remove_midi_name_document(const std::string& file_path, bool emit_signal = true);
+
+ void add_midnam_files_from_directory(const std::string& directory_path);
+ void remove_midnam_files_from_directory(const std::string& directory_path);
+
private:
- void session_going_away();
- void refresh();
+ PBD::Searchpath _search_path;
MidiNameDocuments _documents;
MIDINameDocument::MasterDeviceNamesList _master_devices_by_model;
+ DeviceNamesByMaker _devices_by_manufacturer;
MasterDeviceNames::Models _all_models;
};