2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file access library * |
* libgig - C++ cross-platform Gigasampler format file access library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003-2016 by Christian Schoenebeck * |
* Copyright (C) 2003-2017 by Christian Schoenebeck * |
6 |
* <cuse@users.sourceforge.net> * |
* <cuse@users.sourceforge.net> * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
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> |
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 *************** |
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 |
// *************** Sample *************** |
// *************** Sample *************** |
345 |
// * |
// * |
346 |
|
|
1816 |
} |
} |
1817 |
} |
} |
1818 |
|
|
1819 |
|
void DimensionRegion::serialize(Serialization::Archive* archive) { |
1820 |
|
SRLZ(VelocityUpperLimit); |
1821 |
|
SRLZ(EG1PreAttack); |
1822 |
|
SRLZ(EG1Attack); |
1823 |
|
SRLZ(EG1Decay1); |
1824 |
|
SRLZ(EG1Decay2); |
1825 |
|
SRLZ(EG1InfiniteSustain); |
1826 |
|
SRLZ(EG1Sustain); |
1827 |
|
SRLZ(EG1Release); |
1828 |
|
SRLZ(EG1Hold); |
1829 |
|
SRLZ(EG1Controller); |
1830 |
|
SRLZ(EG1ControllerInvert); |
1831 |
|
SRLZ(EG1ControllerAttackInfluence); |
1832 |
|
SRLZ(EG1ControllerDecayInfluence); |
1833 |
|
SRLZ(EG1ControllerReleaseInfluence); |
1834 |
|
SRLZ(LFO1Frequency); |
1835 |
|
SRLZ(LFO1InternalDepth); |
1836 |
|
SRLZ(LFO1ControlDepth); |
1837 |
|
SRLZ(LFO1Controller); |
1838 |
|
SRLZ(LFO1FlipPhase); |
1839 |
|
SRLZ(LFO1Sync); |
1840 |
|
SRLZ(EG2PreAttack); |
1841 |
|
SRLZ(EG2Attack); |
1842 |
|
SRLZ(EG2Decay1); |
1843 |
|
SRLZ(EG2Decay2); |
1844 |
|
SRLZ(EG2InfiniteSustain); |
1845 |
|
SRLZ(EG2Sustain); |
1846 |
|
SRLZ(EG2Release); |
1847 |
|
SRLZ(EG2Controller); |
1848 |
|
SRLZ(EG2ControllerInvert); |
1849 |
|
SRLZ(EG2ControllerAttackInfluence); |
1850 |
|
SRLZ(EG2ControllerDecayInfluence); |
1851 |
|
SRLZ(EG2ControllerReleaseInfluence); |
1852 |
|
SRLZ(LFO2Frequency); |
1853 |
|
SRLZ(LFO2InternalDepth); |
1854 |
|
SRLZ(LFO2ControlDepth); |
1855 |
|
SRLZ(LFO2Controller); |
1856 |
|
SRLZ(LFO2FlipPhase); |
1857 |
|
SRLZ(LFO2Sync); |
1858 |
|
SRLZ(EG3Attack); |
1859 |
|
SRLZ(EG3Depth); |
1860 |
|
SRLZ(LFO3Frequency); |
1861 |
|
SRLZ(LFO3InternalDepth); |
1862 |
|
SRLZ(LFO3ControlDepth); |
1863 |
|
SRLZ(LFO3Controller); |
1864 |
|
SRLZ(LFO3Sync); |
1865 |
|
SRLZ(VCFEnabled); |
1866 |
|
SRLZ(VCFType); |
1867 |
|
SRLZ(VCFCutoffController); |
1868 |
|
SRLZ(VCFCutoffControllerInvert); |
1869 |
|
SRLZ(VCFCutoff); |
1870 |
|
SRLZ(VCFVelocityCurve); |
1871 |
|
SRLZ(VCFVelocityScale); |
1872 |
|
SRLZ(VCFVelocityDynamicRange); |
1873 |
|
SRLZ(VCFResonance); |
1874 |
|
SRLZ(VCFResonanceDynamic); |
1875 |
|
SRLZ(VCFResonanceController); |
1876 |
|
SRLZ(VCFKeyboardTracking); |
1877 |
|
SRLZ(VCFKeyboardTrackingBreakpoint); |
1878 |
|
SRLZ(VelocityResponseCurve); |
1879 |
|
SRLZ(VelocityResponseDepth); |
1880 |
|
SRLZ(VelocityResponseCurveScaling); |
1881 |
|
SRLZ(ReleaseVelocityResponseCurve); |
1882 |
|
SRLZ(ReleaseVelocityResponseDepth); |
1883 |
|
SRLZ(ReleaseTriggerDecay); |
1884 |
|
SRLZ(Crossfade); |
1885 |
|
SRLZ(PitchTrack); |
1886 |
|
SRLZ(DimensionBypass); |
1887 |
|
SRLZ(Pan); |
1888 |
|
SRLZ(SelfMask); |
1889 |
|
SRLZ(AttenuationController); |
1890 |
|
SRLZ(InvertAttenuationController); |
1891 |
|
SRLZ(AttenuationControllerThreshold); |
1892 |
|
SRLZ(ChannelOffset); |
1893 |
|
SRLZ(SustainDefeat); |
1894 |
|
SRLZ(MSDecode); |
1895 |
|
//SRLZ(SampleStartOffset); |
1896 |
|
SRLZ(SampleAttenuation); |
1897 |
|
|
1898 |
|
// derived attributes from DLS::Sampler |
1899 |
|
SRLZ(FineTune); |
1900 |
|
SRLZ(Gain); |
1901 |
|
} |
1902 |
|
|
1903 |
/** |
/** |
1904 |
* Updates the respective member variable and updates @c SampleAttenuation |
* Updates the respective member variable and updates @c SampleAttenuation |
1905 |
* which depends on this value. |
* which depends on this value. |
4408 |
return pGroup; |
return pGroup; |
4409 |
} |
} |
4410 |
|
|
4411 |
|
/** |
4412 |
|
* Make a (semi) deep copy of the Script object given by @a orig |
4413 |
|
* and assign it to this object. Note: the ScriptGroup this Script |
4414 |
|
* object belongs to remains untouched by this call. |
4415 |
|
* |
4416 |
|
* @param orig - original Script object to be copied from |
4417 |
|
*/ |
4418 |
|
void Script::CopyAssign(const Script* orig) { |
4419 |
|
Name = orig->Name; |
4420 |
|
Compression = orig->Compression; |
4421 |
|
Encoding = orig->Encoding; |
4422 |
|
Language = orig->Language; |
4423 |
|
Bypass = orig->Bypass; |
4424 |
|
data = orig->data; |
4425 |
|
} |
4426 |
|
|
4427 |
void Script::RemoveAllScriptReferences() { |
void Script::RemoveAllScriptReferences() { |
4428 |
File* pFile = pGroup->pFile; |
File* pFile = pGroup->pFile; |
4429 |
for (int i = 0; pFile->GetInstrument(i); ++i) { |
for (int i = 0; pFile->GetInstrument(i); ++i) { |
5739 |
mGroups[pFile->GetSample(i)->GetGroup()]->AddSample(s); |
mGroups[pFile->GetSample(i)->GetGroup()]->AddSample(s); |
5740 |
mSamples[pFile->GetSample(i)] = s; |
mSamples[pFile->GetSample(i)] = s; |
5741 |
} |
} |
5742 |
|
|
5743 |
|
// clone script groups and their scripts |
5744 |
|
for (int iGroup = 0; pFile->GetScriptGroup(iGroup); ++iGroup) { |
5745 |
|
ScriptGroup* sg = pFile->GetScriptGroup(iGroup); |
5746 |
|
ScriptGroup* dg = AddScriptGroup(); |
5747 |
|
dg->Name = "COPY" + ToString(iCallCount) + "_" + sg->Name; |
5748 |
|
for (int iScript = 0; sg->GetScript(iScript); ++iScript) { |
5749 |
|
Script* ss = sg->GetScript(iScript); |
5750 |
|
Script* ds = dg->AddScript(); |
5751 |
|
ds->CopyAssign(ss); |
5752 |
|
} |
5753 |
|
} |
5754 |
|
|
5755 |
//BUG: For some reason this method only works with this additional |
//BUG: For some reason this method only works with this additional |
5756 |
// Save() call in between here. |
// Save() call in between here. |
5757 |
// |
// |