--- linuxsampler/trunk/src/engines/gig/Engine.cpp 2008/07/10 15:00:38 1750 +++ linuxsampler/trunk/src/engines/gig/Engine.cpp 2008/08/29 17:33:02 1762 @@ -953,12 +953,15 @@ * * @param pData - pointer to sysex data * @param Size - lenght of sysex data (in bytes) + * @param pSender - the MIDI input port on which the SysEx message was + * received */ - void Engine::SendSysex(void* pData, uint Size) { + void Engine::SendSysex(void* pData, uint Size, MidiInputPort* pSender) { Event event = pEventGenerator->CreateEvent(); event.Type = Event::type_sysex; event.Param.Sysex.Size = Size; event.pEngineChannel = NULL; // as Engine global event + event.pMidiInputPort = pSender; if (pEventQueue->write_space() > 0) { if (pSysexBuffer->write_space() >= Size) { // copy sysex data to input buffer @@ -1901,10 +1904,27 @@ switch (sub_id1) { case 0x04: // Device Control switch (sub_id2) { - case 0x01: // Master Volume - GLOBAL_VOLUME = + case 0x01: { // Master Volume + const double volume = double((uint(val_msb)<<7) | uint(val_lsb)) / 16383.0; + #if CONFIG_MASTER_VOLUME_SYSEX_BY_PORT + // apply volume to all sampler channels that + // are connected to the same MIDI input port + // this sysex message arrived on + for (int i = 0; i < engineChannels.size(); ++i) { + EngineChannel* pEngineChannel = engineChannels[i]; + if (pEngineChannel->GetMidiInputPort() == + itSysexEvent->pMidiInputPort) + { + pEngineChannel->Volume(volume); + } + } + #else + // apply volume globally to the whole sampler + GLOBAL_VOLUME = volume; + #endif // CONFIG_MASTER_VOLUME_SYSEX_BY_PORT break; + } } break; } @@ -1953,8 +1973,10 @@ if (!reader.pop(&map)) goto free_sysex_data; for (int i = 0; i < engineChannels.size(); ++i) { EngineChannel* pEngineChannel = engineChannels[i]; - if (pEngineChannel->midiChannel == part || - pEngineChannel->midiChannel == midi_chan_all + if ( + (pEngineChannel->midiChannel == part || + pEngineChannel->midiChannel == midi_chan_all) && + pEngineChannel->GetMidiInputPort() == itSysexEvent->pMidiInputPort ) { try { pEngineChannel->SetMidiInstrumentMap(map); @@ -2112,7 +2134,7 @@ } String Engine::Version() { - String s = "$Revision: 1.94 $"; + String s = "$Revision: 1.96 $"; return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword }