summaryrefslogtreecommitdiff
path: root/libs/midi++2
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-06-12 16:32:06 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-06-12 16:32:06 +0000
commitd1d08e391059449977e7de1e858851ffd1afadc6 (patch)
tree5bb21a8854d1f2c6f5e3e2467226f9275d7dc07b /libs/midi++2
parentd7551a8f087483af2ef1eae4b0d6988585f03e79 (diff)
fix complete screw up in connecting MIDNAM PatchNameList with ChannelNameSets; more tweaks and twirls for patch/program change mgmt
git-svn-id: svn://localhost/ardour2/branches/3.0@12673 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/midi++2')
-rw-r--r--libs/midi++2/midi++/midnam_patch.h19
-rw-r--r--libs/midi++2/midnam_patch.cc62
2 files changed, 66 insertions, 15 deletions
diff --git a/libs/midi++2/midi++/midnam_patch.h b/libs/midi++2/midi++/midnam_patch.h
index 7a570ad3ff..f3ff434a9f 100644
--- a/libs/midi++2/midi++/midnam_patch.h
+++ b/libs/midi++2/midi++/midnam_patch.h
@@ -198,8 +198,10 @@ public:
int set_state (const XMLTree&, const XMLNode&);
void set_patch_banks (const PatchBanks&);
+ void use_patch_name_list (const PatchBank::PatchNameList&);
private:
+ friend std::ostream& operator<< (std::ostream&, const ChannelNameSet&);
std::string _name;
AvailableForChannels _available_for_channels;
PatchBanks _patch_banks;
@@ -208,6 +210,8 @@ private:
std::string _patch_list_name;
};
+std::ostream& operator<< (std::ostream&, const ChannelNameSet&);
+
class Note
{
public:
@@ -298,18 +302,9 @@ public:
const CustomDeviceModeNames& custom_device_mode_names() const { return _custom_device_mode_names; }
- boost::shared_ptr<CustomDeviceMode> custom_device_mode_by_name(std::string mode_name) {
- assert(mode_name != "");
- return _custom_device_modes[mode_name];
- }
-
- boost::shared_ptr<ChannelNameSet> channel_name_set_by_device_mode_and_channel(std::string mode, uint8_t channel) {
- return _channel_name_sets[custom_device_mode_by_name(mode)->channel_name_set_name_by_channel(channel)];
- }
-
- boost::shared_ptr<Patch> find_patch(std::string mode, uint8_t channel, PatchPrimaryKey& key) {
- return channel_name_set_by_device_mode_and_channel(mode, channel)->find_patch(key);
- }
+ boost::shared_ptr<CustomDeviceMode> custom_device_mode_by_name(std::string mode_name);
+ boost::shared_ptr<ChannelNameSet> channel_name_set_by_device_mode_and_channel(std::string mode, uint8_t channel);
+ boost::shared_ptr<Patch> find_patch(std::string mode, uint8_t channel, PatchPrimaryKey& key);
XMLNode& get_state (void);
int set_state (const XMLTree&, const XMLNode&);
diff --git a/libs/midi++2/midnam_patch.cc b/libs/midi++2/midnam_patch.cc
index fea9c09704..2b32fee42e 100644
--- a/libs/midi++2/midnam_patch.cc
+++ b/libs/midi++2/midnam_patch.cc
@@ -235,7 +235,7 @@ PatchBank::set_patch_name_list (const PatchNameList& pnl)
{
_patch_name_list = pnl;
_patch_list_name = "";
-
+
for (PatchNameList::iterator p = _patch_name_list.begin(); p != _patch_name_list.end(); p++) {
(*p)->set_bank_number (_number);
}
@@ -243,6 +243,29 @@ PatchBank::set_patch_name_list (const PatchNameList& pnl)
return 0;
}
+std::ostream&
+operator<< (std::ostream& os, const ChannelNameSet& cns)
+{
+ os << "Channel Name Set: name = " << cns._name << endl
+ << "Map size " << cns._patch_map.size () << endl
+ << "List size " << cns._patch_list.size() << endl
+ << "Patch list name = [" << cns._patch_list_name << ']' << endl
+ << "Available channels : ";
+ for (set<uint8_t>::iterator x = cns._available_for_channels.begin(); x != cns._available_for_channels.end(); ++x) {
+ os << (int) (*x) << ' ';
+ }
+ os << endl;
+
+ for (ChannelNameSet::PatchBanks::const_iterator pbi = cns._patch_banks.begin(); pbi != cns._patch_banks.end(); ++pbi) {
+ os << "\tPatch Bank " << (*pbi)->name() << " with " << (*pbi)->patch_name_list().size() << " patches\n";
+ for (PatchBank::PatchNameList::const_iterator pni = (*pbi)->patch_name_list().begin(); pni != (*pbi)->patch_name_list().end(); ++pni) {
+ os << "\t\tPatch name " << (*pni)->name() << " prog " << (int) (*pni)->program_number() << " bank " << (*pni)->bank_number() << endl;
+ }
+ }
+
+ return os;
+}
+
void
ChannelNameSet::set_patch_banks (const ChannelNameSet::PatchBanks& pb)
{
@@ -265,6 +288,15 @@ ChannelNameSet::set_patch_banks (const ChannelNameSet::PatchBanks& pb)
}
}
+void
+ChannelNameSet::use_patch_name_list (const PatchBank::PatchNameList& pnl)
+{
+ for (PatchBank::PatchNameList::const_iterator p = pnl.begin(); p != pnl.end(); ++p) {
+ _patch_map[(*p)->patch_primary_key()] = (*p);
+ _patch_list.push_back ((*p)->patch_primary_key());
+ }
+}
+
XMLNode&
ChannelNameSet::get_state (void)
{
@@ -369,6 +401,27 @@ CustomDeviceMode::get_state(void)
return *custom_device_mode;
}
+boost::shared_ptr<CustomDeviceMode>
+MasterDeviceNames::custom_device_mode_by_name(std::string mode_name)
+{
+ assert(mode_name != "");
+ return _custom_device_modes[mode_name];
+}
+
+boost::shared_ptr<ChannelNameSet>
+MasterDeviceNames::channel_name_set_by_device_mode_and_channel(std::string mode, uint8_t channel)
+{
+ boost::shared_ptr<CustomDeviceMode> cdm = custom_device_mode_by_name(mode);
+ boost::shared_ptr<ChannelNameSet> cns = _channel_name_sets[cdm->channel_name_set_name_by_channel(channel)];
+ return cns;
+}
+
+boost::shared_ptr<Patch>
+MasterDeviceNames::find_patch(std::string mode, uint8_t channel, PatchPrimaryKey& key)
+{
+ return channel_name_set_by_device_mode_and_channel(mode, channel)->find_patch(key);
+}
+
int
MasterDeviceNames::set_state(const XMLTree& tree, const XMLNode& a_node)
{
@@ -448,20 +501,23 @@ MasterDeviceNames::set_state(const XMLTree& tree, const XMLNode& a_node)
for (ChannelNameSets::iterator cns = _channel_name_sets.begin(); cns != _channel_name_sets.end(); ++cns) {
ChannelNameSet::PatchBanks pbs = cns->second->patch_banks();
+ PatchNameLists::iterator p;
+
for (ChannelNameSet::PatchBanks::iterator pb = pbs.begin(); pb != pbs.end(); ++pb) {
std::string pln = (*pb)->patch_list_name();
if (!pln.empty()) {
- PatchNameLists::iterator p = _patch_name_lists.find (pln);
- if (p != _patch_name_lists.end()) {
+ if ((p = _patch_name_lists.find (pln)) != _patch_name_lists.end()) {
if ((*pb)->set_patch_name_list (p->second)) {
return -1;
}
+ cns->second->use_patch_name_list (p->second);
} else {
error << string_compose ("Patch list name %1 was not found - patch file ignored", pln) << endmsg;
return -1;
}
}
}
+
}
return 0;