1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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);
}
}
|