Skip to content

Commit

Permalink
Use automation track for MIDI program change events (#6308)
Browse files Browse the repository at this point in the history
  • Loading branch information
Veratil authored Jul 8, 2022
1 parent 1246e76 commit f39b3d5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plugins/MidiImport/MidiImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ bool MidiImport::readSMF( TrackContainer* tc )
// 128 CC + Pitch Bend
smfMidiCC ccs[MIDI_CC_COUNT];

// channel to CC object for program changes
std::unordered_map<long, smfMidiCC> pcs;

// channels can be set out of 256 range
// using unordered_map should fix most invalid loads and crashes while loading
std::unordered_map<long, smfMidiChannel> chs;
Expand Down Expand Up @@ -467,8 +470,12 @@ bool MidiImport::readSMF( TrackContainer* tc )
long prog = evt->get_integer_value();
if( ch->isSF2 )
{
ch->it_inst->childModel( "bank" )->setValue( 0 );
ch->it_inst->childModel( "patch" )->setValue( prog );
auto& pc = pcs[evt->chan];
AutomatableModel* objModel = ch->it_inst->childModel("patch");
if (pc.at == nullptr) {
pc.create(tc, trackName + " > " + objModel->displayName());
}
pc.putValue(time, objModel, prog);
}
else {
const QString num = QString::number( prog );
Expand Down

0 comments on commit f39b3d5

Please sign in to comment.