/[svn]/libgig/trunk/src/gig.cpp
ViewVC logotype

Diff of /libgig/trunk/src/gig.cpp

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

revision 3117 by schoenebeck, Sun Apr 16 23:20:30 2017 UTC revision 3324 by schoenebeck, Fri Jul 21 13:05:39 2017 UTC
# Line 24  Line 24 
24  #include "gig.h"  #include "gig.h"
25    
26  #include "helper.h"  #include "helper.h"
27    #include "Serialization.h"
28    
29  #include <algorithm>  #include <algorithm>
30  #include <math.h>  #include <math.h>
# Line 55  Line 56 
56  #define GIG_EG_CTR_DECAY_INFLUENCE_ENCODE(x)    ((x & 0x03) << 3)  #define GIG_EG_CTR_DECAY_INFLUENCE_ENCODE(x)    ((x & 0x03) << 3)
57  #define GIG_EG_CTR_RELEASE_INFLUENCE_ENCODE(x)  ((x & 0x03) << 5)  #define GIG_EG_CTR_RELEASE_INFLUENCE_ENCODE(x)  ((x & 0x03) << 5)
58    
59    #define SRLZ(member) \
60        archive->serializeMember(*this, member, #member);
61    
62  namespace gig {  namespace gig {
63    
64  // *************** Internal functions for sample decompression ***************  // *************** Internal functions for sample decompression ***************
# Line 315  namespace { Line 319  namespace {
319    
320    
321    
322    // *************** leverage_ctrl_t ***************
323    // *
324    
325        void leverage_ctrl_t::serialize(Serialization::Archive* archive) {
326            SRLZ(type);
327            SRLZ(controller_number);
328        }
329    
330    
331    
332    // *************** crossfade_t ***************
333    // *
334    
335        void crossfade_t::serialize(Serialization::Archive* archive) {
336            SRLZ(in_start);
337            SRLZ(in_end);
338            SRLZ(out_start);
339            SRLZ(out_end);
340        }
341    
342    
343    
344    // *************** eg_opt_t ***************
345    // *
346    
347        eg_opt_t::eg_opt_t() {
348            AttackCancel     = true;
349            AttackHoldCancel = true;
350            Decay1Cancel     = true;
351            Decay2Cancel     = true;
352            ReleaseCancel    = true;
353        }
354    
355        void eg_opt_t::serialize(Serialization::Archive* archive) {
356            SRLZ(AttackCancel);
357            SRLZ(AttackHoldCancel);
358            SRLZ(Decay1Cancel);
359            SRLZ(Decay2Cancel);
360            SRLZ(ReleaseCancel);
361        }
362    
363    
364    
365  // *************** Sample ***************  // *************** Sample ***************
366  // *  // *
367    
# Line 1685  namespace { Line 1732  namespace {
1732              VCFType                         = vcf_type_lowpass;              VCFType                         = vcf_type_lowpass;
1733              memset(DimensionUpperLimits, 127, 8);              memset(DimensionUpperLimits, 127, 8);
1734          }          }
1735            // format extension for EG behavior options, these will *NOT* work with
1736            // Gigasampler/GigaStudio !
1737            RIFF::Chunk* lsde = _3ewl->GetSubChunk(CHUNK_ID_LSDE);
1738            if (lsde) {
1739                unsigned char byte = lsde->ReadUint8();
1740                EGOptions.AttackCancel     = byte & 1;
1741                EGOptions.AttackHoldCancel = byte & (1 << 1);
1742                EGOptions.Decay1Cancel     = byte & (1 << 2);
1743                EGOptions.Decay2Cancel     = byte & (1 << 3);
1744                EGOptions.ReleaseCancel    = byte & (1 << 4);
1745            }
1746    
1747          pVelocityAttenuationTable = GetVelocityTable(VelocityResponseCurve,          pVelocityAttenuationTable = GetVelocityTable(VelocityResponseCurve,
1748                                                       VelocityResponseDepth,                                                       VelocityResponseDepth,
# Line 1790  namespace { Line 1848  namespace {
1848          }          }
1849      }      }
1850    
1851        void DimensionRegion::serialize(Serialization::Archive* archive) {
1852            // in case this class will become backward incompatible one day,
1853            // then set a version and minimum version for this class like:
1854            //archive->setVersion(*this, 2);
1855            //archive->setMinVersion(*this, 1);
1856    
1857            SRLZ(VelocityUpperLimit);
1858            SRLZ(EG1PreAttack);
1859            SRLZ(EG1Attack);
1860            SRLZ(EG1Decay1);
1861            SRLZ(EG1Decay2);
1862            SRLZ(EG1InfiniteSustain);
1863            SRLZ(EG1Sustain);
1864            SRLZ(EG1Release);
1865            SRLZ(EG1Hold);
1866            SRLZ(EG1Controller);
1867            SRLZ(EG1ControllerInvert);
1868            SRLZ(EG1ControllerAttackInfluence);
1869            SRLZ(EG1ControllerDecayInfluence);
1870            SRLZ(EG1ControllerReleaseInfluence);
1871            SRLZ(LFO1Frequency);
1872            SRLZ(LFO1InternalDepth);
1873            SRLZ(LFO1ControlDepth);
1874            SRLZ(LFO1Controller);
1875            SRLZ(LFO1FlipPhase);
1876            SRLZ(LFO1Sync);
1877            SRLZ(EG2PreAttack);
1878            SRLZ(EG2Attack);
1879            SRLZ(EG2Decay1);
1880            SRLZ(EG2Decay2);
1881            SRLZ(EG2InfiniteSustain);
1882            SRLZ(EG2Sustain);
1883            SRLZ(EG2Release);
1884            SRLZ(EG2Controller);
1885            SRLZ(EG2ControllerInvert);
1886            SRLZ(EG2ControllerAttackInfluence);
1887            SRLZ(EG2ControllerDecayInfluence);
1888            SRLZ(EG2ControllerReleaseInfluence);
1889            SRLZ(LFO2Frequency);
1890            SRLZ(LFO2InternalDepth);
1891            SRLZ(LFO2ControlDepth);
1892            SRLZ(LFO2Controller);
1893            SRLZ(LFO2FlipPhase);
1894            SRLZ(LFO2Sync);
1895            SRLZ(EG3Attack);
1896            SRLZ(EG3Depth);
1897            SRLZ(LFO3Frequency);
1898            SRLZ(LFO3InternalDepth);
1899            SRLZ(LFO3ControlDepth);
1900            SRLZ(LFO3Controller);
1901            SRLZ(LFO3Sync);
1902            SRLZ(VCFEnabled);
1903            SRLZ(VCFType);
1904            SRLZ(VCFCutoffController);
1905            SRLZ(VCFCutoffControllerInvert);
1906            SRLZ(VCFCutoff);
1907            SRLZ(VCFVelocityCurve);
1908            SRLZ(VCFVelocityScale);
1909            SRLZ(VCFVelocityDynamicRange);
1910            SRLZ(VCFResonance);
1911            SRLZ(VCFResonanceDynamic);
1912            SRLZ(VCFResonanceController);
1913            SRLZ(VCFKeyboardTracking);
1914            SRLZ(VCFKeyboardTrackingBreakpoint);
1915            SRLZ(VelocityResponseCurve);
1916            SRLZ(VelocityResponseDepth);
1917            SRLZ(VelocityResponseCurveScaling);
1918            SRLZ(ReleaseVelocityResponseCurve);
1919            SRLZ(ReleaseVelocityResponseDepth);
1920            SRLZ(ReleaseTriggerDecay);
1921            SRLZ(Crossfade);
1922            SRLZ(PitchTrack);
1923            SRLZ(DimensionBypass);
1924            SRLZ(Pan);
1925            SRLZ(SelfMask);
1926            SRLZ(AttenuationController);
1927            SRLZ(InvertAttenuationController);
1928            SRLZ(AttenuationControllerThreshold);
1929            SRLZ(ChannelOffset);
1930            SRLZ(SustainDefeat);
1931            SRLZ(MSDecode);
1932            //SRLZ(SampleStartOffset);
1933            SRLZ(SampleAttenuation);
1934            SRLZ(EGOptions);
1935    
1936            // derived attributes from DLS::Sampler
1937            SRLZ(FineTune);
1938            SRLZ(Gain);
1939        }
1940    
1941      /**      /**
1942       * Updates the respective member variable and updates @c SampleAttenuation       * Updates the respective member variable and updates @c SampleAttenuation
1943       * which depends on this value.       * which depends on this value.
# Line 2090  namespace { Line 2238  namespace {
2238          if (chunksize >= 148) {          if (chunksize >= 148) {
2239              memcpy(&pData[140], DimensionUpperLimits, 8);              memcpy(&pData[140], DimensionUpperLimits, 8);
2240          }          }
2241    
2242            // format extension for EG behavior options, these will *NOT* work with
2243            // Gigasampler/GigaStudio !
2244            RIFF::Chunk* lsde = pParentList->GetSubChunk(CHUNK_ID_LSDE);
2245            if (!lsde) {
2246                // only add this "LSDE" chunk if the EG options do not match the
2247                // default EG behavior
2248                eg_opt_t defaultOpt;
2249                if (memcmp(&EGOptions, &defaultOpt, sizeof(eg_opt_t))) {
2250                    lsde = pParentList->AddSubChunk(CHUNK_ID_LSDE, 1);
2251                    // move LSDE chunk to the end of parent list
2252                    pParentList->MoveSubChunk(lsde, (RIFF::Chunk*)NULL);
2253                }
2254            }
2255            if (lsde) {
2256                unsigned char* pByte = (unsigned char*) lsde->LoadChunkData();
2257                *pByte =
2258                    (EGOptions.AttackCancel     ? 1 : 0) |
2259                    (EGOptions.AttackHoldCancel ? (1<<1) : 0) |
2260                    (EGOptions.Decay1Cancel     ? (1<<2) : 0) |
2261                    (EGOptions.Decay2Cancel     ? (1<<3) : 0) |
2262                    (EGOptions.ReleaseCancel    ? (1<<4) : 0);
2263            }
2264      }      }
2265    
2266      double* DimensionRegion::GetReleaseVelocityTable(curve_type_t releaseVelocityResponseCurve, uint8_t releaseVelocityResponseDepth) {      double* DimensionRegion::GetReleaseVelocityTable(curve_type_t releaseVelocityResponseCurve, uint8_t releaseVelocityResponseDepth) {
# Line 2504  namespace { Line 2675  namespace {
2675    
2676              // unknown controller type              // unknown controller type
2677              default:              default:
2678                  throw gig::Exception("Unknown leverage controller type.");                  decodedcontroller.type = leverage_ctrl_t::type_none;
2679                    decodedcontroller.controller_number = 0;
2680                    printf("Warning: Unknown leverage controller type (0x%x).\n", EncodedController);
2681                    break;
2682          }          }
2683          return decodedcontroller;          return decodedcontroller;
2684      }      }
# Line 6358  namespace { Line 6532  namespace {
6532  // *************** Exception ***************  // *************** Exception ***************
6533  // *  // *
6534    
6535      Exception::Exception(String Message) : DLS::Exception(Message) {      Exception::Exception() : DLS::Exception() {
6536        }
6537    
6538        Exception::Exception(String format, ...) : DLS::Exception() {
6539            va_list arg;
6540            va_start(arg, format);
6541            Message = assemble(format, arg);
6542            va_end(arg);
6543        }
6544    
6545        Exception::Exception(String format, va_list arg) : DLS::Exception() {
6546            Message = assemble(format, arg);
6547      }      }
6548    
6549      void Exception::PrintMessage() {      void Exception::PrintMessage() {

Legend:
Removed from v.3117  
changed lines
  Added in v.3324

  ViewVC Help
Powered by ViewVC