remove craziness of propagating MIDI 7 bit limits into MIDNAM handling by replacing bank_msb/lsb with "bank" ; move responsibility for discovering patch names into MIDI trackview (soon to move again)
git-svn-id: svn://localhost/ardour2/branches/3.0@12647 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
df6222b3b4
commit
23350c195d
|
@ -117,7 +117,7 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &
|
|||
|
||||
/* Look up MIDNAM details from our MidiTimeAxisView */
|
||||
MidiTimeAxisView& mtv = dynamic_cast<MidiTimeAxisView&> (tv);
|
||||
midi_patch_settings_changed (mtv.midi_patch_model (), mtv.midi_patch_custom_device_node ());
|
||||
midi_patch_settings_changed (mtv.midi_patch_model (), mtv.midi_patch_custom_device_mode ());
|
||||
|
||||
Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&MidiRegionView::parameter_changed, this, _1), gui_context());
|
||||
connect_to_diskstream ();
|
||||
|
@ -158,7 +158,7 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &
|
|||
|
||||
/* Look up MIDNAM details from our MidiTimeAxisView */
|
||||
MidiTimeAxisView& mtv = dynamic_cast<MidiTimeAxisView&> (tv);
|
||||
midi_patch_settings_changed (mtv.midi_patch_model (), mtv.midi_patch_custom_device_node ());
|
||||
midi_patch_settings_changed (mtv.midi_patch_model (), mtv.midi_patch_custom_device_mode ());
|
||||
|
||||
connect_to_diskstream ();
|
||||
|
||||
|
@ -1209,20 +1209,10 @@ MidiRegionView::display_patch_changes_on_channel (uint8_t channel, bool active_c
|
|||
continue;
|
||||
}
|
||||
|
||||
MIDI::Name::PatchPrimaryKey patch_key ((*i)->bank_msb (), (*i)->bank_lsb (), (*i)->program ());
|
||||
MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
|
||||
string patch_name = mtv->get_patch_name ((*i)->bank(), (*i)->program(), channel);
|
||||
|
||||
boost::shared_ptr<MIDI::Name::Patch> patch =
|
||||
MIDI::Name::MidiPatchManager::instance().find_patch(
|
||||
_model_name, _custom_device_mode, channel, patch_key);
|
||||
|
||||
if (patch != 0) {
|
||||
add_canvas_patch_change (*i, patch->name(), active_channel);
|
||||
} else {
|
||||
char buf[16];
|
||||
/* program and bank numbers are zero-based: convert to one-based: MIDI_BP_ZERO */
|
||||
snprintf (buf, 16, "%d %d", (*i)->program() + MIDI_BP_ZERO , (*i)->bank() + MIDI_BP_ZERO);
|
||||
add_canvas_patch_change (*i, buf, active_channel);
|
||||
}
|
||||
add_canvas_patch_change (*i, patch_name, active_channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1832,11 +1822,10 @@ MidiRegionView::get_patch_key_at (Evoral::MusicalTime time, uint8_t channel, MID
|
|||
}
|
||||
|
||||
if (i != _model->patch_changes().end()) {
|
||||
key.msb = (*i)->bank_msb ();
|
||||
key.lsb = (*i)->bank_lsb ();
|
||||
key.bank_number = (*i)->bank();
|
||||
key.program_number = (*i)->program ();
|
||||
} else {
|
||||
key.msb = key.lsb = key.program_number = 0;
|
||||
key.bank_number = key.program_number = 0;
|
||||
}
|
||||
|
||||
assert (key.is_sane());
|
||||
|
@ -1852,7 +1841,7 @@ MidiRegionView::change_patch_change (CanvasPatchChange& pc, const MIDI::Name::Pa
|
|||
c->change_program (pc.patch (), new_patch.program_number);
|
||||
}
|
||||
|
||||
int const new_bank = (new_patch.msb << 7) | new_patch.lsb;
|
||||
int const new_bank = new_patch.bank_number;
|
||||
if (pc.patch()->bank() != new_bank) {
|
||||
c->change_bank (pc.patch (), new_bank);
|
||||
}
|
||||
|
@ -1965,15 +1954,9 @@ MidiRegionView::previous_bank (CanvasPatchChange& patch)
|
|||
if (patch.patch()->program() < 127) {
|
||||
MIDI::Name::PatchPrimaryKey key;
|
||||
get_patch_key_at (patch.patch()->time(), patch.patch()->channel(), key);
|
||||
if (key.lsb > 0) {
|
||||
key.lsb--;
|
||||
if (key.bank_number > 0) {
|
||||
key.bank_number--;
|
||||
change_patch_change (patch, key);
|
||||
} else {
|
||||
if (key.msb > 0) {
|
||||
key.lsb = 127;
|
||||
key.msb--;
|
||||
change_patch_change (patch, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1984,15 +1967,9 @@ MidiRegionView::next_bank (CanvasPatchChange& patch)
|
|||
if (patch.patch()->program() > 0) {
|
||||
MIDI::Name::PatchPrimaryKey key;
|
||||
get_patch_key_at (patch.patch()->time(), patch.patch()->channel(), key);
|
||||
if (key.lsb < 127) {
|
||||
key.lsb++;
|
||||
if (key.bank_number < 127) {
|
||||
key.bank_number++;
|
||||
change_patch_change (patch, key);
|
||||
} else {
|
||||
if (key.msb < 127) {
|
||||
key.lsb = 0;
|
||||
key.msb++;
|
||||
change_patch_change (patch, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -324,8 +324,8 @@ MidiTimeAxisView::model_changed()
|
|||
void
|
||||
MidiTimeAxisView::custom_device_mode_changed()
|
||||
{
|
||||
_midi_patch_settings_changed.emit (midi_patch_model (), midi_patch_custom_device_node ());
|
||||
set_gui_property (X_("midnam-custom-device-mode"), midi_patch_custom_device_node ());
|
||||
_midi_patch_settings_changed.emit (midi_patch_model (), midi_patch_custom_device_mode ());
|
||||
set_gui_property (X_("midnam-custom-device-mode"), midi_patch_custom_device_mode ());
|
||||
}
|
||||
|
||||
MidiStreamView*
|
||||
|
@ -1214,7 +1214,26 @@ MidiTimeAxisView::midi_patch_model () const
|
|||
}
|
||||
|
||||
string
|
||||
MidiTimeAxisView::midi_patch_custom_device_node () const
|
||||
MidiTimeAxisView::midi_patch_custom_device_mode () const
|
||||
{
|
||||
return _custom_device_mode_selector.get_active_text ();
|
||||
}
|
||||
|
||||
string
|
||||
MidiTimeAxisView::get_patch_name (uint16_t bank, uint8_t program, uint8_t channel) const
|
||||
{
|
||||
MIDI::Name::PatchPrimaryKey patch_key (bank, program);
|
||||
|
||||
boost::shared_ptr<MIDI::Name::Patch> patch =
|
||||
MIDI::Name::MidiPatchManager::instance().find_patch (midi_patch_model(), midi_patch_custom_device_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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,8 @@ class MidiTimeAxisView : public RouteTimeAxisView
|
|||
uint8_t get_channel_for_add () const;
|
||||
|
||||
std::string midi_patch_model () const;
|
||||
std::string midi_patch_custom_device_node () const;
|
||||
std::string midi_patch_custom_device_mode () const;
|
||||
std::string get_patch_name (uint16_t bank, uint8_t program, uint8_t channel) const;
|
||||
|
||||
protected:
|
||||
void start_step_editing ();
|
||||
|
|
|
@ -167,7 +167,7 @@ PatchChangeDialog::set_active_bank_combo ()
|
|||
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 (key && (key->bank_number == _bank.get_value () - 1)) {
|
||||
_current_patch_bank = *i;
|
||||
_ignore_signals = true;
|
||||
_bank_combo.set_active_text (n);
|
||||
|
@ -218,7 +218,7 @@ PatchChangeDialog::bank_combo_changed ()
|
|||
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);
|
||||
_bank.set_value (key->bank_number + 1);
|
||||
_ignore_signals = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,42 +39,36 @@ namespace Name
|
|||
struct PatchPrimaryKey
|
||||
{
|
||||
public:
|
||||
int msb;
|
||||
int lsb;
|
||||
int bank_number;
|
||||
int program_number;
|
||||
|
||||
PatchPrimaryKey(int a_msb = -1, int a_lsb = -1, int a_program_number = -1) {
|
||||
msb = a_msb;
|
||||
lsb = a_lsb;
|
||||
|
||||
PatchPrimaryKey(int a_bank_number = -1, int a_program_number = -1) {
|
||||
bank_number = a_bank_number;
|
||||
program_number = a_program_number;
|
||||
}
|
||||
|
||||
bool is_sane() {
|
||||
return ((msb >= 0) && (msb <= 127) &&
|
||||
(lsb >= 0) && (lsb <= 127) &&
|
||||
return ((bank_number >= 0) && (bank_number <= 16384) &&
|
||||
(program_number >=0 ) && (program_number <= 127));
|
||||
}
|
||||
|
||||
inline PatchPrimaryKey& operator=(const PatchPrimaryKey& id) {
|
||||
msb = id.msb;
|
||||
lsb = id.lsb;
|
||||
bank_number = id.bank_number;
|
||||
program_number = id.program_number;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool operator==(const PatchPrimaryKey& id) const {
|
||||
return (msb == id.msb && lsb == id.lsb && program_number == id.program_number);
|
||||
return (bank_number == id.bank_number && program_number == id.program_number);
|
||||
}
|
||||
|
||||
/**
|
||||
* obey strict weak ordering or crash in STL containers
|
||||
*/
|
||||
inline bool operator<(const PatchPrimaryKey& id) const {
|
||||
if (msb < id.msb) {
|
||||
if (bank_number < id.bank_number) {
|
||||
return true;
|
||||
} else if (msb == id.msb && lsb < id.lsb) {
|
||||
return true;
|
||||
} else if (msb == id.msb && lsb == id.lsb && program_number < id.program_number) {
|
||||
} else if (bank_number == id.bank_number && program_number < id.program_number) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -168,7 +162,7 @@ public:
|
|||
|
||||
boost::shared_ptr<Patch> previous_patch(PatchPrimaryKey& key) {
|
||||
assert(key.is_sane());
|
||||
std::cerr << "finding patch with " << key.msb << "/" << key.lsb << "/" <<key.program_number << std::endl;
|
||||
std::cerr << "finding patch with " << key.bank_number << "/" <<key.program_number << std::endl;
|
||||
for (PatchList::const_iterator i = _patch_list.begin();
|
||||
i != _patch_list.end();
|
||||
++i) {
|
||||
|
@ -186,7 +180,7 @@ public:
|
|||
|
||||
boost::shared_ptr<Patch> next_patch(PatchPrimaryKey& key) {
|
||||
assert(key.is_sane());
|
||||
std::cerr << "finding patch with " << key.msb << "/" << key.lsb << "/" <<key.program_number << std::endl;
|
||||
std::cerr << "finding patch with " << key.bank_number << "/" <<key.program_number << std::endl;
|
||||
for (PatchList::const_iterator i = _patch_list.begin();
|
||||
i != _patch_list.end();
|
||||
++i) {
|
||||
|
|
|
@ -78,10 +78,12 @@ int initialize_primary_key_from_commands (PatchPrimaryKey& id, const XMLNode* no
|
|||
string value = node->property("Value")->value();
|
||||
assert(value != "");
|
||||
|
||||
id.bank_number = 0;
|
||||
|
||||
if (control == "0") {
|
||||
id.msb = PBD::atoi(value);
|
||||
id.bank_number |= (PBD::atoi (value)<<7);
|
||||
} else if (control == "32") {
|
||||
id.lsb = PBD::atoi(value);
|
||||
id.bank_number |= PBD::atoi (value);
|
||||
}
|
||||
} else if (node->name() == "ProgramChange") {
|
||||
string number = node->property("Number")->value();
|
||||
|
@ -135,8 +137,7 @@ Patch::use_bank_info (PatchBank* bank)
|
|||
{
|
||||
if (bank) {
|
||||
if (bank->patch_primary_key() ) {
|
||||
_id.msb = bank->patch_primary_key()->msb;
|
||||
_id.lsb = bank->patch_primary_key()->lsb;
|
||||
_id.bank_number = bank->patch_primary_key()->bank_number;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue