* first primitive implementation of MidiPatchManager
authorHans Baier <hansfbaier@googlemail.com>
Mon, 8 Dec 2008 09:50:19 +0000 (09:50 +0000)
committerHans Baier <hansfbaier@googlemail.com>
Mon, 8 Dec 2008 09:50:19 +0000 (09:50 +0000)
* some cosmetic changes
* added midi_patch_path() to libs/ardour/ardour/session_directory.h

git-svn-id: svn://localhost/ardour2/branches/3.0@4299 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/SConscript
gtk2_ardour/midi_patch_manager.cc [new file with mode: 0644]
gtk2_ardour/midi_patch_manager.h [new file with mode: 0644]
gtk2_ardour/midi_time_axis.cc
libs/ardour/ardour/session_directory.h
libs/ardour/directory_names.cc
libs/ardour/plugin_manager.cc
libs/ardour/session_directory.cc
libs/midi++2/midi++/midnam_patch.h
libs/midi++2/midnam_patch.cc

index 60d5149493578ccc28c0ff33654faa21c46f758b..fef196e5ba046371c9b0f5ca42b38306fe7b23ac 100644 (file)
@@ -200,6 +200,7 @@ midi_region_view.cc
 midi_scroomer.cc
 midi_streamview.cc
 midi_time_axis.cc
+midi_patch_manager.cc
 mixer_strip.cc
 mixer_ui.cc
 new_session_dialog.cc
diff --git a/gtk2_ardour/midi_patch_manager.cc b/gtk2_ardour/midi_patch_manager.cc
new file mode 100644 (file)
index 0000000..738441b
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+    Copyright (C) 2008 Hans Baier 
+
+    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.
+
+    $Id$
+*/
+
+#include <sigc++/sigc++.h>
+#include <boost/shared_ptr.hpp>
+
+#include "midi_patch_manager.h"
+#include "pbd/file_utils.h"
+#include "ardour/session.h"
+#include "ardour/session_directory.h"
+
+using namespace std;
+using namespace sigc;
+using namespace ARDOUR;
+using namespace MIDI;
+using namespace MIDI::Name;
+using namespace PBD;
+using namespace PBD::sys;
+
+MidiPatchManager* MidiPatchManager::_manager = 0;
+
+void
+MidiPatchManager::set_session (Session& s)
+{
+       _session = &s;
+       _session->GoingAway.connect (mem_fun (*this, &MidiPatchManager::drop_session));
+       
+       refresh();
+}
+
+void
+MidiPatchManager::refresh()
+{
+       _documents.clear();
+       
+       path path_to_patches = _session->session_directory().midi_patch_path();
+       
+       if(!exists(path_to_patches)) {
+               return;
+       }
+       
+       assert(is_directory(path_to_patches));
+       
+       Glib::PatternSpec pattern(Glib::ustring("*.midnam"));
+       vector<path> result;
+       
+       find_matching_files_in_directory(path_to_patches, pattern, result);
+       
+       for(vector<path>::iterator i = result.begin(); i != result.end(); ++i) {
+               boost::shared_ptr<MIDINameDocument> document(new MIDINameDocument(i->to_string()));
+               _documents.push_back(document);
+       }
+}
+
+void
+MidiPatchManager::drop_session ()
+{
+       _session = 0;
+       _documents.clear();
+}
diff --git a/gtk2_ardour/midi_patch_manager.h b/gtk2_ardour/midi_patch_manager.h
new file mode 100644 (file)
index 0000000..ec82e93
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+    Copyright (C) 2008 Hans Baier 
+
+    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.
+
+    $Id$
+*/
+
+#ifndef MIDI_PATCH_MANAGER_H_
+#define MIDI_PATCH_MANAGER_H_
+
+#include "midi++/midnam_patch.h"
+
+namespace ARDOUR {
+       class Session;
+}
+
+namespace MIDI
+{
+
+namespace Name
+{
+
+class MidiPatchManager
+{
+       /// Singleton
+private:
+       MidiPatchManager() {};
+       MidiPatchManager( const MidiPatchManager& );
+       MidiPatchManager& operator= (const MidiPatchManager&);
+       
+       static MidiPatchManager* _manager; 
+       
+public:
+       typedef std::list<boost::shared_ptr<MIDINameDocument> > MidiNameDocuments;
+       
+       virtual ~MidiPatchManager() { _manager = 0; }
+       
+       static MidiPatchManager& instance() { 
+               if (_manager == 0) {
+                       _manager = new MidiPatchManager();
+               }
+               return *_manager; 
+       }
+       
+       void set_session (ARDOUR::Session&);
+       
+private:
+       void drop_session();
+       void refresh();
+       
+       ARDOUR::Session*  _session;
+       MidiNameDocuments _documents;
+};
+
+} // namespace Name
+
+} // namespace MIDI
+#endif /* MIDI_PATCH_MANAGER_H_ */
index 9453a05611c45ec4e7efdce44efbfc55190163fa..01505ad3033a521868f7baa76b959718ca651b53 100644 (file)
@@ -141,9 +141,9 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
        }
                
        // add channel selector expander
-       HBox *channel_selector_box = manage(new HBox());
-       channel_selector_box->pack_start(_channel_selector, false, false);
-       _midi_expander.add(*channel_selector_box);
+       HBox *midi_expander_box = manage(new HBox());
+       midi_expander_box->pack_start(_channel_selector, false, false);
+       _midi_expander.add(*midi_expander_box);
        _midi_expander.property_expanded().signal_changed().connect(
                        mem_fun(this, &MidiTimeAxisView::channel_selector_toggled));
        controls_vbox.pack_start(_midi_expander, false, false);
index a4fb7d07c5df5216e2440b8dfeb0d14041dc700e..5c976374e3e19cfcc23670987eb6afbfc57789e7 100644 (file)
@@ -61,6 +61,13 @@ public:
         * root_path()/interchange/session_name/midifiles
         */
        const path midi_path () const;
+       
+       /**
+        * @return the absolute path to the directory in which 
+        * the session stores MIDNAM patch files, ie
+        * root_path()/interchange/session_name/patchfiles
+        */
+       const path midi_patch_path () const;
 
        /**
         * @return The absolute path to the directory in which all
index 2b6dfcbb39645aa41fb58c15bf71d0b8506c9c88..0480ddc8bae7fc20cbe2a36e4cca71e92965ceb4 100644 (file)
@@ -7,6 +7,7 @@ namespace ARDOUR {
 const char* const old_sound_dir_name = X_("sounds");
 const char* const sound_dir_name = X_("audiofiles");
 const char* const midi_dir_name = X_("midifiles");
+const char* const midi_patch_dir_name = X_("patchfiles");
 const char* const peak_dir_name = X_("peaks");
 const char* const dead_sound_dir_name = X_("dead_sounds");
 const char* const dead_midi_dir_name = X_("dead_midi");
index e7c2aecd2df5839eb57c15bc03150bab7942c416..d4e995f0bf0651e41593214d01c3be7531247973 100644 (file)
@@ -478,7 +478,7 @@ PluginManager::vst_discover (string path)
        
        PluginInfoPtr info(new VSTPluginInfo);
 
-       /* what a goddam joke freeware VST is */
+       /* what a joke freeware VST is */
 
        if (!strcasecmp ("The Unnamed plugin", finfo->name)) {
                info->name = PBD::basename_nosuffix (path);
index d5f2ddc1ba2311f2ae2f3caf08f794ed480c1d13..50e213a4c2d90b07c1113725f964628d010776dc 100644 (file)
@@ -106,6 +106,12 @@ SessionDirectory::midi_path () const
        return sources_root() / midi_dir_name;
 }
 
+const path
+SessionDirectory::midi_patch_path () const
+{
+       return sources_root() / midi_patch_path();
+}
+
 const path
 SessionDirectory::peak_path () const
 {
index 3abb6c6c54f09475dc380369c97ec44aa1d8a00c..2561d905eb3367f73d5521ad50de9e96c58d605b 100644 (file)
@@ -1,14 +1,34 @@
+/*
+    Copyright (C) 2008 Hans Baier 
+
+    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.
+
+    $Id$
+*/
+
 #ifndef MIDNAM_PATCH_H_
 #define MIDNAM_PATCH_H_
 
-#include "pbd/stateful.h"
-#include "midi++/event.h"
-#include "pbd/xml++.h"
-
 #include <string>
 #include <list>
 #include <set>
 
+#include "pbd/stateful.h"
+#include "midi++/event.h"
+#include "pbd/xml++.h"
+
 namespace MIDI
 {
 
index 758667d90973f3dc176fc7492aff22fc63cd6398..56b36b5919777adc2ac16c096a99cb73d5bd4806 100644 (file)
@@ -1,3 +1,23 @@
+/*
+    Copyright (C) 2008 Hans Baier 
+
+    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.
+
+    $Id$
+*/
+
 #include "midi++/midnam_patch.h"
 #include <algorithm>