2 Copyright (C) 2012 Paul 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.
19 #include "pbd/compose.h"
21 #include "midi++/midnam_patch.h"
23 #include "ardour/instrument_info.h"
24 #include "ardour/midi_patch_manager.h"
25 #include "ardour/processor.h"
26 #include "ardour/rc_configuration.h"
30 using namespace ARDOUR;
33 InstrumentInfo::InstrumentInfo ()
34 : external_instrument_model (_("Unknown"))
38 InstrumentInfo::~InstrumentInfo ()
43 InstrumentInfo::set_external_instrument (const string& model, const string& mode)
45 external_instrument_model = model;
46 external_instrument_mode = mode;
47 internal_instrument.reset ();
48 Changed(); /* EMIT SIGNAL */
52 InstrumentInfo::set_internal_instrument (boost::shared_ptr<Processor> p)
54 internal_instrument = p;
55 external_instrument_model = (_("Unknown"));
56 external_instrument_mode = "";
57 Changed(); /* EMIT SIGNAL */
61 InstrumentInfo::get_instrument_name () const
63 boost::shared_ptr<Processor> p = internal_instrument.lock();
69 if (external_instrument_mode.empty()) {
70 return external_instrument_model;
72 return string_compose ("%1 (%2)", external_instrument_model, external_instrument_mode);
77 InstrumentInfo::get_patch_name (uint16_t bank, uint8_t program, uint8_t channel) const
79 boost::shared_ptr<Processor> p = internal_instrument.lock();
82 return "some plugin program";
85 MIDI::Name::PatchPrimaryKey patch_key (bank, program);
87 boost::shared_ptr<MIDI::Name::Patch> patch =
88 MIDI::Name::MidiPatchManager::instance().find_patch (external_instrument_model,
89 external_instrument_mode, channel, patch_key);
94 /* program and bank numbers are zero-based: convert to one-based: MIDI_BP_ZERO */
96 #define MIDI_BP_ZERO ((Config->get_first_midi_bank_is_zero())?0:1)
98 return string_compose ("%1 %2",program + MIDI_BP_ZERO , bank + MIDI_BP_ZERO);