Hi everyone

I've attached two small patches that I'm using that you might also find useful.

linuxsampler-2.1.0.svn1-sustain_release_velocity.patch causes sustain release samples to be played with the latest Note On velocity of each key instead of the current hard-coded velocity of 127 (the highest). This was causing me a problem while playing some piano instruments like PMI Emperor 24-bit where I would hear an unnaturally loud thump and string noise on releasing the sustain pedal even after playing very softly.

libgig-4.1.0.svn5-load_giga4_as_giga3.patch causes GigaStudio 4 instruments to be loaded as if they were GigaStudio 3 instruments. They are currently loaded as if they were GigaStudio 2 instruments making them unplayable (usually the same samples on every key). I have a set of about 25 GigaStudio 4 instruments which were included on my GigaStudio 4 installation discs. There are only one or two of these instruments which don't behave as expected with this patch.

Kind regards,
Ivan

diff -Naur linuxsampler_original/src/engines/common/MidiKeyboardManager.h linuxsampler_modified/src/engines/common/MidiKeyboardManager.h
--- linuxsampler_original/src/engines/common/MidiKeyboardManager.h	2018-08-11 20:20:44.505782040 +0100
+++ linuxsampler_modified/src/engines/common/MidiKeyboardManager.h	2018-08-11 20:23:59.425587803 +0100
@@ -700,7 +700,7 @@
                             *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 = pKey->Velocity;
                             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;

diff -Naur libgig_original/src/gig.cpp libgig_modified/src/gig.cpp
--- libgig_original/src/gig.cpp	2018-08-14 21:00:56.946626642 +0100
+++ libgig_modified/src/gig.cpp	2018-12-06 23:27:21.984985925 +0000
@@ -468,7 +468,7 @@
         TruncatedBits     = 0;
         if (Compressed) {
             uint32_t version = ewav->ReadInt32();
-            if (version == 3 && BitDepth == 24) {
+            if (version > 2 && BitDepth == 24) {
                 Dithered = ewav->ReadInt32();
                 ewav->SetPos(Channels == 2 ? 84 : 64);
                 TruncatedBits = ewav->ReadInt32();
@@ -1975,8 +1975,8 @@
         RIFF::Chunk* _3ewa = pParentList->GetSubChunk(CHUNK_ID_3EWA);
         if (!_3ewa) {
             File* pFile = (File*) GetParent()->GetParent()->GetParent();
-            bool version3 = pFile->pVersion && pFile->pVersion->major == 3;
-            _3ewa = pParentList->AddSubChunk(CHUNK_ID_3EWA, version3 ? 148 : 140);
+            bool versiongt2 = pFile->pVersion && pFile->pVersion->major > 2;
+            _3ewa = pParentList->AddSubChunk(CHUNK_ID_3EWA, versiongt2 ? 148 : 140);
         }
         pData = (uint8_t*) _3ewa->LoadChunkData();
 
@@ -3208,7 +3208,7 @@
         }
         Layers = 1;
         File* file = (File*) GetParent()->GetParent();
-        int dimensionBits = (file->pVersion && file->pVersion->major == 3) ? 8 : 5;
+        int dimensionBits = (file->pVersion && file->pVersion->major > 2) ? 8 : 5;
 
         // Actual Loading
 
@@ -3252,7 +3252,7 @@
             UpdateVelocityTable();
 
             // jump to start of the wave pool indices (if not already there)
-            if (file->pVersion && file->pVersion->major == 3)
+            if (file->pVersion && file->pVersion->major > 2)
                 _3lnk->SetPos(68); // version 3 has a different 3lnk structure
             else
                 _3lnk->SetPos(44);
@@ -3311,14 +3311,14 @@
         }
 
         File* pFile = (File*) GetParent()->GetParent();
-        bool version3 = pFile->pVersion && pFile->pVersion->major == 3;
-        const int iMaxDimensions =  version3 ? 8 : 5;
-        const int iMaxDimensionRegions = version3 ? 256 : 32;
+        bool versiongt2 = pFile->pVersion && pFile->pVersion->major > 2;
+        const int iMaxDimensions =  versiongt2 ? 8 : 5;
+        const int iMaxDimensionRegions = versiongt2 ? 256 : 32;
 
         // make sure '3lnk' chunk exists
         RIFF::Chunk* _3lnk = pCkRegion->GetSubChunk(CHUNK_ID_3LNK);
         if (!_3lnk) {
-            const int _3lnkChunkSize = version3 ? 1092 : 172;
+            const int _3lnkChunkSize = versiongt2 ? 1092 : 172;
             _3lnk = pCkRegion->AddSubChunk(CHUNK_ID_3LNK, _3lnkChunkSize);
             memset(_3lnk->LoadChunkData(), 0, _3lnkChunkSize);
 
@@ -3342,7 +3342,7 @@
         }
 
         // update wave pool table in '3lnk' chunk
-        const int iWavePoolOffset = version3 ? 68 : 44;
+        const int iWavePoolOffset = versiongt2 ? 68 : 44;
         for (uint i = 0; i < iMaxDimensionRegions; i++) {
             int iWaveIndex = -1;
             if (i < DimensionRegions) {
@@ -3485,7 +3485,7 @@
 
         // check if max. amount of dimensions reached
         File* file = (File*) GetParent()->GetParent();
-        const int iMaxDimensions = (file->pVersion && file->pVersion->major == 3) ? 8 : 5;
+        const int iMaxDimensions = (file->pVersion && file->pVersion->major > 2) ? 8 : 5;
         if (Dimensions >= iMaxDimensions)
             throw gig::Exception("Could not add new dimension, max. amount of " + ToString(iMaxDimensions) + " dimensions already reached");
         // check if max. amount of dimension bits reached
@@ -4817,7 +4817,7 @@
             File* pFile = (File*) GetParent();
 
             // 3ewg is bigger in gig3, as it includes the iMIDI rules
-            int size = (pFile->pVersion && pFile->pVersion->major == 3) ? 16416 : 12;
+            int size = (pFile->pVersion && pFile->pVersion->major > 2) ? 16416 : 12;
             _3ewg = lart->AddSubChunk(CHUNK_ID_3EWG, size);
             memset(_3ewg->LoadChunkData(), 0, size);
         }
@@ -5399,7 +5399,7 @@
         RIFF::List* _3gnl = _3gri->GetSubList(LIST_TYPE_3GNL);
         if (!_3gnl) _3gnl = _3gri->AddSubList(LIST_TYPE_3GNL);
 
-        if (!pNameChunk && pFile->pVersion && pFile->pVersion->major == 3) {
+        if (!pNameChunk && pFile->pVersion && pFile->pVersion->major > 2) {
             // v3 has a fixed list of 128 strings, find a free one
             for (RIFF::Chunk* ck = _3gnl->GetFirstSubChunk() ; ck ; ck = _3gnl->GetNextSubChunk()) {
                 if (strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) {
@@ -6071,7 +6071,7 @@
             _3crc = pRIFF->AddSubChunk(CHUNK_ID_3CRC, pSamples->size() * 8);
             // the order of einf and 3crc is not the same in v2 and v3
             RIFF::Chunk* einf = pRIFF->GetSubChunk(CHUNK_ID_EINF);
-            if (einf && pVersion && pVersion->major == 3) pRIFF->MoveSubChunk(_3crc, einf);
+            if (einf && pVersion && pVersion->major > 2) pRIFF->MoveSubChunk(_3crc, einf);
             bRequiresSave = true;
         } else if (_3crc->GetNewSize() != pSamples->size() * 8) {
             _3crc->Resize(pSamples->size() * 8);
@@ -6220,7 +6220,7 @@
                 RIFF::Chunk* ck = lst3gnl->GetFirstSubChunk();
                 while (ck) {
                     if (ck->GetChunkID() == CHUNK_ID_3GNM) {
-                        if (pVersion && pVersion->major == 3 &&
+                        if (pVersion && pVersion->major > 2 &&
                             strcmp(static_cast<char*>(ck->LoadChunkData()), "") == 0) break;
 
                         pGroups->push_back(new Group(this, ck));
@@ -6396,7 +6396,7 @@
 
             // v3: make sure the file has 128 3gnm chunks
             // (before updating the Group chunks)
-            if (pVersion && pVersion->major == 3) {
+            if (pVersion && pVersion->major > 2) {
                 RIFF::Chunk* _3gnm = _3gnl->GetFirstSubChunk();
                 for (int i = 0 ; i < 128 ; i++) {
                     if (i >= pGroups->size()) ::SaveString(CHUNK_ID_3GNM, _3gnm, _3gnl, "", "", true, 64);
@@ -6542,7 +6542,7 @@
         } else /*if (newFile)*/ {
             _3crc = pRIFF->AddSubChunk(CHUNK_ID_3CRC, pSamples->size() * 8);
             // the order of einf and 3crc is not the same in v2 and v3
-            if (einf && pVersion && pVersion->major == 3) pRIFF->MoveSubChunk(_3crc, einf);
+            if (einf && pVersion && pVersion->major > 2) pRIFF->MoveSubChunk(_3crc, einf);
         }
         { // must be performed in RAM here ...
             uint32_t* pData = (uint32_t*) _3crc->LoadChunkData();

_______________________________________________
Linuxsampler-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel

Reply via email to