- Evoral::Parameter bank_select_lsb(MidiCCAutomation, channel, MIDI_CTL_LSB_BANK);
- boost::shared_ptr<Evoral::Control> lsb_control = _model->control(bank_select_lsb);
- uint8_t lsb = 0;
- if (lsb_control != 0) {
- lsb = uint8_t(floor(lsb_control->get_float(true, event_time) + 0.5));
- }
-
- //cerr << " got msb " << int(msb) << " and lsb " << int(lsb)
- // << " thread_id: " << pthread_self() << endl;
-
- MIDI::Name::PatchPrimaryKey patch_key(msb, lsb, program_number);
-
- boost::shared_ptr<MIDI::Name::Patch> patch =
- MIDI::Name::MidiPatchManager::instance().find_patch(
- _model_name,
- _custom_device_mode,
- channel,
- patch_key);
-
- ControlEvent program_change(beats_to_frames(event_time),
- uint8_t(program_number), channel);
-
- if (patch != 0) {
- //cerr << " got patch with name " << patch->name()
- // << " number " << patch->number() << endl;
- add_pgm_change(program_change, patch->name());
- } else {
- char buf[4];
- snprintf(buf, 4, "%d", int(program_number));
- add_pgm_change(program_change, buf);
- }
+ uint8_t channel = control->parameter().channel();
+
+ for (AutomationList::const_iterator event = control->list()->begin();
+ event != control->list()->end(); ++event) {
+ double event_time = (*event)->when;
+ double program_number = floor((*event)->value + 0.5);
+
+ // Get current value of bank select MSB at time of the program change
+ Evoral::Parameter bank_select_msb(MidiCCAutomation, channel, MIDI_CTL_MSB_BANK);
+ boost::shared_ptr<Evoral::Control> msb_control = _model->control(bank_select_msb);
+ uint8_t msb = 0;
+ if (msb_control != 0) {
+ msb = uint8_t(floor(msb_control->get_float(true, event_time) + 0.5));
+ }
+
+ // Get current value of bank select LSB at time of the program change
+ Evoral::Parameter bank_select_lsb(MidiCCAutomation, channel, MIDI_CTL_LSB_BANK);
+ boost::shared_ptr<Evoral::Control> lsb_control = _model->control(bank_select_lsb);
+ uint8_t lsb = 0;
+ if (lsb_control != 0) {
+ lsb = uint8_t(floor(lsb_control->get_float(true, event_time) + 0.5));
+ }
+
+ MIDI::Name::PatchPrimaryKey patch_key(msb, lsb, program_number);
+
+ boost::shared_ptr<MIDI::Name::Patch> patch =
+ MIDI::Name::MidiPatchManager::instance().find_patch(
+ _model_name, _custom_device_mode, channel, patch_key);
+
+ PCEvent program_change(event_time, uint8_t(program_number), channel);
+
+ if (patch != 0) {
+ add_pgm_change(program_change, patch->name());
+ } else {
+ char buf[4];
+ snprintf(buf, 4, "%d", int(program_number));
+ add_pgm_change(program_change, buf);
+ }
+ }
+}
+
+void
+MidiRegionView::display_sysexes()
+{
+ for (MidiModel::SysExes::const_iterator i = _model->sysexes().begin(); i != _model->sysexes().end(); ++i) {
+ ARDOUR::MidiModel::TimeType time = (*i)->time();
+ assert(time >= 0);
+
+ ostringstream str;
+ str << hex;
+ for (uint32_t b = 0; b < (*i)->size(); ++b) {
+ str << int((*i)->buffer()[b]);
+ if (b != (*i)->size() -1) {
+ str << " ";