272 |
} |
} |
273 |
} |
} |
274 |
|
|
275 |
|
void EngineChannel::ExecuteProgramChange(uint8_t Program) { |
276 |
|
dmsg(1,("Received MIDI program change (prog=%d)\n",Program)); |
277 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
278 |
|
if (maps.empty()) return; |
279 |
|
|
280 |
|
SetMidiProgram(Program); |
281 |
|
if (UsesNoMidiInstrumentMap()) return; |
282 |
|
if (MidiInstrumentMapper::GetMapCount() == 0) return; |
283 |
|
// retrieve the MIDI instrument map this engine channel is assigned to |
284 |
|
int iMapID = (UsesDefaultMidiInstrumentMap()) |
285 |
|
? MidiInstrumentMapper::GetDefaultMap() /*default*/ : GetMidiInstrumentMap(); |
286 |
|
// is there an entry for this MIDI bank&prog pair in that map? |
287 |
|
midi_prog_index_t midiIndex; |
288 |
|
midiIndex.midi_bank_msb = GetMidiBankMsb(); |
289 |
|
midiIndex.midi_bank_lsb = GetMidiBankLsb(); |
290 |
|
midiIndex.midi_prog = GetMidiProgram(); |
291 |
|
optional<MidiInstrumentMapper::entry_t> mapping = |
292 |
|
MidiInstrumentMapper::GetEntry(iMapID, midiIndex); |
293 |
|
if (mapping) { // if mapping exists ... |
294 |
|
InstrumentManager::instrument_id_t id; |
295 |
|
id.FileName = mapping->InstrumentFile; |
296 |
|
id.Index = mapping->InstrumentIndex; |
297 |
|
//TODO: we should switch the engine type here |
298 |
|
InstrumentManager::LoadInstrumentInBackground(id, this); |
299 |
|
Volume(mapping->Volume); |
300 |
|
} |
301 |
|
} |
302 |
|
|
303 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |