/[svn]/linuxsampler/trunk/src/engines/EngineChannel.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/EngineChannel.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1923 by persson, Mon May 4 18:34:44 2009 UTC revision 1924 by persson, Sun Jun 28 16:43:38 2009 UTC
# Line 272  namespace LinuxSampler { Line 272  namespace LinuxSampler {
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

Legend:
Removed from v.1923  
changed lines
  Added in v.1924

  ViewVC Help
Powered by ViewVC