mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-06 05:35:47 +01:00
merge 12607:12717 from svn+ssh://ardoursvn@subversion.ardour.org/ardour2/branches/3.0
git-svn-id: svn://localhost/ardour2/branches/3.0-SG@12718 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
2b1fdfe815
commit
129dcd7f97
130 changed files with 2870 additions and 1065 deletions
|
|
@ -20,11 +20,18 @@
|
|||
|
||||
#include <gtkmm/stock.h>
|
||||
#include <gtkmm/table.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "gtkmm2ext/utils.h"
|
||||
|
||||
#include "ardour/midi_patch_manager.h"
|
||||
#include "ardour/beats_frames_converter.h"
|
||||
#include "ardour/instrument_info.h"
|
||||
|
||||
#include "patch_change_dialog.h"
|
||||
#include "gui_thread.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
@ -36,14 +43,12 @@ PatchChangeDialog::PatchChangeDialog (
|
|||
const ARDOUR::BeatsFramesConverter* tc,
|
||||
ARDOUR::Session* session,
|
||||
Evoral::PatchChange<Evoral::MusicalTime> const & patch,
|
||||
string const & model_name,
|
||||
string const & custom_device_node,
|
||||
ARDOUR::InstrumentInfo& info,
|
||||
const Gtk::BuiltinStockID& ok
|
||||
)
|
||||
: ArdourDialog (_("Patch Change"), true)
|
||||
, _time_converter (tc)
|
||||
, _model_name (model_name)
|
||||
, _custom_device_mode (custom_device_node)
|
||||
, _info (info)
|
||||
, _time (X_("patchchangetime"), true, "", true, false)
|
||||
, _channel (*manage (new Adjustment (1, 1, 16, 1, 4)))
|
||||
, _program (*manage (new Adjustment (1, 1, 128, 1, 16)))
|
||||
|
|
@ -115,9 +120,21 @@ PatchChangeDialog::PatchChangeDialog (
|
|||
set_active_bank_combo ();
|
||||
bank_combo_changed ();
|
||||
|
||||
_info.Changed.connect (_info_changed_connection, invalidator (*this),
|
||||
boost::bind (&PatchChangeDialog::instrument_info_changed, this), gui_context());
|
||||
|
||||
show_all ();
|
||||
}
|
||||
|
||||
void
|
||||
PatchChangeDialog::instrument_info_changed ()
|
||||
{
|
||||
_bank_combo.clear ();
|
||||
_patch_combo.clear ();
|
||||
fill_bank_combo ();
|
||||
fill_patch_combo ();
|
||||
}
|
||||
|
||||
Evoral::PatchChange<Evoral::MusicalTime>
|
||||
PatchChangeDialog::patch () const
|
||||
{
|
||||
|
|
@ -139,12 +156,13 @@ PatchChangeDialog::patch () const
|
|||
void
|
||||
PatchChangeDialog::fill_bank_combo ()
|
||||
{
|
||||
MIDI::Name::ChannelNameSet::PatchBanks const * banks = get_banks ();
|
||||
if (banks == 0) {
|
||||
boost::shared_ptr<MIDI::Name::ChannelNameSet> cns = _info.get_patches (_channel.get_value_as_int() - 1);
|
||||
|
||||
if (!cns) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (MIDI::Name::ChannelNameSet::PatchBanks::const_iterator i = banks->begin(); i != banks->end(); ++i) {
|
||||
for (MIDI::Name::ChannelNameSet::PatchBanks::const_iterator i = cns->patch_banks().begin(); i != cns->patch_banks().end(); ++i) {
|
||||
string n = (*i)->name ();
|
||||
boost::replace_all (n, "_", " ");
|
||||
_bank_combo.append_text (n);
|
||||
|
|
@ -157,17 +175,18 @@ PatchChangeDialog::set_active_bank_combo ()
|
|||
{
|
||||
_current_patch_bank.reset ();
|
||||
|
||||
MIDI::Name::ChannelNameSet::PatchBanks const * banks = get_banks ();
|
||||
if (banks == 0) {
|
||||
boost::shared_ptr<MIDI::Name::ChannelNameSet> cns = _info.get_patches (_channel.get_value_as_int() - 1);
|
||||
|
||||
if (!cns) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (MIDI::Name::ChannelNameSet::PatchBanks::const_iterator i = banks->begin(); i != banks->end(); ++i) {
|
||||
for (MIDI::Name::ChannelNameSet::PatchBanks::const_iterator i = cns->patch_banks().begin(); i != cns->patch_banks().end(); ++i) {
|
||||
|
||||
string n = (*i)->name ();
|
||||
boost::replace_all (n, "_", " ");
|
||||
|
||||
MIDI::Name::PatchPrimaryKey const * key = (*i)->patch_primary_key ();
|
||||
if (key && ((key->msb << 7) | key->lsb) == _bank.get_value () - 1) {
|
||||
if ((*i)->number() == _bank.get_value () - 1) {
|
||||
_current_patch_bank = *i;
|
||||
_ignore_signals = true;
|
||||
_bank_combo.set_active_text (n);
|
||||
|
|
@ -193,12 +212,13 @@ PatchChangeDialog::bank_combo_changed ()
|
|||
|
||||
_current_patch_bank.reset ();
|
||||
|
||||
MIDI::Name::ChannelNameSet::PatchBanks const * banks = get_banks ();
|
||||
if (banks == 0) {
|
||||
boost::shared_ptr<MIDI::Name::ChannelNameSet> cns = _info.get_patches (_channel.get_value_as_int() - 1);
|
||||
|
||||
if (!cns) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (MIDI::Name::ChannelNameSet::PatchBanks::const_iterator i = banks->begin(); i != banks->end(); ++i) {
|
||||
for (MIDI::Name::ChannelNameSet::PatchBanks::const_iterator i = cns->patch_banks().begin(); i != cns->patch_banks().end(); ++i) {
|
||||
string n = (*i)->name ();
|
||||
boost::replace_all (n, "_", " ");
|
||||
if (n == _bank_combo.get_active_text()) {
|
||||
|
|
@ -215,12 +235,9 @@ PatchChangeDialog::bank_combo_changed ()
|
|||
fill_patch_combo ();
|
||||
set_active_patch_combo ();
|
||||
|
||||
MIDI::Name::PatchPrimaryKey const * key = _current_patch_bank->patch_primary_key ();
|
||||
if (key) {
|
||||
_ignore_signals = true;
|
||||
_bank.set_value (((key->msb << 7) | key->lsb) + 1);
|
||||
_ignore_signals = false;
|
||||
}
|
||||
_ignore_signals = true;
|
||||
_bank.set_value (_current_patch_bank->number() + 1);
|
||||
_ignore_signals = false;
|
||||
}
|
||||
|
||||
/** Fill the contents of the patch combo */
|
||||
|
|
@ -284,14 +301,17 @@ PatchChangeDialog::patch_combo_changed ()
|
|||
}
|
||||
|
||||
const MIDI::Name::PatchBank::PatchNameList& patches = _current_patch_bank->patch_name_list ();
|
||||
|
||||
for (MIDI::Name::PatchBank::PatchNameList::const_iterator j = patches.begin(); j != patches.end(); ++j) {
|
||||
string n = (*j)->name ();
|
||||
boost::replace_all (n, "_", " ");
|
||||
std::cerr << "Looking for " << n << " vs " << _patch_combo.get_active_text() << std::endl;
|
||||
if (n == _patch_combo.get_active_text ()) {
|
||||
MIDI::Name::PatchPrimaryKey const & key = (*j)->patch_primary_key ();
|
||||
_ignore_signals = true;
|
||||
_program.set_value (key.program_number + 1);
|
||||
std::cerr << " reset pgm number to " << (int) (*j)->program_number() << std::endl;
|
||||
_program.set_value ((*j)->program_number() + 1);
|
||||
_ignore_signals = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -327,17 +347,3 @@ PatchChangeDialog::bank_changed ()
|
|||
set_active_patch_combo ();
|
||||
}
|
||||
|
||||
MIDI::Name::ChannelNameSet::PatchBanks const *
|
||||
PatchChangeDialog::get_banks ()
|
||||
{
|
||||
MIDI::Name::MidiPatchManager& mpm = MIDI::Name::MidiPatchManager::instance ();
|
||||
boost::shared_ptr<MIDI::Name::ChannelNameSet> channel_name_set = mpm.find_channel_name_set (
|
||||
_model_name, _custom_device_mode, _channel.get_value_as_int() - 1
|
||||
);
|
||||
|
||||
if (!channel_name_set) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return &channel_name_set->patch_banks ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue