Hi

I've attached an updated version of the linuxsampler-2.1.0.svn1 patch I submitted on Tuesday morning. The previous one should have worked most of the time but the logic wasn't quite correct. I'm using copies of Tascam GigaPiano II, edited in gigedit, to test my changes btw and they appear to be working.

All the best,
Ivan

diff -Naur '--exclude=.svn' linuxsampler_original/src/engines/common/MidiKeyboardManager.h linuxsampler_modified/src/engines/common/MidiKeyboardManager.h
--- linuxsampler_original/src/engines/common/MidiKeyboardManager.h	2018-12-17 20:19:46.567208572 +0000
+++ linuxsampler_modified/src/engines/common/MidiKeyboardManager.h	2018-12-19 23:35:59.809800000 +0000
@@ -31,6 +31,7 @@
 #include "../../common/Pool.h"
 #include "../../common/global_private.h"
 #include "Note.h"
+#include "libgig/gig.h"
 
 namespace LinuxSampler {
 
@@ -692,23 +693,53 @@
             void ProcessSustainPedalUp(Pool<Event>::Iterator& itEvent) {
                 // release voices if their respective key is not pressed
                 RTList<uint>::Iterator iuiKey = pActiveKeys->first();
+                AbstractEngineChannel* pChannel = (AbstractEngineChannel*) itEvent->pEngineChannel;
+                AbstractEngine* pEngine = (AbstractEngine*)pChannel->GetEngine();
+                bool isGigEngine = pEngine->GetEngineFormat() == AbstractEngine::Format::GIG;
                 for (; iuiKey; ++iuiKey) {
                     MidiKey* pKey = &pMIDIKeyInfo[*iuiKey];
                     if (!pKey->KeyPressed && ShouldReleaseVoice(*iuiKey)) {
+                        // default sustain up release samples behaviour
+                        bool triggerReleaseSamples = isGigEngine ? false : true;
+                        int releaseSamplesVelocity = 127;
+                        if (isGigEngine) {
+                            // try to get sustain up release option from DimensionRegion
+                            RTListNoteIterator itNote = pKey->pActiveNotes->first();
+                            if (itNote != pKey->pActiveNotes->end()) {
+                                RTListVoiceIterator itVoice = itNote->pActiveVoices->first();
+                                if (itVoice != itNote->pActiveVoices->end()) {
+                                    ::gig::DimensionRegion* pRegion = (::gig::DimensionRegion*)itVoice->GetRegion();
+                                    if (pRegion) {
+                                        switch(pRegion->SustainUpReleaseOption) {
+                                            case ::gig::sustup_relsmp_t::sustup_relsmp_none:
+                                                // no change from the default
+                                                break;
+                                            case ::gig::sustup_relsmp_t::sustup_relsmp_max_vel:
+                                                triggerReleaseSamples = true;
+                                                break;
+                                            case ::gig::sustup_relsmp_t::sustup_relsmp_last_vel:
+                                                triggerReleaseSamples = true;
+                                                releaseSamplesVelocity = pKey->Velocity;
+                                                break;
+                                        }
+                                    }
+                                }
+                            }
+                        }
                         RTList<Event>::Iterator itNewEvent = pKey->pEvents->allocAppend();
                         if (itNewEvent) {
                             *itNewEvent = *itEvent; // copy event to the key's own event list
                             itNewEvent->Type = Event::type_release_key; // transform event type
                             itNewEvent->Param.Note.Key = *iuiKey;
-                            itNewEvent->Param.Note.Velocity = 127;
+                            itNewEvent->Param.Note.Velocity = releaseSamplesVelocity;
                             if (!SostenutoActiveOnKey(*iuiKey)) {
                                 //HACK: set sustain CC (64) as "pressed down" for a short moment, so that release trigger voices can distinguish between note off and sustain pedal up cases
-                                AbstractEngineChannel* pChannel = (AbstractEngineChannel*) itEvent->pEngineChannel;
                                 const int8_t CC64Value = pChannel->ControllerTable[64];
                                 pChannel->ControllerTable[64] = 127;
 
                                 // now spawn release trigger voices (if required)
-                                ProcessReleaseTrigger(itNewEvent);
+                                if (triggerReleaseSamples)
+                                    ProcessReleaseTrigger(itNewEvent);
 
                                 //HACK: reset sustain pedal CC value to old one (see comment above)
                                 pChannel->ControllerTable[64] = CC64Value;
_______________________________________________
Linuxsampler-devel mailing list
Linuxsampler-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel

Reply via email to