mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-11 07:56:27 +01:00
make MIDI Patch Manager search in $user_config_dir/patchfiles for midnam files as well as the per-session equivalent. need to stop it from doing at session shutdown time too.
git-svn-id: svn://localhost/ardour2/branches/3.0@11736 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
1c399d5ebc
commit
494635b99b
5 changed files with 146 additions and 11 deletions
|
|
@ -39,7 +39,7 @@ class MidiPatchManager : public PBD::ScopedConnectionList, public ARDOUR::Sessio
|
|||
{
|
||||
/// Singleton
|
||||
private:
|
||||
MidiPatchManager() {};
|
||||
MidiPatchManager();
|
||||
MidiPatchManager( const MidiPatchManager& );
|
||||
MidiPatchManager& operator= (const MidiPatchManager&);
|
||||
|
||||
|
|
@ -136,6 +136,7 @@ public:
|
|||
private:
|
||||
void session_going_away();
|
||||
void refresh();
|
||||
void add_session_patches();
|
||||
|
||||
MidiNameDocuments _documents;
|
||||
MIDINameDocument::MasterDeviceNamesList _master_devices_by_model;
|
||||
|
|
|
|||
39
libs/ardour/ardour/midi_patch_search_path.h
Normal file
39
libs/ardour/ardour/midi_patch_search_path.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright (C) 2011 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __ardour_midi_patch_search_path_h__
|
||||
#define __ardour_midi_patch_search_path_h__
|
||||
|
||||
#include "pbd/search_path.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
/**
|
||||
* return a SearchPath containing directories in which to look for
|
||||
* MIDI patch files ("*.midnam") aka MIDNAM files
|
||||
*
|
||||
* If ARDOUR_MIDI_PATCH_PATH is defined then the SearchPath returned
|
||||
* will contain only those directories specified in it, otherwise it will
|
||||
* contain the user and system directories which may contain control
|
||||
* surface plugins.
|
||||
*/
|
||||
PBD::SearchPath midi_patch_search_path ();
|
||||
|
||||
} // namespace ARDOUR
|
||||
|
||||
#endif /* __ardour_midi_patch_search_path_h__ */
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
#include "ardour/session.h"
|
||||
#include "ardour/session_directory.h"
|
||||
#include "ardour/midi_patch_manager.h"
|
||||
#include "ardour/midi_patch_search_path.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
|
|
@ -39,27 +40,28 @@ using namespace PBD::sys;
|
|||
|
||||
MidiPatchManager* MidiPatchManager::_manager = 0;
|
||||
|
||||
MidiPatchManager::MidiPatchManager ()
|
||||
{
|
||||
refresh ();
|
||||
}
|
||||
|
||||
void
|
||||
MidiPatchManager::set_session (Session* s)
|
||||
{
|
||||
SessionHandlePtr::set_session (s);
|
||||
refresh();
|
||||
add_session_patches ();
|
||||
}
|
||||
|
||||
void
|
||||
MidiPatchManager::refresh()
|
||||
MidiPatchManager::add_session_patches ()
|
||||
{
|
||||
_documents.clear();
|
||||
_master_devices_by_model.clear();
|
||||
_all_models.clear();
|
||||
|
||||
if (!_session) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
path path_to_patches = _session->session_directory().midi_patch_path();
|
||||
|
||||
if (!exists(path_to_patches)) {
|
||||
if (!exists (path_to_patches)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -68,9 +70,9 @@ MidiPatchManager::refresh()
|
|||
Glib::PatternSpec pattern(string("*.midnam"));
|
||||
vector<path> result;
|
||||
|
||||
find_matching_files_in_directory(path_to_patches, pattern, result);
|
||||
find_matching_files_in_directory (path_to_patches, pattern, result);
|
||||
|
||||
info << "Loading " << result.size() << " MIDI patches from " << path_to_patches.to_string() << endl;
|
||||
info << "Loading " << result.size() << " MIDI patches from " << path_to_patches.to_string() << endmsg;
|
||||
|
||||
for (vector<path>::iterator i = result.begin(); i != result.end(); ++i) {
|
||||
boost::shared_ptr<MIDINameDocument> document(new MIDINameDocument(i->to_string()));
|
||||
|
|
@ -93,6 +95,46 @@ MidiPatchManager::refresh()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
MidiPatchManager::refresh()
|
||||
{
|
||||
_documents.clear();
|
||||
_master_devices_by_model.clear();
|
||||
_all_models.clear();
|
||||
|
||||
SearchPath search_path = midi_patch_search_path ();
|
||||
Glib::PatternSpec pattern (string("*.midnam"));
|
||||
vector<path> result;
|
||||
|
||||
find_matching_files_in_search_path (search_path, pattern, result);
|
||||
|
||||
info << "Loading " << result.size() << " MIDI patches from " << search_path.to_string() << endmsg;
|
||||
|
||||
for (vector<path>::iterator i = result.begin(); i != result.end(); ++i) {
|
||||
boost::shared_ptr<MIDINameDocument> document(new MIDINameDocument(i->to_string()));
|
||||
for (MIDINameDocument::MasterDeviceNamesList::const_iterator device =
|
||||
document->master_device_names_by_model().begin();
|
||||
device != document->master_device_names_by_model().end();
|
||||
++device) {
|
||||
//cerr << "got model " << device->first << endl;
|
||||
// have access to the documents by model name
|
||||
_documents[device->first] = document;
|
||||
// build a list of all master devices from all documents
|
||||
_master_devices_by_model[device->first] = device->second;
|
||||
_all_models.push_back(device->first);
|
||||
|
||||
// make sure there are no double model names
|
||||
// TODO: handle this gracefully.
|
||||
assert(_documents.count(device->first) == 1);
|
||||
assert(_master_devices_by_model.count(device->first) == 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (_session) {
|
||||
add_session_patches ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MidiPatchManager::session_going_away ()
|
||||
{
|
||||
|
|
|
|||
52
libs/ardour/midi_patch_search_path.cc
Normal file
52
libs/ardour/midi_patch_search_path.cc
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
Copyright (C) 2007 Tim Mayberry
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <glibmm/miscutils.h>
|
||||
|
||||
#include "ardour/midi_name_search_path.h"
|
||||
#include "ardour/directory_names.h"
|
||||
#include "ardour/filesystem_paths.h"
|
||||
|
||||
namespace {
|
||||
const char * const midi_patch_env_variable_name = "ARDOUR_MIDI_PATCH_PATH";
|
||||
} // anonymous
|
||||
|
||||
using namespace PBD;
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
SearchPath
|
||||
midi_patch_search_path ()
|
||||
{
|
||||
SearchPath spath (user_config_directory ());
|
||||
|
||||
spath += ardour_module_directory ();
|
||||
spath.add_subdirectory_to_paths(midi_patch_dir_name);
|
||||
|
||||
bool midi_patch_path_defined = false;
|
||||
SearchPath spath_env (Glib::getenv(midi_patch_env_variable_name, midi_patch_path_defined));
|
||||
|
||||
if (midi_patch_path_defined) {
|
||||
spath += spath_env;
|
||||
}
|
||||
|
||||
return spath;
|
||||
}
|
||||
|
||||
} // namespace ARDOUR
|
||||
|
|
@ -123,6 +123,7 @@ libardour_sources = [
|
|||
'midi_diskstream.cc',
|
||||
'midi_model.cc',
|
||||
'midi_patch_manager.cc',
|
||||
'midi_patch_search_path.cc',
|
||||
'midi_playlist.cc',
|
||||
'midi_playlist_source.cc',
|
||||
'midi_port.cc',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue