summaryrefslogtreecommitdiff
path: root/libs/ardour/instrument_info.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-06-11 12:07:17 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-06-11 12:07:17 +0000
commit960de7306f8573f6cb698cf031fad46daa3c741d (patch)
tree690e6312cbe1d25bfe3845cdd578b6c864d83ab8 /libs/ardour/instrument_info.cc
parent80afb6e08b52f05d672df2d991265df713792010 (diff)
partially-done (but compile-friendly) move of instrument info into a new backend object
git-svn-id: svn://localhost/ardour2/branches/3.0@12652 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/instrument_info.cc')
-rw-r--r--libs/ardour/instrument_info.cc100
1 files changed, 100 insertions, 0 deletions
diff --git a/libs/ardour/instrument_info.cc b/libs/ardour/instrument_info.cc
new file mode 100644
index 0000000000..21e4bd1cd9
--- /dev/null
+++ b/libs/ardour/instrument_info.cc
@@ -0,0 +1,100 @@
+/*
+ Copyright (C) 2012 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.
+*/
+
+#include "pbd/compose.h"
+
+#include "midi++/midnam_patch.h"
+
+#include "ardour/instrument_info.h"
+#include "ardour/midi_patch_manager.h"
+#include "ardour/processor.h"
+#include "ardour/rc_configuration.h"
+
+#include "i18n.h"
+
+using namespace ARDOUR;
+using std::string;
+
+InstrumentInfo::InstrumentInfo ()
+ : external_instrument_model (_("Unknown"))
+{
+}
+
+InstrumentInfo::~InstrumentInfo ()
+{
+}
+
+void
+InstrumentInfo::set_external_instrument (const string& model, const string& mode)
+{
+ external_instrument_model = model;
+ external_instrument_mode = mode;
+ internal_instrument.reset ();
+ Changed(); /* EMIT SIGNAL */
+}
+
+void
+InstrumentInfo::set_internal_instrument (boost::shared_ptr<Processor> p)
+{
+ internal_instrument = p;
+ external_instrument_model = (_("Unknown"));
+ external_instrument_mode = "";
+ Changed(); /* EMIT SIGNAL */
+}
+
+string
+InstrumentInfo::get_instrument_name () const
+{
+ boost::shared_ptr<Processor> p = internal_instrument.lock();
+
+ if (p) {
+ return p->name();
+ }
+
+ if (external_instrument_mode.empty()) {
+ return external_instrument_model;
+ } else {
+ return string_compose ("%1 (%2)", external_instrument_model, external_instrument_mode);
+ }
+}
+
+string
+InstrumentInfo::get_patch_name (uint16_t bank, uint8_t program, uint8_t channel) const
+{
+ boost::shared_ptr<Processor> p = internal_instrument.lock();
+
+ if (p) {
+ return "some plugin program";
+ }
+
+ MIDI::Name::PatchPrimaryKey patch_key (bank, program);
+
+ boost::shared_ptr<MIDI::Name::Patch> patch =
+ MIDI::Name::MidiPatchManager::instance().find_patch (external_instrument_model,
+ external_instrument_mode, channel, patch_key);
+
+ if (patch) {
+ return patch->name();
+ } else {
+ /* program and bank numbers are zero-based: convert to one-based: MIDI_BP_ZERO */
+
+#define MIDI_BP_ZERO ((Config->get_first_midi_bank_is_zero())?0:1)
+
+ return string_compose ("%1 %2",program + MIDI_BP_ZERO , bank + MIDI_BP_ZERO);
+ }
+}