35 #define GIG_FILE_EXT_VERSION 2 42 #define INITIAL_SAMPLE_BUFFER_SIZE 512000 // 512 kB 45 #define GIG_EXP_DECODE(x) (pow(1.000000008813822, x)) 46 #define GIG_EXP_ENCODE(x) (log(x) / log(1.000000008813822)) 47 #define GIG_PITCH_TRACK_EXTRACT(x) (!(x & 0x01)) 48 #define GIG_PITCH_TRACK_ENCODE(x) ((x) ? 0x00 : 0x01) 49 #define GIG_VCF_RESONANCE_CTRL_EXTRACT(x) ((x >> 4) & 0x03) 50 #define GIG_VCF_RESONANCE_CTRL_ENCODE(x) ((x & 0x03) << 4) 51 #define GIG_EG_CTR_ATTACK_INFLUENCE_EXTRACT(x) ((x >> 1) & 0x03) 52 #define GIG_EG_CTR_DECAY_INFLUENCE_EXTRACT(x) ((x >> 3) & 0x03) 53 #define GIG_EG_CTR_RELEASE_INFLUENCE_EXTRACT(x) ((x >> 5) & 0x03) 54 #define GIG_EG_CTR_ATTACK_INFLUENCE_ENCODE(x) ((x & 0x03) << 1) 55 #define GIG_EG_CTR_DECAY_INFLUENCE_ENCODE(x) ((x & 0x03) << 3) 56 #define GIG_EG_CTR_RELEASE_INFLUENCE_ENCODE(x) ((x & 0x03) << 5) 65 inline int get12lo(
const unsigned char* pSrc)
67 const int x = pSrc[0] | (pSrc[1] & 0x0f) << 8;
68 return x & 0x800 ? x - 0x1000 : x;
71 inline int get12hi(
const unsigned char* pSrc)
73 const int x = pSrc[1] >> 4 | pSrc[2] << 4;
74 return x & 0x800 ? x - 0x1000 : x;
77 inline int16_t get16(
const unsigned char* pSrc)
79 return int16_t(pSrc[0] | pSrc[1] << 8);
82 inline int get24(
const unsigned char* pSrc)
84 const int x = pSrc[0] | pSrc[1] << 8 | pSrc[2] << 16;
85 return x & 0x800000 ? x - 0x1000000 : x;
88 inline void store24(
unsigned char* pDst,
int x)
95 void Decompress16(
int compressionmode,
const unsigned char* params,
96 int srcStep,
int dstStep,
97 const unsigned char* pSrc, int16_t* pDst,
101 switch (compressionmode) {
103 pSrc += currentframeoffset * srcStep;
104 while (copysamples) {
113 int y = get16(params);
114 int dy = get16(params + 2);
115 while (currentframeoffset) {
119 currentframeoffset--;
121 while (copysamples) {
133 void Decompress24(
int compressionmode,
const unsigned char* params,
134 int dstStep,
const unsigned char* pSrc, uint8_t* pDst,
138 int y, dy, ddy, dddy;
140 #define GET_PARAMS(params) \ 142 dy = y - get24((params) + 3); \ 143 ddy = get24((params) + 6); \ 144 dddy = get24((params) + 9) 146 #define SKIP_ONE(x) \ 152 #define COPY_ONE(x) \ 154 store24(pDst, y << truncatedBits); \ 157 switch (compressionmode) {
159 pSrc += currentframeoffset * 3;
160 while (copysamples) {
161 store24(pDst, get24(pSrc) << truncatedBits);
170 while (currentframeoffset) {
173 currentframeoffset--;
175 while (copysamples) {
184 while (currentframeoffset > 1) {
188 currentframeoffset -= 2;
190 if (currentframeoffset) {
192 currentframeoffset--;
199 while (copysamples > 1) {
212 while (currentframeoffset) {
214 currentframeoffset--;
216 while (copysamples) {
224 const int bytesPerFrame[] = { 4096, 2052, 768, 524, 396, 268 };
225 const int bytesPerFrameNoHdr[] = { 4096, 2048, 768, 512, 384, 256 };
226 const int headerSize[] = { 0, 4, 0, 12, 12, 12 };
227 const int bitsPerSample[] = { 16, 8, 24, 16, 12, 8 };
235 static uint32_t* __initCRCTable() {
236 static uint32_t res[256];
238 for (
int i = 0 ; i < 256 ; i++) {
240 for (
int j = 0 ; j < 8 ; j++) {
241 c = (c & 1) ? 0xedb88320 ^ (c >> 1) : c >> 1;
248 static const uint32_t* __CRCTable = __initCRCTable();
255 inline static void __resetCRC(uint32_t& crc) {
278 static void __calculateCRC(
unsigned char* buf,
int bufSize, uint32_t& crc) {
279 for (
int i = 0 ; i < bufSize ; i++) {
280 crc = __CRCTable[(crc ^ buf[i]) & 0xff] ^ (crc >> 8);
289 inline static uint32_t __encodeCRC(
const uint32_t& crc) {
290 return crc ^ 0xffffffff;
311 static int __resolveZoneSize(dimension_def_t& dimension_definition) {
313 ? int(128.0 / dimension_definition.zones) : 0;
411 if (version == 3 &&
BitDepth == 24) {
416 ScanCompressedSample();
481 const int iReadAtOnce = 32*1024;
482 char* buf =
new char[iReadAtOnce * orig->
FrameSize];
488 n = pOrig->
Read(buf, iReadAtOnce))
492 pOrig->
SetPos(restorePos);
528 store32(&pData[28],
Loops);
532 store32(&pData[36],
LoopID);
543 uint16_t iSampleGroup = 0;
545 if (pFile->pGroups) {
546 std::list<Group*>::iterator iter = pFile->pGroups->begin();
547 std::list<Group*>::iterator end = pFile->pGroups->end();
548 for (
int i = 0; iter != end; i++, iter++) {
557 store16(&pData[0], iSampleGroup);
569 void Sample::ScanCompressedSample() {
572 std::list<file_offset_t> frameOffsets;
580 for (
int i = 0 ; ; i++) {
587 if (mode_l > 5 || mode_r > 5)
throw gig::Exception(
"Unknown compression mode");
588 const file_offset_t frameSize = bytesPerFrame[mode_l] + bytesPerFrame[mode_r];
593 (bitsPerSample[mode_l] + bitsPerSample[mode_r]);
602 for (
int i = 0 ; ; i++) {
624 std::list<file_offset_t>::iterator end = frameOffsets.end();
625 std::list<file_offset_t>::iterator iter = frameOffsets.begin();
626 for (
int i = 0; iter != end; i++, iter++) {
852 return (result == orderedBytes) ? SampleCount
901 file_offset_t samplestoread = SampleCount, totalreadsamples = 0, readsamples, samplestoloopend;
902 uint8_t* pDst = (uint8_t*) pBuffer;
911 if (
GetPos() <= loopEnd) {
919 if (!pPlaybackState->
reverse) {
921 samplestoloopend = loopEnd -
GetPos();
922 readsamples =
Read(&pDst[totalreadsamples * this->
FrameSize], Min(samplestoread, samplestoloopend), pExternalDecompressionBuffer);
923 samplestoread -= readsamples;
924 totalreadsamples += readsamples;
925 if (readsamples == samplestoloopend) {
926 pPlaybackState->
reverse =
true;
929 }
while (samplestoread && readsamples);
941 file_offset_t samplestoreadinloop = Min(samplestoread, loopoffset);
944 SetPos(reverseplaybackend);
948 readsamples =
Read(&pDst[totalreadsamples * this->
FrameSize], samplestoreadinloop, pExternalDecompressionBuffer);
949 samplestoreadinloop -= readsamples;
950 samplestoread -= readsamples;
951 totalreadsamples += readsamples;
952 }
while (samplestoreadinloop && readsamples);
954 SetPos(reverseplaybackend);
956 if (reverseplaybackend == loop.
LoopStart) {
958 pPlaybackState->
reverse =
false;
962 if (totalreadsamples > swapareastart)
963 SwapMemoryArea(&pDst[swapareastart * this->
FrameSize], (totalreadsamples - swapareastart) * this->FrameSize, this->FrameSize);
965 }
while (samplestoread && readsamples);
971 if (!pPlaybackState->
reverse)
do {
972 samplestoloopend = loopEnd -
GetPos();
973 readsamples =
Read(&pDst[totalreadsamples * this->
FrameSize], Min(samplestoread, samplestoloopend), pExternalDecompressionBuffer);
974 samplestoread -= readsamples;
975 totalreadsamples += readsamples;
976 if (readsamples == samplestoloopend) {
977 pPlaybackState->
reverse =
true;
980 }
while (samplestoread && readsamples);
982 if (!samplestoread)
break;
996 SetPos(reverseplaybackend);
1002 samplestoloopend = loopEnd -
GetPos();
1003 readsamples =
Read(&pDst[totalreadsamples * this->
FrameSize], Min(samplestoreadinloop, samplestoloopend), pExternalDecompressionBuffer);
1004 samplestoreadinloop -= readsamples;
1005 samplestoread -= readsamples;
1006 totalreadsamples += readsamples;
1007 if (readsamples == samplestoloopend) {
1011 }
while (samplestoreadinloop && readsamples);
1013 SetPos(reverseplaybackend);
1016 SwapMemoryArea(&pDst[swapareastart * this->
FrameSize], (totalreadsamples - swapareastart) * this->FrameSize, this->FrameSize);
1024 samplestoloopend = loopEnd -
GetPos();
1025 readsamples =
Read(&pDst[totalreadsamples * this->
FrameSize], Min(samplestoread, samplestoloopend), pExternalDecompressionBuffer);
1026 samplestoread -= readsamples;
1027 totalreadsamples += readsamples;
1028 if (readsamples == samplestoloopend) {
1032 }
while (samplestoread && readsamples);
1040 if (samplestoread)
do {
1041 readsamples =
Read(&pDst[totalreadsamples * this->
FrameSize], samplestoread, pExternalDecompressionBuffer);
1042 samplestoread -= readsamples;
1043 totalreadsamples += readsamples;
1044 }
while (readsamples && samplestoread);
1049 return totalreadsamples;
1075 if (SampleCount == 0)
return 0;
1091 remainingsamples = SampleCount,
1092 copysamples, skipsamples,
1099 if (pDecompressionBuffer->
Size < assumedsize) {
1100 std::cerr <<
"gig::Read(): WARNING - decompression buffer size too small!" << std::endl;
1102 remainingsamples = SampleCount;
1106 unsigned char* pSrc = (
unsigned char*) pDecompressionBuffer->
pStart;
1107 int16_t* pDst = static_cast<int16_t*>(pBuffer);
1108 uint8_t* pDst24 =
static_cast<uint8_t*
>(pBuffer);
1109 remainingbytes =
pCkData->
Read(pSrc, assumedsize, 1);
1111 while (remainingsamples && remainingbytes) {
1113 file_offset_t framebytes, rightChannelOffset = 0, nextFrameOffset;
1115 int mode_l = *pSrc++, mode_r = 0;
1119 framebytes = bytesPerFrame[mode_l] + bytesPerFrame[mode_r] + 2;
1120 rightChannelOffset = bytesPerFrameNoHdr[mode_l];
1121 nextFrameOffset = rightChannelOffset + bytesPerFrameNoHdr[mode_r];
1122 if (remainingbytes < framebytes) {
1124 if (mode_l == 4 && (framesamples & 1)) {
1125 rightChannelOffset = ((framesamples + 1) * bitsPerSample[mode_l]) >> 3;
1128 rightChannelOffset = (framesamples * bitsPerSample[mode_l]) >> 3;
1133 framebytes = bytesPerFrame[mode_l] + 1;
1134 nextFrameOffset = bytesPerFrameNoHdr[mode_l];
1135 if (remainingbytes < framebytes) {
1141 if (currentframeoffset + remainingsamples >= framesamples) {
1142 if (currentframeoffset <= framesamples) {
1143 copysamples = framesamples - currentframeoffset;
1144 skipsamples = currentframeoffset;
1148 skipsamples = framesamples;
1155 copysamples = remainingsamples;
1156 skipsamples = currentframeoffset;
1158 this->
FrameOffset = currentframeoffset + copysamples;
1160 remainingsamples -= copysamples;
1162 if (remainingbytes > framebytes) {
1163 remainingbytes -= framebytes;
1164 if (remainingsamples == 0 &&
1165 currentframeoffset + copysamples == framesamples) {
1173 else remainingbytes = 0;
1175 currentframeoffset -= skipsamples;
1177 if (copysamples == 0) {
1182 const unsigned char*
const param_l = pSrc;
1184 if (mode_l != 2) pSrc += 12;
1187 const unsigned char*
const param_r = pSrc;
1188 if (mode_r != 2) pSrc += 12;
1190 Decompress24(mode_l, param_l, 6, pSrc, pDst24,
1192 Decompress24(mode_r, param_r, 6, pSrc + rightChannelOffset, pDst24 + 3,
1194 pDst24 += copysamples * 6;
1197 Decompress24(mode_l, param_l, 3, pSrc, pDst24,
1199 pDst24 += copysamples * 3;
1203 if (mode_l) pSrc += 4;
1207 const unsigned char*
const param_r = pSrc;
1208 if (mode_r) pSrc += 4;
1210 step = (2 - mode_l) + (2 - mode_r);
1211 Decompress16(mode_l, param_l, step, 2, pSrc, pDst, skipsamples, copysamples);
1212 Decompress16(mode_r, param_r, step, 2, pSrc + (2 - mode_l), pDst + 1,
1213 skipsamples, copysamples);
1214 pDst += copysamples << 1;
1218 Decompress16(mode_l, param_l, step, 1, pSrc, pDst, skipsamples, copysamples);
1219 pDst += copysamples;
1222 pSrc += nextFrameOffset;
1226 if (remainingsamples && remainingbytes < WorstCaseFrameSize && pCkData->GetState() ==
RIFF::stream_ready) {
1227 assumedsize =
GuessSize(remainingsamples);
1231 pSrc = (
unsigned char*) pDecompressionBuffer->
pStart;
1235 this->
SamplePos += (SampleCount - remainingsamples);
1237 return (SampleCount - remainingsamples);
1271 if (
GetSize() < SampleCount)
throw Exception(
"Could not write sample data, current sample size to small");
1279 __calculateCRC((
unsigned char *)pBuffer, SampleCount *
FrameSize, crc);
1308 const double worstCaseHeaderOverhead =
1309 (256.0 + 12.0 + 2.0 ) / 256.0;
1310 result.
Size = (
file_offset_t) (
double(MaxReadSize) * 3.0 * 2.0 * worstCaseHeaderOverhead);
1324 if (DecompressionBuffer.
Size && DecompressionBuffer.
pStart) {
1325 delete[] (int8_t*) DecompressionBuffer.
pStart;
1326 DecompressionBuffer.
pStart = NULL;
1327 DecompressionBuffer.
Size = 0;
1360 size_t DimensionRegion::Instances = 0;
1361 DimensionRegion::VelocityTableMap* DimensionRegion::pVelocityTables = NULL;
1372 if (!pVelocityTables) pVelocityTables =
new VelocityTableMap;
1393 uint8_t eg1ctrloptions = _3ewa->
ReadUint8();
1399 uint8_t eg2ctrloptions = _3ewa->
ReadUint8();
1425 uint8_t velocityresponse = _3ewa->
ReadUint8();
1426 if (velocityresponse < 5) {
1429 }
else if (velocityresponse < 10) {
1432 }
else if (velocityresponse < 15) {
1439 uint8_t releasevelocityresponse = _3ewa->
ReadUint8();
1440 if (releasevelocityresponse < 5) {
1443 }
else if (releasevelocityresponse < 10) {
1446 }
else if (releasevelocityresponse < 15) {
1458 uint8_t pitchTrackDimensionBypass = _3ewa->
ReadInt8();
1464 Pan = (pan < 64) ? pan : -((
int)pan - 63);
1476 bool extResonanceCtrl = lfo2ctrl & 0x40;
1484 EG3Depth = (eg3depth <= 1200) ? eg3depth
1485 : (-1) * (int16_t) ((eg3depth ^ 0xfff) + 1);
1488 uint8_t regoptions = _3ewa->
ReadUint8();
1503 uint8_t vcfvelscale = _3ewa->
ReadUint8();
1507 uint8_t vcfresonance = _3ewa->
ReadUint8();
1510 uint8_t vcfbreakpoint = _3ewa->
ReadUint8();
1513 uint8_t vcfvelocity = _3ewa->
ReadUint8();
1518 if (lfo3ctrl & 0x40)
1613 pVelocityReleaseTable = GetReleaseVelocityTable(
1640 for (
int k = 0 ; k < 128 ; k++)
1688 pRegion = pOriginalRegion;
1696 if (mSamples && mSamples->count(orig->
pSample)) {
1703 for (
int k = 0 ; k < 128 ; k++)
1753 const uint32_t chunksize = _3ewa->
GetNewSize();
1754 store32(&pData[0], chunksize);
1757 store32(&pData[4], lfo3freq);
1760 store32(&pData[8], eg3attack);
1779 store32(&pData[28], eg1attack);
1782 store32(&pData[32], eg1decay1);
1789 store32(&pData[40], eg1release);
1791 const uint8_t eg1ctl = (uint8_t) EncodeLeverageController(
EG1Controller);
1794 const uint8_t eg1ctrloptions =
1799 pData[45] = eg1ctrloptions;
1801 const uint8_t eg2ctl = (uint8_t) EncodeLeverageController(
EG2Controller);
1804 const uint8_t eg2ctrloptions =
1809 pData[47] = eg2ctrloptions;
1812 store32(&pData[48], lfo1freq);
1815 store32(&pData[52], eg2attack);
1818 store32(&pData[56], eg2decay1);
1825 store32(&pData[64], eg2release);
1832 store32(&pData[72], lfo2freq);
1839 store32(&pData[80], eg1decay2);
1846 store32(&pData[88], eg2decay2);
1859 velocityresponse += 5;
1862 velocityresponse += 10;
1866 throw Exception(
"Could not update DimensionRegion's chunk, unknown VelocityResponseCurve selected");
1868 pData[96] = velocityresponse;
1878 releasevelocityresponse += 5;
1881 releasevelocityresponse += 10;
1885 throw Exception(
"Could not update DimensionRegion's chunk, unknown ReleaseVelocityResponseCurve selected");
1887 pData[97] = releasevelocityresponse;
1904 pitchTrackDimensionBypass |= 0x10;
1907 pitchTrackDimensionBypass |= 0x20;
1913 throw Exception(
"Could not update DimensionRegion's chunk, unknown DimensionBypass selected");
1915 pData[108] = pitchTrackDimensionBypass;
1918 const uint8_t pan = (
Pan >= 0) ?
Pan : ((-
Pan) + 63);
1921 const uint8_t selfmask = (
SelfMask) ? 0x01 : 0x00;
1922 pData[110] = selfmask;
1931 pData[112] = lfo3ctrl;
1935 pData[113] = attenctl;
1942 pData[114] = lfo2ctrl;
1951 pData[115] = lfo1ctrl;
1955 : uint16_t(((-
EG3Depth) - 1) ^ 0xfff);
1956 store16(&pData[116], eg3depth);
1961 pData[120] = channeloffset;
1964 uint8_t regoptions = 0;
1967 pData[121] = regoptions;
1980 const uint8_t eg1hold = (
EG1Hold) ? 0x80 : 0x00;
1981 pData[131] = eg1hold;
1983 const uint8_t vcfcutoff = (
VCFEnabled ? 0x80 : 0x00) |
1985 pData[132] = vcfcutoff;
1991 pData[134] = vcfvelscale;
1997 pData[136] = vcfresonance;
2001 pData[137] = vcfbreakpoint;
2005 pData[138] = vcfvelocity;
2008 pData[139] = vcftype;
2010 if (chunksize >= 148) {
2015 double* DimensionRegion::GetReleaseVelocityTable(
curve_type_t releaseVelocityResponseCurve, uint8_t releaseVelocityResponseDepth) {
2017 uint8_t depth = releaseVelocityResponseDepth;
2026 return GetVelocityTable(curveType, depth, 0);
2029 double* DimensionRegion::GetCutoffVelocityTable(
curve_type_t vcfVelocityCurve,
2030 uint8_t vcfVelocityDynamicRange,
2031 uint8_t vcfVelocityScale,
2035 uint8_t depth = vcfVelocityDynamicRange;
2044 return GetVelocityTable(curveType, depth,
2046 ? vcfVelocityScale : 0);
2050 double* DimensionRegion::GetVelocityTable(
curve_type_t curveType, uint8_t depth, uint8_t scaling)
2053 uint32_t tableKey = (curveType<<16) | (depth<<8) | scaling;
2054 if (pVelocityTables->count(tableKey)) {
2055 table = (*pVelocityTables)[tableKey];
2058 table = CreateVelocityTable(curveType, depth, scaling);
2059 (*pVelocityTables)[tableKey] = table;
2074 leverage_ctrl_t DimensionRegion::DecodeLeverageController(_lev_ctrl_t EncodedController) {
2076 switch (EncodedController) {
2078 case _lev_ctrl_none:
2082 case _lev_ctrl_velocity:
2086 case _lev_ctrl_channelaftertouch:
2092 case _lev_ctrl_modwheel:
2096 case _lev_ctrl_breath:
2100 case _lev_ctrl_foot:
2104 case _lev_ctrl_effect1:
2108 case _lev_ctrl_effect2:
2112 case _lev_ctrl_genpurpose1:
2116 case _lev_ctrl_genpurpose2:
2120 case _lev_ctrl_genpurpose3:
2124 case _lev_ctrl_genpurpose4:
2128 case _lev_ctrl_portamentotime:
2132 case _lev_ctrl_sustainpedal:
2136 case _lev_ctrl_portamento:
2140 case _lev_ctrl_sostenutopedal:
2144 case _lev_ctrl_softpedal:
2148 case _lev_ctrl_genpurpose5:
2152 case _lev_ctrl_genpurpose6:
2156 case _lev_ctrl_genpurpose7:
2160 case _lev_ctrl_genpurpose8:
2164 case _lev_ctrl_effect1depth:
2168 case _lev_ctrl_effect2depth:
2172 case _lev_ctrl_effect3depth:
2176 case _lev_ctrl_effect4depth:
2180 case _lev_ctrl_effect5depth:
2188 case _lev_ctrl_CC3_EXT:
2192 case _lev_ctrl_CC6_EXT:
2196 case _lev_ctrl_CC7_EXT:
2200 case _lev_ctrl_CC8_EXT:
2204 case _lev_ctrl_CC9_EXT:
2208 case _lev_ctrl_CC10_EXT:
2212 case _lev_ctrl_CC11_EXT:
2216 case _lev_ctrl_CC14_EXT:
2220 case _lev_ctrl_CC15_EXT:
2224 case _lev_ctrl_CC20_EXT:
2228 case _lev_ctrl_CC21_EXT:
2232 case _lev_ctrl_CC22_EXT:
2236 case _lev_ctrl_CC23_EXT:
2240 case _lev_ctrl_CC24_EXT:
2244 case _lev_ctrl_CC25_EXT:
2248 case _lev_ctrl_CC26_EXT:
2252 case _lev_ctrl_CC27_EXT:
2256 case _lev_ctrl_CC28_EXT:
2260 case _lev_ctrl_CC29_EXT:
2264 case _lev_ctrl_CC30_EXT:
2268 case _lev_ctrl_CC31_EXT:
2272 case _lev_ctrl_CC68_EXT:
2276 case _lev_ctrl_CC69_EXT:
2280 case _lev_ctrl_CC70_EXT:
2284 case _lev_ctrl_CC71_EXT:
2288 case _lev_ctrl_CC72_EXT:
2292 case _lev_ctrl_CC73_EXT:
2296 case _lev_ctrl_CC74_EXT:
2300 case _lev_ctrl_CC75_EXT:
2304 case _lev_ctrl_CC76_EXT:
2308 case _lev_ctrl_CC77_EXT:
2312 case _lev_ctrl_CC78_EXT:
2316 case _lev_ctrl_CC79_EXT:
2320 case _lev_ctrl_CC84_EXT:
2324 case _lev_ctrl_CC85_EXT:
2328 case _lev_ctrl_CC86_EXT:
2332 case _lev_ctrl_CC87_EXT:
2336 case _lev_ctrl_CC89_EXT:
2340 case _lev_ctrl_CC90_EXT:
2344 case _lev_ctrl_CC96_EXT:
2348 case _lev_ctrl_CC97_EXT:
2352 case _lev_ctrl_CC102_EXT:
2356 case _lev_ctrl_CC103_EXT:
2360 case _lev_ctrl_CC104_EXT:
2364 case _lev_ctrl_CC105_EXT:
2368 case _lev_ctrl_CC106_EXT:
2372 case _lev_ctrl_CC107_EXT:
2376 case _lev_ctrl_CC108_EXT:
2380 case _lev_ctrl_CC109_EXT:
2384 case _lev_ctrl_CC110_EXT:
2388 case _lev_ctrl_CC111_EXT:
2392 case _lev_ctrl_CC112_EXT:
2396 case _lev_ctrl_CC113_EXT:
2400 case _lev_ctrl_CC114_EXT:
2404 case _lev_ctrl_CC115_EXT:
2408 case _lev_ctrl_CC116_EXT:
2412 case _lev_ctrl_CC117_EXT:
2416 case _lev_ctrl_CC118_EXT:
2420 case _lev_ctrl_CC119_EXT:
2429 return decodedcontroller;
2435 DimensionRegion::_lev_ctrl_t DimensionRegion::EncodeLeverageController(
leverage_ctrl_t DecodedController) {
2436 _lev_ctrl_t encodedcontroller;
2437 switch (DecodedController.
type) {
2440 encodedcontroller = _lev_ctrl_none;
2443 encodedcontroller = _lev_ctrl_velocity;
2446 encodedcontroller = _lev_ctrl_channelaftertouch;
2453 encodedcontroller = _lev_ctrl_modwheel;
2456 encodedcontroller = _lev_ctrl_breath;
2459 encodedcontroller = _lev_ctrl_foot;
2462 encodedcontroller = _lev_ctrl_effect1;
2465 encodedcontroller = _lev_ctrl_effect2;
2468 encodedcontroller = _lev_ctrl_genpurpose1;
2471 encodedcontroller = _lev_ctrl_genpurpose2;
2474 encodedcontroller = _lev_ctrl_genpurpose3;
2477 encodedcontroller = _lev_ctrl_genpurpose4;
2480 encodedcontroller = _lev_ctrl_portamentotime;
2483 encodedcontroller = _lev_ctrl_sustainpedal;
2486 encodedcontroller = _lev_ctrl_portamento;
2489 encodedcontroller = _lev_ctrl_sostenutopedal;
2492 encodedcontroller = _lev_ctrl_softpedal;
2495 encodedcontroller = _lev_ctrl_genpurpose5;
2498 encodedcontroller = _lev_ctrl_genpurpose6;
2501 encodedcontroller = _lev_ctrl_genpurpose7;
2504 encodedcontroller = _lev_ctrl_genpurpose8;
2507 encodedcontroller = _lev_ctrl_effect1depth;
2510 encodedcontroller = _lev_ctrl_effect2depth;
2513 encodedcontroller = _lev_ctrl_effect3depth;
2516 encodedcontroller = _lev_ctrl_effect4depth;
2519 encodedcontroller = _lev_ctrl_effect5depth;
2526 encodedcontroller = _lev_ctrl_CC3_EXT;
2529 encodedcontroller = _lev_ctrl_CC6_EXT;
2532 encodedcontroller = _lev_ctrl_CC7_EXT;
2535 encodedcontroller = _lev_ctrl_CC8_EXT;
2538 encodedcontroller = _lev_ctrl_CC9_EXT;
2541 encodedcontroller = _lev_ctrl_CC10_EXT;
2544 encodedcontroller = _lev_ctrl_CC11_EXT;
2547 encodedcontroller = _lev_ctrl_CC14_EXT;
2550 encodedcontroller = _lev_ctrl_CC15_EXT;
2553 encodedcontroller = _lev_ctrl_CC20_EXT;
2556 encodedcontroller = _lev_ctrl_CC21_EXT;
2559 encodedcontroller = _lev_ctrl_CC22_EXT;
2562 encodedcontroller = _lev_ctrl_CC23_EXT;
2565 encodedcontroller = _lev_ctrl_CC24_EXT;
2568 encodedcontroller = _lev_ctrl_CC25_EXT;
2571 encodedcontroller = _lev_ctrl_CC26_EXT;
2574 encodedcontroller = _lev_ctrl_CC27_EXT;
2577 encodedcontroller = _lev_ctrl_CC28_EXT;
2580 encodedcontroller = _lev_ctrl_CC29_EXT;
2583 encodedcontroller = _lev_ctrl_CC30_EXT;
2586 encodedcontroller = _lev_ctrl_CC31_EXT;
2589 encodedcontroller = _lev_ctrl_CC68_EXT;
2592 encodedcontroller = _lev_ctrl_CC69_EXT;
2595 encodedcontroller = _lev_ctrl_CC70_EXT;
2598 encodedcontroller = _lev_ctrl_CC71_EXT;
2601 encodedcontroller = _lev_ctrl_CC72_EXT;
2604 encodedcontroller = _lev_ctrl_CC73_EXT;
2607 encodedcontroller = _lev_ctrl_CC74_EXT;
2610 encodedcontroller = _lev_ctrl_CC75_EXT;
2613 encodedcontroller = _lev_ctrl_CC76_EXT;
2616 encodedcontroller = _lev_ctrl_CC77_EXT;
2619 encodedcontroller = _lev_ctrl_CC78_EXT;
2622 encodedcontroller = _lev_ctrl_CC79_EXT;
2625 encodedcontroller = _lev_ctrl_CC84_EXT;
2628 encodedcontroller = _lev_ctrl_CC85_EXT;
2631 encodedcontroller = _lev_ctrl_CC86_EXT;
2634 encodedcontroller = _lev_ctrl_CC87_EXT;
2637 encodedcontroller = _lev_ctrl_CC89_EXT;
2640 encodedcontroller = _lev_ctrl_CC90_EXT;
2643 encodedcontroller = _lev_ctrl_CC96_EXT;
2646 encodedcontroller = _lev_ctrl_CC97_EXT;
2649 encodedcontroller = _lev_ctrl_CC102_EXT;
2652 encodedcontroller = _lev_ctrl_CC103_EXT;
2655 encodedcontroller = _lev_ctrl_CC104_EXT;
2658 encodedcontroller = _lev_ctrl_CC105_EXT;
2661 encodedcontroller = _lev_ctrl_CC106_EXT;
2664 encodedcontroller = _lev_ctrl_CC107_EXT;
2667 encodedcontroller = _lev_ctrl_CC108_EXT;
2670 encodedcontroller = _lev_ctrl_CC109_EXT;
2673 encodedcontroller = _lev_ctrl_CC110_EXT;
2676 encodedcontroller = _lev_ctrl_CC111_EXT;
2679 encodedcontroller = _lev_ctrl_CC112_EXT;
2682 encodedcontroller = _lev_ctrl_CC113_EXT;
2685 encodedcontroller = _lev_ctrl_CC114_EXT;
2688 encodedcontroller = _lev_ctrl_CC115_EXT;
2691 encodedcontroller = _lev_ctrl_CC116_EXT;
2694 encodedcontroller = _lev_ctrl_CC117_EXT;
2697 encodedcontroller = _lev_ctrl_CC118_EXT;
2700 encodedcontroller = _lev_ctrl_CC119_EXT;
2704 throw gig::Exception(
"leverage controller number is not supported by the gig format");
2710 return encodedcontroller;
2717 VelocityTableMap::iterator iter;
2718 for (iter = pVelocityTables->begin(); iter != pVelocityTables->end(); iter++) {
2719 double* pTable = iter->second;
2720 if (pTable)
delete[] pTable;
2722 pVelocityTables->clear();
2723 delete pVelocityTables;
2724 pVelocityTables = NULL;
2741 return pVelocityAttenuationTable[MIDIKeyVelocity];
2745 return pVelocityReleaseTable[MIDIKeyVelocity];
2749 return pVelocityCutoffTable[MIDIKeyVelocity];
2757 pVelocityAttenuationTable =
2769 pVelocityAttenuationTable =
2781 pVelocityAttenuationTable =
2842 double* DimensionRegion::CreateVelocityTable(
curve_type_t curveType, uint8_t depth, uint8_t scaling) {
2847 const int lin0[] = { 1, 1, 127, 127 };
2848 const int lin1[] = { 1, 21, 127, 127 };
2849 const int lin2[] = { 1, 45, 127, 127 };
2850 const int lin3[] = { 1, 74, 127, 127 };
2851 const int lin4[] = { 1, 127, 127, 127 };
2854 const int non0[] = { 1, 4, 24, 5, 57, 17, 92, 57, 122, 127, 127, 127 };
2855 const int non1[] = { 1, 4, 46, 9, 93, 56, 118, 106, 123, 127,
2857 const int non2[] = { 1, 4, 46, 9, 57, 20, 102, 107, 107, 127,
2859 const int non3[] = { 1, 15, 10, 19, 67, 73, 80, 80, 90, 98, 98, 127,
2861 const int non4[] = { 1, 25, 33, 57, 82, 81, 92, 127, 127, 127 };
2864 const int spe0[] = { 1, 2, 76, 10, 90, 15, 95, 20, 99, 28, 103, 44,
2865 113, 127, 127, 127 };
2866 const int spe1[] = { 1, 2, 27, 5, 67, 18, 89, 29, 95, 35, 107, 67,
2867 118, 127, 127, 127 };
2868 const int spe2[] = { 1, 1, 33, 1, 53, 5, 61, 13, 69, 32, 79, 74,
2869 85, 90, 91, 127, 127, 127 };
2870 const int spe3[] = { 1, 32, 28, 35, 66, 48, 89, 59, 95, 65, 99, 73,
2871 117, 127, 127, 127 };
2872 const int spe4[] = { 1, 4, 23, 5, 49, 13, 57, 17, 92, 57, 122, 127,
2876 const int spe5[] = { 1, 2, 30, 5, 60, 19, 77, 70, 83, 85, 88, 106,
2877 91, 127, 127, 127 };
2879 const int*
const curves[] = { non0, non1, non2, non3, non4,
2880 lin0, lin1, lin2, lin3, lin4,
2881 spe0, spe1, spe2, spe3, spe4, spe5 };
2883 double*
const table =
new double[128];
2885 const int* curve = curves[curveType * 5 + depth];
2886 const int s = scaling == 0 ? 20 : scaling;
2889 for (
int x = 1 ; x < 128 ; x++) {
2891 if (x > curve[2]) curve += 2;
2892 double y = curve[1] + (x - curve[0]) *
2893 (
double(curve[3] - curve[1]) / (curve[2] - curve[0]));
2898 if (s < 20 && y >= 0.5)
2899 y = y / ((2 - 40.0 / s) * y + 40.0 / s - 1);
2916 for (
int i = 0; i < 256; i++) {
2932 for (
int i = 0; i < dimensionBits; i++) {
2973 uint32_t wavepoolindex = _3lnk->
ReadUint32();
2980 for (
int i = 0 ; i < 8 ; i++) {
3024 const int iMaxDimensions = version3 ? 8 : 5;
3025 const int iMaxDimensionRegions = version3 ? 256 : 32;
3030 const int _3lnkChunkSize = version3 ? 1092 : 172;
3040 store32(&pData[0], DimensionRegions);
3042 for (
int i = 0; i < iMaxDimensions; i++) {
3054 const int iWavePoolOffset = version3 ? 68 : 44;
3055 for (uint i = 0; i < iMaxDimensionRegions; i++) {
3056 int iWaveIndex = -1;
3057 if (i < DimensionRegions) {
3059 File::SampleList::iterator iter = pFile->
pSamples->begin();
3060 File::SampleList::iterator end = pFile->
pSamples->end();
3061 for (
int index = 0; iter != end; ++iter, ++index) {
3068 store32(&pData[iWavePoolOffset + i * 4], iWaveIndex);
3075 int dimensionRegionNr = 0;
3080 dimensionRegionNr++;
3084 if (dimensionRegionNr == 0)
throw gig::Exception(
"No dimension region found.");
3104 if (veldim == -1)
return;
3121 table =
new uint8_t[128];
3125 int velocityZone = 0;
3127 for (
int k = i ; k < end ; k += step) {
3129 for (; tableidx <= d->
DimensionUpperLimits[veldim] ; tableidx++) table[tableidx] = velocityZone;
3133 for (
int k = i ; k < end ; k += step) {
3135 for (; tableidx <= d->
VelocityUpperLimit ; tableidx++) table[tableidx] = velocityZone;
3150 if (j == veldim) i += skipveldim;
3163 if (j == Dimensions)
break;
3184 if (pDimDef->
zones < 2)
3185 throw gig::Exception(
"Could not add new dimension, amount of requested zones must always be at least two");
3186 if (pDimDef->
bits < 1)
3187 throw gig::Exception(
"Could not add new dimension, amount of requested requested zone bits must always be at least one");
3189 if (pDimDef->
zones != 2)
3190 throw gig::Exception(
"Could not add new 'sample channel' dimensions, the requested amount of zones must always be 2 for this dimension type");
3191 if (pDimDef->
bits != 1)
3192 throw gig::Exception(
"Could not add new 'sample channel' dimensions, the requested amount of zone bits must always be 1 for this dimension type");
3199 throw gig::Exception(
"Could not add new dimension, max. amount of " + ToString(iMaxDimensions) +
" dimensions already reached");
3201 int iCurrentBits = 0;
3204 if (iCurrentBits >= iMaxDimensions)
3205 throw gig::Exception(
"Could not add new dimension, max. amount of " + ToString(iMaxDimensions) +
" dimension bits already reached");
3206 const int iNewBits = iCurrentBits + pDimDef->
bits;
3207 if (iNewBits > iMaxDimensions)
3208 throw gig::Exception(
"Could not add new dimension, new dimension would exceed max. amount of " + ToString(iMaxDimensions) +
" dimension bits");
3212 throw gig::Exception(
"Could not add new dimension, there is already a dimension of the same type");
3219 for (
int i = 0 ; i < pos ; i++)
3224 for (
int i = 0 ; i < (1 << iCurrentBits) ; i++) {
3225 for (
int j = Dimensions ; j > pos ; j--) {
3245 for (
int i = (1 << iCurrentBits) - (1 << bitpos) ; i >= 0 ; i -= (1 << bitpos)) {
3246 for (
int k = 0 ; k < (1 << bitpos) ; k++) {
3249 for (
int j = 1 ; j < (1 << pDimDef->
bits) ; j++) {
3250 for (
int k = 0 ; k < (1 << bitpos) ; k++) {
3252 if (moveTo) _3prg->
MoveSubChunk(pNewDimRgnListChunk, moveTo);
3265 int mask = (1 << bitpos) - 1;
3266 for (
int z = 0 ; z < pDimDef->
zones ; z++) {
3267 uint8_t upperLimit = uint8_t((z + 1) * 128.0 / pDimDef->
zones - 1);
3268 for (
int i = 0 ; i < 1 << iCurrentBits ; i++) {
3296 int iDimensionNr = -1;
3303 if (iDimensionNr < 0)
throw gig::Exception(
"Invalid dimension_def_t pointer");
3307 for (
int i = 0; i < iDimensionNr; i++)
3312 for (
int i = iDimensionNr + 1; i <
Dimensions; i++)
3319 for (
int iUpperBit = 0; iUpperBit < 1 << iUpperBits; iUpperBit++) {
3321 for (
int iLowerBit = 0; iLowerBit < 1 << iLowerBits; iLowerBit++) {
3323 iObsoleteBit << iLowerBits |
3336 for (
int iFrom = 2, iTo = 1; iFrom < 256 && iTo < 256 - 1; iTo++) {
3338 if (iFrom <= iTo) iFrom = iTo + 1;
3350 for (
int i = iDimensionNr + 1; i <
Dimensions; i++) {
3357 for (
int i = iDimensionNr + 1; i <
Dimensions; i++) {
3387 throw gig::Exception(
"Could not delete dimension zone, no such dimension of given type");
3388 if (oldDef->
zones <= 2)
3389 throw gig::Exception(
"Could not delete dimension zone, because it would end up with only one zone.");
3390 if (zone < 0 || zone >= oldDef->
zones)
3391 throw gig::Exception(
"Could not delete dimension zone, requested zone index out of bounds.");
3393 const int newZoneSize = oldDef->
zones - 1;
3406 tempRgn =
new Region(instr, rgn);
3418 def.
zones = newZoneSize;
3427 int tempReducedDimensionIndex = -1;
3428 for (
int d = 0; d < tempRgn->
Dimensions; ++d) {
3430 tempReducedDimensionIndex = d;
3436 for (
int iDst = 0; iDst < 256; ++iDst) {
3438 if (!dstDimRgn)
continue;
3439 std::map<dimension_t,int> dimCase;
3440 bool isValidZone =
true;
3441 for (
int d = 0, baseBits = 0; d < tempRgn->
Dimensions; ++d) {
3444 (iDst >> baseBits) & ((1 << dstBits) - 1);
3445 baseBits += dstBits;
3448 isValidZone =
false;
3452 if (!isValidZone)
continue;
3455 const bool isLastZone = (dimCase[type] == newZoneSize - 1);
3456 if (dimCase[type] >= zone) dimCase[type]++;
3471 for (
int iSrc = 0; iSrc < 256; ++iSrc) {
3473 if (!srcDimRgn)
continue;
3474 std::map<dimension_t,int> dimCase;
3475 for (
int d = 0, baseBits = 0; d < tempRgn->
Dimensions; ++d) {
3478 (iSrc >> baseBits) & ((1 << srcBits) - 1);
3479 baseBits += srcBits;
3484 if (!dstDimRgn)
continue;
3511 throw gig::Exception(
"Could not split dimension zone, no such dimension of given type");
3512 if (zone < 0 || zone >= oldDef->
zones)
3513 throw gig::Exception(
"Could not split dimension zone, requested zone index out of bounds.");
3515 const int newZoneSize = oldDef->
zones + 1;
3528 tempRgn =
new Region(instr, rgn);
3540 def.
zones = newZoneSize;
3541 if ((1 << oldDef->
bits) < newZoneSize) def.
bits++;
3549 int tempIncreasedDimensionIndex = -1;
3550 for (
int d = 0; d < tempRgn->
Dimensions; ++d) {
3552 tempIncreasedDimensionIndex = d;
3558 for (
int iSrc = 0; iSrc < 256; ++iSrc) {
3560 if (!srcDimRgn)
continue;
3561 std::map<dimension_t,int> dimCase;
3562 bool isValidZone =
true;
3563 for (
int d = 0, baseBits = 0; d <
Dimensions; ++d) {
3566 (iSrc >> baseBits) & ((1 << srcBits) - 1);
3568 if (dimCase[pDimensionDefinitions[d].dimension] >= pDimensionDefinitions[d].zones) {
3569 isValidZone =
false;
3572 baseBits += srcBits;
3574 if (!isValidZone)
continue;
3577 if (dimCase[type] > zone) dimCase[type]++;
3583 if (dimCase[type] == zone) {
3590 std::map<dimension_t,int> lowerCase = dimCase;
3610 for (
int iSrc = 0; iSrc < 256; ++iSrc) {
3612 if (!srcDimRgn)
continue;
3613 std::map<dimension_t,int> dimCase;
3614 for (
int d = 0, baseBits = 0; d < tempRgn->
Dimensions; ++d) {
3617 (iSrc >> baseBits) & ((1 << srcBits) - 1);
3618 baseBits += srcBits;
3623 if (!dstDimRgn)
continue;
3648 if (oldType == newType)
return;
3651 throw gig::Exception(
"No dimension with provided old dimension type exists on this region");
3653 throw gig::Exception(
"Cannot change to dimension type 'sample channel', because existing dimension does not have 2 zones");
3655 throw gig::Exception(
"There is already a dimension with requested new dimension type on this region");
3657 def->
split_type = __resolveSplitType(newType);
3661 uint8_t bits[8] = {};
3662 for (std::map<dimension_t,int>::const_iterator it = DimCase.begin();
3663 it != DimCase.end(); ++it)
3667 bits[d] = it->second;
3668 goto nextDimCaseSlice;
3695 for (
int i = 0; i < 256; i++) {
3735 if (DimValues[i] <=
pDimensionRegions[bits << bitpos]->DimensionUpperLimits[i])
break;
3744 bits = DimValues[i] & limiter_mask;
3747 dimregidx |= bits << bitpos;
3752 if (!dimreg)
return NULL;
3761 dimregidx |= (bits & limiter_mask) << velbitpos;
3784 if (DimValues[i] <=
pDimensionRegions[bits << bitpos]->DimensionUpperLimits[i])
break;
3793 bits = DimValues[i] & limiter_mask;
3796 dimregidx |= bits << bitpos;
3802 if (!dimreg)
return -1;
3811 dimregidx |= (bits & limiter_mask) << velbitpos;
3852 if ((int32_t)WavePoolTableIndex == -1)
return NULL;
3858 uint64_t soughtoffset =
3920 for (
int i = 0; i < 256; i++) {
3941 for (
int i = 0 ; i < Triggers ; i++) {
3942 pTriggers[i].TriggerPoint = _3ewg->
ReadUint8();
3943 pTriggers[i].Descending = _3ewg->
ReadUint8();
3944 pTriggers[i].VelSensitivity = _3ewg->
ReadUint8();
3946 pTriggers[i].NoteOff = _3ewg->
ReadUint8();
3947 pTriggers[i].Velocity = _3ewg->
ReadUint8();
3948 pTriggers[i].OverridePedal = _3ewg->
ReadUint8();
3954 ControllerNumber(0),
3963 for (
int i = 0 ; i <
Triggers ; i++) {
3978 BypassUseController = _3ewg->
ReadUint8();
3995 BypassUseController(false),
3997 BypassController(1),
4000 ReleaseTriggerKey(0),
4027 Polyphonic = flags & 8;
4028 Chained = flags & 4;
4029 Selector = (flags & 2) ? selector_controller :
4030 (flags & 1) ? selector_key_switch : selector_none;
4036 KeySwitchRange.low = _3ewg->
ReadUint8();
4037 KeySwitchRange.high = _3ewg->
ReadUint8();
4042 int n = std::min(
int(Articulations), 32);
4043 for (
int i = 0 ; i < n ; i++) {
4047 n = std::min(
int(Patterns), 32);
4048 for (
int i = 0 ; i < n ; i++) {
4051 _3ewg->
Read(&pPatterns[i][0], 1, 32);
4058 Selector(selector_none),
4082 char* str =
reinterpret_cast<char*
>(pData);
4085 for (
int i = 0 ; i < n ; i++, pos += 32) {
4091 for (
int i = 0 ; i < n ; i++, pos += 49) {
4092 strncpy(&str[pos],
pPatterns[i].Name.c_str(), 16);
4094 memcpy(&pData[pos + 16], &(
pPatterns[i][0]), 32);
4113 Name.resize(nameSize,
' ');
4114 for (
int i = 0; i < nameSize; ++i)
4117 ckScri->
SetPos(
sizeof(int32_t) + headerSize);
4120 data.resize(scriptSize);
4121 for (
int i = 0; i < scriptSize; ++i)
4124 Compression = COMPRESSION_NONE;
4125 Encoding = ENCODING_ASCII;
4126 Language = LANGUAGE_NKSP;
4129 Name =
"Unnamed Script";
4141 s.resize(data.size(),
' ');
4142 memcpy(&s[0], &data[0], data.size());
4153 data.resize(text.size());
4154 memcpy(&data[0], &text[0], text.size());
4169 __calculateCRC(&data[0], data.size(), crc);
4172 const int chunkSize = 7*
sizeof(int32_t) + Name.size() + data.size();
4173 if (!pChunk) pChunk = pGroup->pList->AddSubChunk(
CHUNK_ID_SCRI, chunkSize);
4174 else pChunk->Resize(chunkSize);
4176 uint8_t* pData = (uint8_t*) pChunk->LoadChunkData();
4178 store32(&pData[pos], 6*
sizeof(int32_t) + Name.size());
4179 pos +=
sizeof(int32_t);
4180 store32(&pData[pos], Compression);
4181 pos +=
sizeof(int32_t);
4182 store32(&pData[pos], Encoding);
4183 pos +=
sizeof(int32_t);
4184 store32(&pData[pos], Language);
4185 pos +=
sizeof(int32_t);
4186 store32(&pData[pos], Bypass ? 1 : 0);
4187 pos +=
sizeof(int32_t);
4188 store32(&pData[pos], crc);
4189 pos +=
sizeof(int32_t);
4190 store32(&pData[pos], Name.size());
4191 pos +=
sizeof(int32_t);
4192 for (
int i = 0; i < Name.size(); ++i, ++pos)
4193 pData[pos] = Name[i];
4194 for (
int i = 0; i < data.size(); ++i, ++pos)
4195 pData[pos] = data[i];
4205 if (this->pGroup == pGroup)
return;
4207 pChunk->GetParent()->MoveSubChunk(pChunk, pGroup->pList);
4208 this->pGroup = pGroup;
4222 File* pFile = pGroup->pFile;
4240 Name =
"Default Group";
4246 std::list<Script*>::iterator iter = pScripts->begin();
4247 std::list<Script*>::iterator end = pScripts->end();
4248 while (iter != end) {
4273 for (std::list<Script*>::iterator it = pScripts->begin();
4274 it != pScripts->end(); ++it)
4276 (*it)->UpdateChunks(pProgress);
4289 if (!pScripts) LoadScripts();
4290 std::list<Script*>::iterator it = pScripts->begin();
4291 for (uint i = 0; it != pScripts->end(); ++i, ++it)
4292 if (i == index)
return *it;
4308 if (!pScripts) LoadScripts();
4310 pScripts->push_back(pScript);
4325 if (!pScripts) LoadScripts();
4326 std::list<Script*>::iterator iter =
4327 find(pScripts->begin(), pScripts->end(), pScript);
4328 if (iter == pScripts->end())
4329 throw gig::Exception(
"Could not delete script, could not find given script");
4330 pScripts->erase(iter);
4332 if (pScript->pChunk)
4338 if (pScripts)
return;
4339 pScripts =
new std::list<Script*>;
4342 for (
RIFF::Chunk* ck = pList->GetFirstSubChunk(); ck;
4343 ck = pList->GetNextSubChunk())
4346 pScripts->push_back(
new Script(
this, ck));
4372 pMidiRules[0] = NULL;
4384 uint8_t dimkeystart = _3ewg->
ReadUint8();
4399 }
else if (id1 == 0) {
4401 }
else if (id1 == 3) {
4407 else if (id1 != 0 || id2 != 0) {
4412 pMidiRules[i] = NULL;
4424 __notify_progress(pProgress, (
float)
pRegions->size() / (float)
Regions);
4443 ckSCSL->
SetPos(headerSize);
4444 int unknownSpace = slotSize - 2*
sizeof(uint32_t);
4445 for (
int i = 0; i < slotCount; ++i) {
4446 _ScriptPooolEntry e;
4450 scriptPoolFileOffsets.push_back(e);
4456 __notify_progress(pProgress, 1.0f);
4461 RegionList::iterator iter =
pRegions->begin();
4462 RegionList::iterator end =
pRegions->end();
4463 for (; iter != end; ++iter) {
4465 for (
int iKey = pRegion->
KeyRange.
low; iKey <= pRegion->KeyRange.high; iKey++) {
4472 for (
int i = 0 ; pMidiRules[i] ; i++) {
4473 delete pMidiRules[i];
4475 delete[] pMidiRules;
4476 if (pScriptRefs)
delete pScriptRefs;
4495 RegionList::iterator iter =
pRegions->begin();
4496 RegionList::iterator end =
pRegions->end();
4497 for (; iter != end; ++iter)
4498 (*iter)->UpdateChunks(pProgress);
4522 pData[10] = dimkeystart;
4525 if (pMidiRules[0] == 0 && _3ewg->
GetSize() >= 34) {
4529 for (
int i = 0 ; pMidiRules[i] ; i++) {
4542 const int slotCount = pScriptRefs->size();
4543 const int headerSize = 3 *
sizeof(uint32_t);
4544 const int slotSize = 2 *
sizeof(uint32_t);
4545 const int totalChunkSize = headerSize + slotCount * slotSize;
4548 else ckSCSL->
Resize(totalChunkSize);
4551 store32(&pData[pos], headerSize);
4552 pos +=
sizeof(uint32_t);
4553 store32(&pData[pos], slotCount);
4554 pos +=
sizeof(uint32_t);
4555 store32(&pData[pos], slotSize);
4556 pos +=
sizeof(uint32_t);
4557 for (
int i = 0; i < slotCount; ++i) {
4560 int bogusFileOffset = 0;
4561 store32(&pData[pos], bogusFileOffset);
4562 pos +=
sizeof(uint32_t);
4563 store32(&pData[pos], (*pScriptRefs)[i].bypass ? 1 : 0);
4564 pos +=
sizeof(uint32_t);
4575 if (pScriptRefs && pScriptRefs->size() > 0) {
4578 const int slotCount = pScriptRefs->size();
4579 const int headerSize = 3 *
sizeof(uint32_t);
4580 ckSCSL->
SetPos(headerSize);
4581 for (
int i = 0; i < slotCount; ++i) {
4582 uint32_t fileOffset =
4583 (*pScriptRefs)[i].script->pChunk->GetFilePos() -
4584 (*pScriptRefs)[i].script->pChunk->GetPos() -
4689 "gig::Instrument::MoveTo() can only be used for moving within " 4690 "the same gig file." 4699 File::InstrumentList::iterator itFrom =
4700 std::find(list.begin(), list.end(),
static_cast<DLS::Instrument*
>(
this));
4702 File::InstrumentList::iterator itTo =
4703 std::find(list.begin(), list.end(),
static_cast<DLS::Instrument*
>(dst));
4705 list.splice(itTo, list, itFrom);
4727 return pMidiRules[i];
4736 delete pMidiRules[0];
4749 delete pMidiRules[0];
4762 delete pMidiRules[0];
4775 delete pMidiRules[i];
4780 if (pScriptRefs)
return;
4781 pScriptRefs =
new std::vector<_ScriptPooolRef>;
4782 if (scriptPoolFileOffsets.empty())
return;
4784 for (uint k = 0; k < scriptPoolFileOffsets.size(); ++k) {
4785 uint32_t soughtOffset = scriptPoolFileOffsets[k].fileOffset;
4788 for (uint s = 0; group->
GetScript(s); ++s) {
4790 if (script->pChunk) {
4791 uint32_t offset = script->pChunk->
GetFilePos() -
4792 script->pChunk->
GetPos() -
4794 if (offset == soughtOffset)
4796 _ScriptPooolRef ref;
4797 ref.script = script;
4798 ref.bypass = scriptPoolFileOffsets[k].bypass;
4799 pScriptRefs->push_back(ref);
4807 scriptPoolFileOffsets.clear();
4824 if (index >= pScriptRefs->size())
return NULL;
4825 return pScriptRefs->at(index).script;
4865 _ScriptPooolRef ref = { pScript, bypass };
4866 pScriptRefs->push_back(ref);
4885 if (index1 >= pScriptRefs->size() || index2 >= pScriptRefs->size())
4887 _ScriptPooolRef tmp = (*pScriptRefs)[index1];
4888 (*pScriptRefs)[index1] = (*pScriptRefs)[index2];
4889 (*pScriptRefs)[index2] = tmp;
4900 if (index >= pScriptRefs->size())
return;
4901 pScriptRefs->erase( pScriptRefs->begin() + index );
4918 for (
int i = pScriptRefs->size() - 1; i >= 0; --i) {
4919 if ((*pScriptRefs)[i].script == pScript) {
4920 pScriptRefs->erase( pScriptRefs->begin() + i );
4940 return pScriptRefs ? pScriptRefs->size() : scriptPoolFileOffsets.size();
4961 return pScriptRefs ? pScriptRefs->at(index).bypass
4962 : scriptPoolFileOffsets.at(index).bypass;
4982 pScriptRefs->at(index).bypass = bBypass;
4984 scriptPoolFileOffsets.at(index).bypass = bBypass;
5020 scriptPoolFileOffsets = orig->scriptPoolFileOffsets;
5021 pScriptRefs = orig->pScriptRefs;
5024 for (
int i = 0 ; pMidiRules[i] ; i++) {
5025 delete pMidiRules[i];
5028 pMidiRules[0] = NULL;
5034 RegionList::const_iterator it = orig->
pRegions->begin();
5035 for (
int i = 0; i < orig->
Regions; ++i, ++it) {
5039 static_cast<gig::Region*>(*it),
5060 pNameChunk = ck3gnm;
5066 if (pNameChunk) pNameChunk->GetParent()->DeleteSubChunk(pNameChunk);
5089 if (!pNameChunk && pFile->pVersion && pFile->pVersion->major == 3) {
5092 if (strcmp(static_cast<char*>(ck->LoadChunkData()),
"") == 0) {
5116 for (
Sample* pSample = pFile->GetFirstSample(); pSample; pSample = pFile->GetNextSample()) {
5117 if (pSample->GetGroup() ==
this)
return pSample;
5134 for (
Sample* pSample = pFile->GetNextSample(); pSample; pSample = pFile->GetNextSample()) {
5135 if (pSample->GetGroup() ==
this)
return pSample;
5155 Group* pOtherGroup = NULL;
5156 for (pOtherGroup = pFile->GetFirstGroup(); pOtherGroup; pOtherGroup = pFile->GetNextGroup()) {
5157 if (pOtherGroup !=
this)
break;
5160 "Could not move samples to another group, since there is no " 5161 "other Group. This is a bug, report it!" 5164 for (
Sample* pSample = GetFirstSample(); pSample; pSample = GetNextSample()) {
5176 0, 2, 19980628 & 0xffff, 19980628 >> 16
5181 0, 3, 20030331 & 0xffff, 20030331 >> 16
5209 pScriptGroups = NULL;
5225 pScriptGroups = NULL;
5231 std::list<Group*>::iterator iter = pGroups->begin();
5232 std::list<Group*>::iterator end = pGroups->end();
5233 while (iter != end) {
5239 if (pScriptGroups) {
5240 std::list<ScriptGroup*>::iterator iter = pScriptGroups->begin();
5241 std::list<ScriptGroup*>::iterator end = pScriptGroups->end();
5242 while (iter != end) {
5246 delete pScriptGroups;
5271 DLS::File::SampleList::iterator it =
pSamples->begin();
5272 for (
int i = 0; i < index; ++i) {
5274 if (it ==
pSamples->end())
return NULL;
5276 if (it ==
pSamples->end())
return NULL;
5315 if (iter ==
pSamples->end())
throw gig::Exception(
"Could not delete sample, could not find given sample");
5324 for (
Region* region = instrument->GetFirstRegion() ; region ;
5325 region = instrument->GetNextRegion()) {
5327 if (region->GetSample() == pSample) region->SetSample(NULL);
5329 for (
int i = 0 ; i < region->DimensionRegions ; i++) {
5352 int iSampleIndex = 0;
5364 int nameLen = name.length();
5366 if (nameLen > 4 && name.substr(nameLen - 4) ==
".gig") nameLen -= 4;
5368 for (
int fileNo = 0 ; ; ) {
5376 const float subprogress = (float) iSampleIndex / (
float) iTotalSamples;
5377 __notify_progress(pProgress, subprogress);
5380 pSamples->push_back(
new Sample(
this, wave, waveFileOffset - wvplFileOffset, fileNo));
5387 if (fileNo == lastFileNo)
break;
5391 sprintf(suffix,
".gx%02d", fileNo);
5392 name.replace(nameLen, 5, suffix);
5398 __notify_progress(pProgress, 1.0);
5427 __divide_progress(pProgress, &subprogress, 3.0f, 0.0f);
5428 __notify_progress(&subprogress, 0.0f);
5431 __notify_progress(&subprogress, 1.0f);
5434 if (pProgress && pProgress->
callback) {
5438 __notify_progress(&subprogress, 0.0f);
5440 __notify_progress(&subprogress, 1.0f);
5445 if (i == index)
return static_cast<gig::Instrument*
>( *InstrumentsIterator );
5513 static int iCallCount = -1;
5515 std::map<Group*,Group*> mGroups;
5516 std::map<Sample*,Sample*> mSamples;
5519 for (
int i = 0; pFile->
GetGroup(i); ++i) {
5522 "COPY" + ToString(iCallCount) +
"_" + pFile->
GetGroup(i)->
Name;
5527 for (
int i = 0; pFile->
GetSample(i); ++i) {
5559 for (
int i = 0; pFile->
GetSample(i); ++i) {
5587 if (lstInstruments) {
5588 int iInstrumentIndex = 0;
5593 const float localProgress = (float) iInstrumentIndex / (
float)
Instruments;
5594 __notify_progress(pProgress, localProgress);
5598 __divide_progress(pProgress, &subprogress,
Instruments, iInstrumentIndex);
5606 __notify_progress(pProgress, 1.0);
5618 int iWaveIndex = -1;
5619 File::SampleList::iterator iter =
pSamples->begin();
5620 File::SampleList::iterator end =
pSamples->end();
5621 for (
int index = 0; iter != end; ++iter, ++index) {
5622 if (*iter == pSample) {
5627 if (iWaveIndex < 0)
throw gig::Exception(
"Could not update crc, could not find sample");
5630 _3crc->
SetPos(iWaveIndex * 8);
5639 GroupsIterator = pGroups->begin();
5640 return *GroupsIterator;
5644 if (!pGroups)
return NULL;
5646 return (GroupsIterator == pGroups->end()) ? NULL : *GroupsIterator;
5657 GroupsIterator = pGroups->begin();
5658 for (uint i = 0; GroupsIterator != pGroups->end(); i++) {
5659 if (i == index)
return *GroupsIterator;
5677 GroupsIterator = pGroups->begin();
5678 for (uint i = 0; GroupsIterator != pGroups->end(); ++GroupsIterator, ++i)
5679 if ((*GroupsIterator)->Name == name)
return *GroupsIterator;
5688 pGroups->push_back(pGroup);
5703 std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);
5704 if (iter == pGroups->end())
throw gig::Exception(
"Could not delete group, could not find given group");
5705 if (pGroups->size() == 1)
throw gig::Exception(
"Cannot delete group, there must be at least one default group!");
5711 pGroups->erase(iter);
5727 std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);
5728 if (iter == pGroups->end())
throw gig::Exception(
"Could not delete group, could not find given group");
5729 if (pGroups->size() == 1)
throw gig::Exception(
"Cannot delete group, there must be at least one default group!");
5732 pGroups->erase(iter);
5737 if (!pGroups) pGroups =
new std::list<Group*>;
5747 strcmp(static_cast<char*>(ck->
LoadChunkData()),
"") == 0)
break;
5749 pGroups->push_back(
new Group(
this, ck));
5756 if (!pGroups->size()) {
5758 pGroup->
Name =
"Default Group";
5759 pGroups->push_back(pGroup);
5772 std::list<ScriptGroup*>::iterator it = pScriptGroups->begin();
5773 for (uint i = 0; it != pScriptGroups->end(); ++i, ++it)
5774 if (i == index)
return *it;
5788 std::list<ScriptGroup*>::iterator it = pScriptGroups->begin();
5789 for (uint i = 0; it != pScriptGroups->end(); ++i, ++it)
5790 if ((*it)->Name == name)
return *it;
5805 pScriptGroups->push_back(pScriptGroup);
5806 return pScriptGroup;
5823 std::list<ScriptGroup*>::iterator iter =
5824 find(pScriptGroups->begin(), pScriptGroups->end(), pScriptGroup);
5825 if (iter == pScriptGroups->end())
5826 throw gig::Exception(
"Could not delete script group, could not find given script group");
5827 pScriptGroups->erase(iter);
5828 for (
int i = 0; pScriptGroup->
GetScript(i); ++i)
5830 if (pScriptGroup->pList)
5832 delete pScriptGroup;
5836 if (pScriptGroups)
return;
5837 pScriptGroups =
new std::list<ScriptGroup*>;
5844 pScriptGroups->push_back(
new ScriptGroup(
this, lst));
5879 if (pScriptGroups) {
5881 for (std::list<ScriptGroup*>::iterator it = pScriptGroups->begin();
5882 it != pScriptGroups->end(); ++it)
5884 (*it)->UpdateChunks(pProgress);
5903 if (first != info) {
5924 for (
int i = 0 ; i < 128 ; i++) {
5925 if (i >= pGroups->size()) ::SaveString(
CHUNK_ID_3GNM, _3gnm, _3gnl,
"",
"",
true, 64);
5930 std::list<Group*>::iterator iter = pGroups->begin();
5931 std::list<Group*>::iterator end = pGroups->end();
5932 for (; iter != end; ++iter) {
5933 (*iter)->UpdateChunks(pProgress);
5953 int sublen =
pSamples->size() / 8 + 49;
5958 if (einf->
GetSize() != einfSize) {
5962 }
else if (newFile) {
5968 std::map<gig::Sample*,int> sampleMap;
5971 sampleMap[pSample] = sampleIdx++;
5974 int totnbusedsamples = 0;
5975 int totnbusedchannels = 0;
5976 int totnbregions = 0;
5977 int totnbdimregions = 0;
5979 int instrumentIdx = 0;
5981 memset(&pData[48], 0, sublen - 48);
5985 int nbusedsamples = 0;
5986 int nbusedchannels = 0;
5987 int nbdimregions = 0;
5990 memset(&pData[(instrumentIdx + 1) * sublen + 48], 0, sublen - 48);
5992 for (
Region* region = instrument->GetFirstRegion() ; region ;
5993 region = instrument->GetNextRegion()) {
5994 for (
int i = 0 ; i < region->DimensionRegions ; i++) {
5997 int sampleIdx = sampleMap[d->
pSample];
5998 int byte = 48 + sampleIdx / 8;
5999 int bit = 1 << (sampleIdx & 7);
6000 if ((pData[(instrumentIdx + 1) * sublen + byte] & bit) == 0) {
6001 pData[(instrumentIdx + 1) * sublen + byte] |= bit;
6005 if ((pData[byte] & bit) == 0) {
6014 nbdimregions += region->DimensionRegions;
6018 store32(&pData[(instrumentIdx + 1) * sublen + 4], nbusedchannels);
6019 store32(&pData[(instrumentIdx + 1) * sublen + 8], nbusedsamples);
6020 store32(&pData[(instrumentIdx + 1) * sublen + 12], 1);
6021 store32(&pData[(instrumentIdx + 1) * sublen + 16], instrument->Regions);
6022 store32(&pData[(instrumentIdx + 1) * sublen + 20], nbdimregions);
6023 store32(&pData[(instrumentIdx + 1) * sublen + 24], nbloops);
6025 store32(&pData[(instrumentIdx + 1) * sublen + 36], instrumentIdx);
6026 store32(&pData[(instrumentIdx + 1) * sublen + 40],
pSamples->size());
6029 totnbregions += instrument->Regions;
6030 totnbdimregions += nbdimregions;
6031 totnbloops += nbloops;
6036 store32(&pData[4], totnbusedchannels);
6037 store32(&pData[8], totnbusedsamples);
6039 store32(&pData[16], totnbregions);
6040 store32(&pData[20], totnbdimregions);
6041 store32(&pData[24], totnbloops);
6044 store32(&pData[40],
pSamples->size());
6057 }
else if (newFile) {
6072 instrument->UpdateScriptFileOffsets();
6112 std::cout <<
"gig::Exception: " <<
Message << std::endl;
range_t KeySwitchRange
Key range for key switch selector.
file_offset_t WriteUint32(uint32_t *pData, file_offset_t WordCount=1)
Writes WordCount number of 32 Bit unsigned integer words from the buffer pointed by pData to the chun...
bool LFO2FlipPhase
Inverts phase of the filter cutoff LFO wave.
void UpdateRegionKeyTable()
void SetScriptAsText(const String &text)
Replaces the current script with the new script source code text given by text.
void AddContentOf(File *pFile)
Add content of another existing file.
void MoveAll()
Move all members of this group to another group (preferably the 1st one except this).
dim_bypass_ctrl_t DimensionBypass
If defined, the MIDI controller can switch on/off the dimension in realtime.
file_offset_t position
Current position within the sample.
Encapsulates articulation informations of a dimension region.
file_offset_t GetFilePos() const
Current, actual offset of chunk data body start in file.
range_t DimensionKeyRange
0-127 (where 0 means C1 and 127 means G9)
sample_loop_t * pSampleLoops
Points to the beginning of a sample loop array, or is NULL if there are no loops defined.
#define GIG_EG_CTR_RELEASE_INFLUENCE_EXTRACT(x)
file_offset_t GetNewSize() const
New chunk size if it was modified with Resize(), otherwise value returned will be equal to GetSize()...
uint8_t VCFVelocityScale
(0-127) Amount velocity controls VCF cutoff frequency (only if no other VCF cutoff controller is defi...
void SetDimensionType(dimension_t oldType, dimension_t newType)
Change type of an existing dimension.
#define CHUNK_HEADER_SIZE(fileOffsetSize)
bool reverse
If playback direction is currently backwards (in case there is a pingpong or reverse loop defined)...
uint8_t AltSustain2Key
Key triggering a second set of alternate sustain samples.
file_offset_t FrameOffset
Current offset (sample points) in current sample frame (for decompression only).
uint32_t Regions
Reflects the number of Region defintions this Instrument has.
Region * GetRegion(unsigned int Key)
Returns the appropriate Region for a triggered note.
void AddSample(Sample *pSample)
Move Sample given by pSample from another Group to this Group.
String GetScriptAsText()
Returns the current script (i.e.
file_offset_t SamplePos
For compressed samples only: stores the current position (in sample points).
MidiRuleAlternator * AddMidiRuleAlternator()
Adds the alternator MIDI rule to the instrument.
File * GetFile() const
Returns pointer to the chunk's File object.
Sample * AddSample()
Add a new sample.
file_offset_t SetPos(file_offset_t SampleCount, RIFF::stream_whence_t Whence=RIFF::stream_start)
Sets the position within the sample (in sample points, not in bytes).
bool VCFEnabled
If filter should be used.
void AddDimension(dimension_def_t *pDimDef)
Einstein would have dreamed of it - create a new dimension.
file_offset_t ReadUint16(uint16_t *pData, file_offset_t WordCount=1)
Reads WordCount number of 16 Bit unsigned integer words and copies it into the buffer pointed by pDat...
stream_whence_t
File stream position dependent to these relations.
uint32_t FineTune
Specifies the fraction of a semitone up from the specified MIDI unity note field. A value of 0x800000...
uint8_t BypassKey
Key to be used to bypass the sustain note.
uint16_t LFO1ControlDepth
Controller depth influencing sample amplitude LFO pitch (0 - 1200 cents).
Chunk * GetFirstSubChunk()
Returns the first subchunk within the list (which may be an ordinary chunk as well as a list chunk)...
file_offset_t SamplesPerFrame
For compressed samples only: number of samples in a full sample frame.
lfo1_ctrl_t
Defines how LFO1 is controlled by.
Group of Gigasampler samples.
uint32_t LoopType
Defines how the waveform samples will be looped (appropriate loop types for the gig format are define...
uint8_t VCFVelocityDynamicRange
0x04 = lowest, 0x00 = highest .
String Name
Stores the name of this Group.
DimensionRegion * GetDimensionRegionByBit(const uint8_t DimBits[8])
Returns the appropriate DimensionRegion for the given dimension bit numbers (zone index)...
Special dimension for triggering samples on releasing a key.
uint16_t PitchbendRange
Number of semitones pitchbend controller can pitch (default is 2).
double EG1Release
Release time of the sample amplitude EG (0.000 - 60.000s).
#define GIG_EG_CTR_ATTACK_INFLUENCE_EXTRACT(x)
uint8_t Triggers
Number of triggers.
uint ScriptSlotCount() const
Instrument's amount of script slots.
#define GIG_EG_CTR_RELEASE_INFLUENCE_ENCODE(x)
String GetFileName() const
vcf_type_t VCFType
Defines the general filter characteristic (lowpass, highpass, bandpass, etc.).
Script * AddScript()
Add new instrument script.
virtual void SetKeyRange(uint16_t Low, uint16_t High)
Modifies the key range of this Region and makes sure the respective chunks are in correct order...
void __ensureMandatoryChunksExist()
Checks if all (for DLS) mandatory chunks exist, if not they will be created.
uint32_t LoopSize
Caution: Use the respective fields in the DimensionRegion instead of this one! (Intended purpose: Len...
Instrument * AddInstrument()
Add a new instrument definition.
virtual void LoadScriptGroups()
Script * GetScript(uint index)
Get instrument script.
loop_type_t LoopType
Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: The ...
lfo1_ctrl_t LFO1Controller
MIDI Controller which controls sample amplitude LFO.
Only internally controlled.
Sample * GetFirstSample()
Returns a pointer to the first Sample object of the file, NULL otherwise.
uint8_t low
Low value of range.
void UpdateChunks(progress_t *pProgress)
Apply this script group to the respective RIFF chunks.
uint16_t SampleStartOffset
Number of samples the sample start should be moved (0 - 2000).
MIDI rule for triggering notes by control change events.
file_offset_t ReadInt32(int32_t *pData, file_offset_t WordCount=1)
Reads WordCount number of 32 Bit signed integer words and copies it into the buffer pointed by pData...
virtual void CopyAssign(const Region *orig)
Make a (semi) deep copy of the Region object given by orig and assign it to this object.
void(* callback)(progress_t *)
Callback function pointer which has to be assigned to a function for progress notification.
uint8_t Key
Key to trigger.
file_offset_t WorstCaseFrameSize
For compressed samples only: size (in bytes) of the largest possible sample frame.
file_offset_t Size
Size of the actual data in the buffer in bytes.
void AddScriptSlot(Script *pScript, bool bypass=false)
Add new instrument script slot (gig format extension).
bool EG1Hold
If true, Decay1 stage should be postponed until the sample reached the sample loop start...
range_t PlayRange
Key range of the playable keys in the instrument.
file_offset_t ullWavePoolOffset
uint16_t ThresholdTime
Maximum time (ms) between two notes that should be played legato.
static size_t Instances
Number of instances of class Sample.
dimension values are already the sought bit number
Sample(File *pFile, RIFF::List *waveList, file_offset_t WavePoolOffset, unsigned long fileNo=0)
Constructor.
uint8_t VelocityResponseCurveScaling
0 - 127 (usually you don't have to interpret this parameter, use GetVelocityAttenuation() instead)...
bool Descending
If the change in CC value should be downwards.
double GetVelocityCutoff(uint8_t MIDIKeyVelocity)
Instrument * GetFirstInstrument()
Returns a pointer to the first Instrument object of the file, NULL otherwise.
void ReadString(String &s, int size)
Reads a null-padded string of size characters and copies it into the string s.
Region * RegionKeyTable[128]
fast lookup for the corresponding Region of a MIDI key
List * GetParent() const
Returns pointer to the chunk's parent list chunk.
uint8_t ReleaseTriggerKey
Key triggering release samples.
uint32_t * pWavePoolTable
For MIDI tools like legato and repetition mode.
bool VCFKeyboardTracking
If true: VCF cutoff frequence will be dependend to the note key position relative to the defined brea...
uint32_t WavePoolTableIndex
uint8_t Velocity
Velocity of the note to trigger. 255 means that velocity should depend on the speed of the controller...
void CopyAssignWave(const Sample *orig)
Should be called after CopyAssignMeta() and File::Save() sequence.
Defines a controller that has a certain contrained influence on a particular synthesis parameter (use...
uint16_t Channels
Number of channels represented in the waveform data, e.g. 1 for mono, 2 for stereo (defaults to 1=mon...
uint8_t Controller
CC number for controller selector.
void SetVCFVelocityScale(uint8_t scaling)
Updates the respective member variable and the lookup table / cache that depends on this value...
RIFF::List * pCkInstrument
Defines Region information of a Gigasampler/GigaStudio instrument.
file_offset_t SamplesTotal
Reflects total number of sample points (only if known sample data format is used, 0 otherwise)...
void UpdateVelocityTable()
uint32_t LoopPlayCount
Number of times the loop should be played (a value of 0 = infinite).
uint8_t ReleaseTriggerDecay
0 - 8
lfo3_ctrl_t LFO3Controller
MIDI Controller which controls the sample pitch LFO.
bool Chained
If all patterns should be chained together.
uint32_t MIDIUnityNote
Specifies the musical note at which the sample will be played at it's original sample rate...
uint8_t ControllerNumber
MIDI controller number.
Sampler(RIFF::List *ParentList)
List * GetSubList(uint32_t ListType)
Returns sublist chunk with list type ListType within this chunk list.
void DeleteSubChunk(Chunk *pSubChunk)
Removes a sub chunk.
uint8_t ChannelOffset
Audio output where the audio signal of the dimension region should be routed to (0 - 9)...
file_offset_t GetCurrentFileSize() const
Returns the current size of this file (in bytes) as it is currently yet stored on disk...
Defines Sample Loop Points.
uint8_t VCFResonance
Firm internal filter resonance weight.
bool VCFResonanceDynamic
If true: Increases the resonance Q according to changes of controllers that actually control the VCF ...
void DeleteMidiRule(int i)
Deletes a MIDI rule from the instrument.
unsigned int Dimensions
Number of defined dimensions, do not alter!
Only controlled by external modulation wheel.
void UpdateChunks(uint8_t *pData) const
vcf_cutoff_ctrl_t VCFCutoffController
Specifies which external controller has influence on the filter cutoff frequency. ...
file_offset_t loop_cycles_left
How many times the loop has still to be passed, this value will be decremented with each loop cycle...
virtual void SetGain(int32_t gain)
MidiRuleCtrlTrigger * AddMidiRuleCtrlTrigger()
Adds the "controller trigger" MIDI rule to the instrument.
void LoadString(RIFF::Chunk *ck, std::string &s, int strLength)
double EG1Decay1
Decay time of the sample amplitude EG (0.000 - 60.000s).
List * GetFirstSubList()
Returns the first sublist within the list (that is a subchunk with chunk ID "LIST").
file_offset_t GetPos() const
Position within the chunk data body (starting with 0).
DimensionRegion * GetDimensionRegionByValue(const uint DimValues[8])
Use this method in your audio engine to get the appropriate dimension region with it's articulation d...
void UpdateScriptFileOffsets()
lfo2_ctrl_t LFO2Controller
MIDI Controlle which controls the filter cutoff LFO.
void LoadDimensionRegions(RIFF::List *rgn)
Different samples triggered each time a note is played, any key advances the counter.
bool Dithered
For 24-bit compressed samples only: if dithering was used during compression with bit reduction...
Region * GetFirstRegion()
Returns the first Region of the instrument.
#define GIG_VCF_RESONANCE_CTRL_ENCODE(x)
String libraryVersion()
Returns version of this C++ library.
uint8_t VelocityUpperLimit
Defines the upper velocity value limit of a velocity split (only if an user defined limit was set...
uint8_t ReleaseVelocityResponseDepth
Dynamic range of release velocity affecting envelope time (0 - 4).
#define GET_PARAMS(params)
void RemoveAllScriptReferences()
std::list< Sample * > SampleList
Will be thrown whenever a gig specific error occurs while trying to access a Gigasampler File...
buffer_t LoadSampleDataWithNullSamplesExtension(uint NullSamplesCount)
Loads (and uncompresses if needed) the whole sample wave into RAM.
void UpdateChunks(progress_t *pProgress)
Apply this script to the respective RIFF chunks.
Group * GetGroup() const
Returns pointer to the Group this Sample belongs to.
InstrumentList::iterator InstrumentsIterator
Instrument(File *pFile, RIFF::List *insList, progress_t *pProgress=NULL)
void GenerateDLSID()
Generates a new DLSID for the resource.
uint8_t in_end
End position of fade in.
void SetVCFCutoffController(vcf_cutoff_ctrl_t controller)
Updates the respective member variable and the lookup table / cache that depends on this value...
static const DLS::version_t VERSION_2
Reflects Gigasampler file format version 2.0 (1998-06-28).
Sample * pSample
Points to the Sample which is assigned to the dimension region.
uint FrameSize
Reflects the size (in bytes) of one single sample point (only if known sample data format is used...
buffer_t LoadSampleData()
Loads (and uncompresses if needed) the whole sample wave into RAM.
uint16_t ReleaseTime
Release time.
uint32_t LoopStart
Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: The ...
Group * GetNextGroup()
Returns a pointer to the next Group object of the file, NULL otherwise.
void SetVCFVelocityCurve(curve_type_t curve)
Updates the respective member variable and the lookup table / cache that depends on this value...
double EG2Decay1
Decay time of the filter cutoff EG (0.000 - 60.000s).
uint8_t EG1ControllerAttackInfluence
Amount EG1 Controller has influence on the EG1 Attack time (0 - 3, where 0 means off).
#define INITIAL_SAMPLE_BUFFER_SIZE
Initial size of the sample buffer which is used for decompression of compressed sample wave streams -...
String pArticulations[32]
Names of the articulations.
void SetAutoLoad(bool b)
Enable / disable automatic loading.
MidiRule * GetMidiRule(int i)
Returns a MIDI rule of the instrument.
smpte_format_t SMPTEFormat
Specifies the Society of Motion Pictures and Television E time format used in the following SMPTEOffs...
uint16_t low
Low value of range.
double SampleAttenuation
Sample volume (calculated from DLS::Sampler::Gain)
file_offset_t GetPos() const
Returns the current position in the sample (in sample points).
lfo3_ctrl_t
Defines how LFO3 is controlled by.
file_offset_t GuessSize(file_offset_t samples)
file_offset_t RemainingBytes() const
Returns the number of bytes left to read in the chunk body.
ScriptGroup * GetGroup() const
Returns the script group this script currently belongs to.
double EG1Decay2
Only if EG1InfiniteSustain == false: 2nd decay stage time of the sample amplitude EG (0...
void SetFixedStringLengths(const string_length_t *lengths)
Forces specific Info fields to be of a fixed length when being saved to a file.
void RemoveScript(Script *pScript)
Remove reference to given Script (gig format extension).
uint8_t BypassController
Controller to be used to bypass the sustain note.
attenuation_ctrl_t AttenuationController
MIDI Controller which has influence on the volume level of the sample (or entire sample group)...
file_offset_t Read(void *pData, file_offset_t WordCount, file_offset_t WordSize)
Reads WordCount number of data words with given WordSize and copies it into a buffer pointed by pData...
static buffer_t InternalDecompressionBuffer
Buffer used for decompression as well as for truncation of 24 Bit -> 16 Bit samples.
static void DestroyDecompressionBuffer(buffer_t &DecompressionBuffer)
Free decompression buffer, previously created with CreateDecompressionBuffer().
Pointer address and size of a buffer.
virtual void LoadSamples()
uint8_t in_start
Start position of fade in.
file_offset_t WorstCaseMaxSamples(buffer_t *pDecompressionBuffer)
uint8_t Patterns
Number of alternator patterns.
file_offset_t GetSize() const
Chunk size in bytes (without header, thus the chunk data body)
dimension_t dimension
Specifies which source (usually a MIDI controller) is associated with the dimension.
range_t KeyRange
Key range for legato notes.
bool EG2ControllerInvert
Invert values coming from defined EG2 controller.
uint8_t Articulations
Number of articulations in the instrument.
Group * GetFirstGroup()
Returns a pointer to the first Group object of the file, NULL otherwise.
file_offset_t SetPos(file_offset_t Where, stream_whence_t Whence=stream_start)
Sets the position within the chunk body, thus within the data portion of the chunk (in bytes)...
Group * GetGroup(uint index)
Returns the group with the given index.
uint8_t VelSensitivity
How sensitive the velocity should be to the speed of the controller change.
uint32_t DimensionRegions
Total number of DimensionRegions this Region contains, do not alter!
Instrument * AddDuplicateInstrument(const Instrument *orig)
Add a duplicate of an existing instrument.
bool MSDecode
Gigastudio flag: defines if Mid Side Recordings should be decoded.
Key Velocity (this is the only dimension in gig2 where the ranges can exactly be defined).
bool EG1InfiniteSustain
If true, instead of going into Decay2 phase, Decay1 level will be hold until note will be released...
bool Compressed
If the sample wave is compressed (probably just interesting for instrument and sample editors...
void ReleaseSampleData()
Frees the cached sample from RAM if loaded with LoadSampleData() previously.
uint32_t SampleLoops
Reflects the number of sample loops.
More poles than normal lowpass.
virtual void Save(const String &Path, progress_t *pProgress=NULL)
Save changes to another file.
uint16_t LFO2InternalDepth
Firm pitch of the filter cutoff LFO (0 - 1200 cents).
void DeleteDimensionZone(dimension_t type, int zone)
Delete one split zone of a dimension (decrement zone amount).
void Resize(file_offset_t NewSize)
Resize sample.
uint16_t LFO1InternalDepth
Firm pitch of the sample amplitude LFO (0 - 1200 cents).
The difference between none and none2 is unknown.
virtual void LoadInstruments()
static buffer_t CreateDecompressionBuffer(file_offset_t MaxReadSize)
Allocates a decompression buffer for streaming (compressed) samples with Sample::Read().
float zone_size
Intended for internal usage: reflects the size of each zone (128/zones) for normal split types only...
virtual void UpdateFileOffsets()
Updates all file offsets stored all over the file.
void Resize(file_offset_t NewSize)
Resize sample.
bool PitchTrack
If true: sample will be pitched according to the key position (this will be disabled for drums for ex...
double GetVelocityRelease(uint8_t MIDIKeyVelocity)
bool BypassUseController
If a controller should be used to bypass the sustain note.
float __range_min
Only for internal usage, do not modify!
unsigned int Layers
Amount of defined layers (1 - 32). A value of 1 actually means no layering, a value > 1 means there i...
void * pStart
Points to the beginning of the buffer.
file_offset_t ReadUint32(uint32_t *pData, file_offset_t WordCount=1)
Reads WordCount number of 32 Bit unsigned integer words and copies it into the buffer pointed by pDat...
bool EG2InfiniteSustain
If true, instead of going into Decay2 phase, Decay1 level will be hold until note will be released...
Group * pGroup
pointer to the Group this sample belongs to (always not-NULL)
Chunk * GetSubChunk(uint32_t ChunkID)
Returns subchunk with chunk ID ChunkID within this chunk list.
Script(ScriptGroup *group, RIFF::Chunk *ckScri)
struct gig::MidiRuleAlternator::pattern_t pPatterns[32]
A pattern is a sequence of articulation numbers.
Chunk * GetNextSubChunk()
Returns the next subchunk within the list (which may be an ordinary chunk as well as a list chunk)...
MidiRuleLegato * AddMidiRuleLegato()
Adds the legato MIDI rule to the instrument.
std::list< Instrument * > InstrumentList
uint8_t EG2ControllerAttackInfluence
Amount EG2 Controller has influence on the EG2 Attack time (0 - 3, where 0 means off).
Exception(String Message)
bool SelfMask
If true: high velocity notes will stop low velocity notes at the same note, with that you can save vo...
int16_t LFO3ControlDepth
Controller depth of the sample pitch LFO (-1200 - +1200 cents).
void RemoveScriptSlot(uint index)
Remove script slot.
double EG3Attack
Attack time of the sample pitch EG (0.000 - 10.000s).
void DeleteDimension(dimension_def_t *pDimDef)
Delete an existing dimension.
Instrument * GetNextInstrument()
Returns a pointer to the next Instrument object of the file, NULL otherwise.
uint8_t LegatoSamples
Number of legato samples per key in each direction (always 12)
uint8_t out_end
End postition of fade out.
void DeleteGroupOnly(Group *pGroup)
Delete a group.
double EG2Attack
Attack time of the filter cutoff EG (0.000 - 60.000s).
#define GIG_EXP_DECODE(x)
(so far) every exponential paramater in the gig format has a basis of 1.000000008813822 ...
uint16_t BitDepth
Size of each sample per channel (only if known sample data format is used, 0 otherwise).
bool InvertAttenuationController
Inverts the values coming from the defined Attenuation Controller.
double LFO1Frequency
Frequency of the sample amplitude LFO (0.10 - 10.00 Hz).
DimensionRegion(Region *pParent, RIFF::List *_3ewl)
uint32_t LoopID
Specifies the unique ID that corresponds to one of the defined cue points in the cue point list (only...
bool LFO1FlipPhase
Inverts phase of the sample amplitude LFO wave.
uint8_t AltSustain1Key
Key triggering alternate sustain samples.
void DeleteSample(Sample *pSample)
Delete a sample.
Region(Instrument *pInstrument, RIFF::List *rgnList)
bool LFO3Sync
If set to true only one LFO should be used for all voices.
bool IsScriptSlotBypassed(uint index)
Whether script execution shall be skipped.
uint32_t GetChunkID() const
Chunk ID in unsigned integer representation.
double LFO3Frequency
Frequency of the sample pitch LFO (0.10 - 10.00 Hz).
static const DLS::version_t VERSION_3
Reflects Gigasampler file format version 3.0 (2003-03-31).
uint32_t LoopLength
Length of the looping area (in sample points).
void DeleteRegion(Region *pRegion)
ScriptGroup * AddScriptGroup()
Add new instrument script group.
DimensionRegion * pDimensionRegions[256]
Pointer array to the 32 (gig2) or 256 (gig3) possible dimension regions (reflects NULL for dimension ...
uint32_t Product
Specifies the MIDI model ID defined by the manufacturer corresponding to the Manufacturer field...
bool LFO1Sync
If set to true only one LFO should be used for all voices.
split_type_t
Intended for internal usage: will be used to convert a dimension value into the corresponding dimensi...
Alternating loop (forward/backward, also known as Ping Pong)
ScriptGroup * GetScriptGroup(uint index)
Get instrument script group (by index).
void SetSampleChecksum(Sample *pSample, uint32_t crc)
Updates the 3crc chunk with the checksum of a sample.
Sample * GetNextSample()
Returns the next Sample of the Group.
uint8_t EG2ControllerReleaseInfluence
Amount EG2 Controller has influence on the EG2 Release time (0 - 3, where 0 means off)...
Used for indicating the progress of a certain task.
file_offset_t ReadAndLoop(void *pBuffer, file_offset_t SampleCount, playback_state_t *pPlaybackState, DimensionRegion *pDimRgn, buffer_t *pExternalDecompressionBuffer=NULL)
Reads SampleCount number of sample points from the position stored in pPlaybackState into the buffer ...
SampleList::iterator SamplesIterator
uint16_t EG2PreAttack
Preattack value of the filter cutoff EG (0 - 1000 permille).
file_offset_t Write(void *pData, file_offset_t WordCount, file_offset_t WordSize)
Writes WordCount number of data words with given WordSize from the buffer pointed by pData...
uint32_t Loops
Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: Numb...
bool LFO2Sync
If set to true only one LFO should be used for all voices.
uint32_t SMPTEOffset
The SMPTE Offset value specifies the time offset to be used for the synchronization / calibration to ...
file_offset_t ReadInt8(int8_t *pData, file_offset_t WordCount=1)
Reads WordCount number of 8 Bit signed integer words and copies it into the buffer pointed by pData...
unsigned long FileNo
File number (> 0 when sample is stored in an extension file, 0 when it's in the gig) ...
void SplitDimensionZone(dimension_t type, int zone)
Divide split zone of a dimension in two (increment zone amount).
Sample * GetFirstSample(progress_t *pProgress=NULL)
Returns a pointer to the first Sample object of the file, NULL otherwise.
bool EG1ControllerInvert
Invert values coming from defined EG1 controller.
void UpdateChunks(uint8_t *pData) const
Ordinary MIDI control change controller, see field 'controller_number'.
virtual void UpdateChunks(progress_t *pProgress)
Apply Instrument with all its Regions to the respective RIFF chunks.
vcf_type_t
Defines which frequencies are filtered by the VCF.
int GetFileOffsetSize() const
Returns the current size (in bytes) of file offsets stored in the headers of all chunks of this file...
version_t * pVersion
Points to a version_t structure if the file provided a version number else is set to NULL...
void DeleteInstrument(Instrument *pInstrument)
Delete an instrument.
uint16_t LFO2ControlDepth
Controller depth influencing filter cutoff LFO pitch (0 - 1200).
uint32_t LoopStart
The start value specifies the offset (in sample points) in the waveform data of the first sample poin...
virtual void UpdateChunks(progress_t *pProgress)
Update chunks with current group settings.
RegionList::iterator RegionsIterator
int GetDimensionRegionIndexByValue(const uint DimValues[8])
file_offset_t * FrameTable
For positioning within compressed samples only: stores the offset values for each frame...
file_offset_t Write(void *pBuffer, file_offset_t SampleCount)
Write sample wave data.
int16_t EG3Depth
Depth of the sample pitch EG (-1200 - +1200).
bool GetAutoLoad()
Returns whether automatic loading is enabled.
uint8_t VCFKeyboardTrackingBreakpoint
See VCFKeyboardTracking (0 - 127).
eg2_ctrl_t EG2Controller
MIDI Controller which has influence on filter cutoff EG parameters (attack, decay, release).
For layering of up to 8 instruments (and eventually crossfading of 2 or 4 layers).
file_offset_t GetSize() const
Returns sample size.
void * LoadChunkData()
Load chunk body into RAM.
bool VCFCutoffControllerInvert
Inverts values coming from the defined cutoff controller.
Different samples triggered each time a note is played, random order.
file_offset_t NullExtensionSize
The buffer might be bigger than the actual data, if that's the case that unused space at the end of t...
virtual void CopyAssign(const Region *orig)
Make a (semi) deep copy of the Region object given by orig and assign it to this object.
#define GIG_EG_CTR_ATTACK_INFLUENCE_ENCODE(x)
void SwapScriptSlots(uint index1, uint index2)
Flip two script slots with each other (gig format extension).
double EG2Release
Release time of the filter cutoff EG (0.000 - 60.000s).
uint8_t EG1ControllerReleaseInfluence
Amount EG1 Controller has influence on the EG1 Release time (0 - 3, where 0 means off)...
uint8_t EG2ControllerDecayInfluence
Amount EG2 Controller has influence on the EG2 Decay time (0 - 3, where 0 means off).
bool Polyphonic
If alternator should step forward only when all notes are off.
Abstract base class for all MIDI rules.
void SetVelocityResponseCurveScaling(uint8_t scaling)
Updates the respective member variable and the lookup table / cache that depends on this value...
virtual void UpdateChunks(progress_t *pProgress)
Apply all the gig file's current instruments, samples, groups and settings to the respective RIFF chu...
dimension_t
Defines the type of dimension, that is how the dimension zones (and thus how the dimension regions ar...
file_offset_t SamplesInLastFrame
For compressed samples only: length of the last sample frame.
ScriptGroup(File *file, RIFF::List *lstRTIS)
uint32_t LoopEnd
Caution: Use the respective field in the DimensionRegion instead of this one! (Intended purpose: The ...
curve_type_t ReleaseVelocityResponseCurve
Defines a transformation curve to the incoming release veloctiy values affecting envelope times...
Different samples triggered each time a note is played, dimension regions selected in sequence...
dimension_def_t pDimensionDefinitions[8]
Defines the five (gig2) or eight (gig3) possible dimensions (the dimension's controller and number of...
uint8_t zones
Number of zones the dimension has.
Effect 5 Depth (MIDI Controller 95)
#define GIG_EG_CTR_DECAY_INFLUENCE_EXTRACT(x)
uint8_t AttenuationControllerThreshold
0-127
buffer_t GetCache()
Returns current cached sample points.
void SetVCFVelocityDynamicRange(uint8_t range)
Updates the respective member variable and the lookup table / cache that depends on this value...
vcf_cutoff_ctrl_t
Defines how the filter cutoff frequency is controlled by.
void Resize(file_offset_t NewSize)
Resize chunk.
Encapsulates sample waves of Gigasampler/GigaStudio files used for playback.
virtual void SetGain(int32_t gain)
Updates the respective member variable and updates SampleAttenuation which depends on this value...
#define GIG_EG_CTR_DECAY_INFLUENCE_ENCODE(x)
List * AddSubList(uint32_t uiListType)
Creates a new list sub chunk.
Group(File *file, RIFF::Chunk *ck3gnm)
Constructor.
file_offset_t Read(void *pBuffer, file_offset_t SampleCount, buffer_t *pExternalDecompressionBuffer=NULL)
Reads SampleCount number of sample points from the current position into the buffer pointed by pBuffe...
InstrumentList * pInstruments
virtual void UpdateChunks(progress_t *pProgress)
Apply all sample player options to the respective RIFF chunk.
dimension value between 0-127
int16_t LFO3InternalDepth
Firm depth of the sample pitch LFO (-1200 - +1200 cents).
virtual void UpdateChunks(progress_t *pProgress)
Apply dimension region settings to the respective RIFF chunks.
bool IsNew() const
Returns true if this file has been created new from scratch and has not been stored to disk yet...
String Software
<ISFT-ck>. Identifies the name of the sofware package used to create the file.
#define GIG_PITCH_TRACK_EXTRACT(x)
String ArchivalLocation
<IARL-ck>. Indicates where the subject of the file is stored.
Sample * GetNextSample()
Returns a pointer to the next Sample object of the file, NULL otherwise.
double EG2Decay2
Only if EG2InfiniteSustain == false: 2nd stage decay time of the filter cutoff EG (0...
Encapsulates sample waves used for playback.
virtual void UpdateChunks(progress_t *pProgress)
Apply Instrument with all its Regions to the respective RIFF chunks.
type_t type
Controller type.
uint controller_number
MIDI controller number if this controller is a control change controller, 0 otherwise.
uint8_t * VelocityTable
For velocity dimensions with custom defined zone ranges only: used for fast converting from velocity ...
void MoveSubChunk(Chunk *pSrc, Chunk *pDst)
Moves a sub chunk witin this list.
uint32_t SamplesPerSecond
Sampling rate at which each channel should be played (defaults to 44100 if Sample was created with In...
curve_type_t VelocityResponseCurve
Defines a transformation curve to the incoming velocity values affecting amplitude (usually you don't...
A MIDI rule not yet implemented by libgig.
uint16_t EG1Sustain
Sustain value of the sample amplitude EG (0 - 1000 permille).
Sample * GetSample(uint index)
Returns Sample object of index.
size_t CountSubChunks()
Returns number of subchunks within the list (including list chunks).
String GetFileName()
File name of this DLS file.
Real-time instrument script (gig format extension).
void SetVelocityResponseDepth(uint8_t depth)
Updates the respective member variable and the lookup table / cache that depends on this value...
Sample * GetSampleFromWavePool(unsigned int WavePoolTableIndex, progress_t *pProgress=NULL)
Gigasampler/GigaStudio specific classes and definitions.
float __range_max
Only for internal usage, do not modify!
uint8_t DimensionUpperLimits[8]
gig3: defines the upper limit of the dimension values for this dimension region. In case you wondered...
virtual void CopyAssign(const DimensionRegion *orig)
Make a (semi) deep copy of the DimensionRegion object given by orig and assign it to this object...
virtual void UpdateChunks(progress_t *pProgress)
Apply Region settings and all its DimensionRegions to the respective RIFF chunks. ...
uint8_t TriggerPoint
The CC value to pass for the note to be triggered.
uint8_t VelocityResponseDepth
Dynamic range of velocity affecting amplitude (0 - 4) (usually you don't have to interpret this param...
uint32_t LoopFraction
The fractional value specifies a fraction of a sample at which to loop. This allows a loop to be fine...
uint32_t TruncatedBits
For 24-bit compressed samples only: number of bits truncated during compression (0, 4 or 6)
Instrument * GetInstrument(uint index, progress_t *pProgress=NULL)
Returns the instrument with the given index.
void CopyAssignCore(const Sample *orig)
Make a deep copy of the Sample object given by orig (without the actual sample waveform data however)...
Group of instrument scripts (gig format extension).
#define GIG_VCF_RESONANCE_CTRL_EXTRACT(x)
#define GIG_PITCH_TRACK_ENCODE(x)
int8_t Pan
Panorama / Balance (-64..0..63 <-> left..middle..right)
Only internally controlled.
Provides convenient access to Gigasampler/GigaStudio .gig files.
void DeleteRegion(Region *pRegion)
void SetGroup(ScriptGroup *pGroup)
Move this script from its current ScriptGroup to another ScriptGroup given by pGroup.
lfo2_ctrl_t
Defines how LFO2 is controlled by.
Dimension for keyswitching.
MIDI rule for instruments with legato samples.
void SetReleaseVelocityResponseDepth(uint8_t depth)
Updates the respective member variable and the lookup table / cache that depends on this value...
virtual void UpdateChunks(progress_t *pProgress)
Apply sample and its settings to the respective RIFF chunks.
Sample * GetFirstSample()
Returns the first Sample of this Group.
struct gig::MidiRuleCtrlTrigger::trigger_t pTriggers[32]
dimension_def_t * GetDimensionDefinition(dimension_t type)
Searches in the current Region for a dimension of the given dimension type and returns the precise co...
RIFF::file_offset_t file_offset_t
uint16_t EG2Sustain
Sustain value of the filter cutoff EG (0 - 1000 permille).
uint32_t Instruments
Reflects the number of available Instrument objects.
Provides all neccessary information for the synthesis of a DLS Instrument.
Provides access to a Gigasampler/GigaStudio instrument.
void SetScriptSlotBypassed(uint index, bool bBypass)
Defines whether execution shall be skipped.
void DeleteGroup(Group *pGroup)
Delete a group and its samples.
bool SustainDefeat
If true: Sustain pedal will not hold a note.
buffer_t RAMCache
Buffers samples (already uncompressed) in RAM.
virtual void CopyAssign(const Instrument *orig)
Make a (semi) deep copy of the Instrument object given by orig and assign it to this object...
bool NoteOff
If a note off should be triggered instead of a note on.
String libraryName()
Returns the name of this C++ library.
virtual void LoadGroups()
Quadtuple version number ("major.minor.release.build").
void MoveTo(Instrument *dst)
Move this instrument at the position before.
double LFO2Frequency
Frequency of the filter cutoff LFO (0.10 - 10.00 Hz).
uint32_t SamplePeriod
Specifies the duration of time that passes during the playback of one sample in nanoseconds (normally...
uint16_t EG1PreAttack
Preattack value of the sample amplitude EG (0 - 1000 permille).
Script * GetScriptOfSlot(uint index)
Get instrument script (gig format extension).
void CopyAssignCore(const Instrument *orig)
curve_type_t
Defines the shape of a function graph.
uint8_t bits
Number of "bits" (1 bit = 2 splits/zones, 2 bit = 4 splits/zones, 3 bit = 8 splits/zones,...).
selector_t Selector
Method by which pattern is chosen.
virtual void UpdateChunks(uint8_t *pData) const =0
uint32_t GetListType() const
Returns unsigned integer representation of the list's ID.
uint8_t out_start
Start position of fade out.
uint8_t VCFCutoff
Max. cutoff frequency.
virtual void SetKeyRange(uint16_t Low, uint16_t High)
Modifies the key range of this Region and makes sure the respective chunks are in correct order...
DLS specific classes and definitions.
Info * pInfo
Points (in any case) to an Info object, providing additional, optional infos and comments.
uint32_t Manufacturer
Specifies the MIDI Manufacturer's Association (MMA) Manufacturer code for the sampler intended to rec...
uint8_t high
High value of range.
bool OverridePedal
If a note off should be triggered even if the sustain pedal is down.
file_offset_t ReadInt16(int16_t *pData, file_offset_t WordCount=1)
Reads WordCount number of 16 Bit signed integer words and copies it into the buffer pointed by pData...
MIDI rule to automatically cycle through specified sequences of different articulations.
Reflects the current playback state for a sample.
Region * GetParent() const
General dimension definition.
int Size
Number of steps in the pattern.
void CopyAssignMeta(const Sample *orig)
Make a (semi) deep copy of the Sample object given by orig (without the actual waveform data) and ass...
eg1_ctrl_t EG1Controller
MIDI Controller which has influence on sample amplitude EG parameters (attack, decay, release).
uint32_t * pWavePoolTableHi
virtual void UpdateChunks(progress_t *pProgress)
Apply Region settings to the respective RIFF chunks.
split_type_t split_type
Intended for internal usage: will be used to convert a dimension value into the corresponding dimensi...
void DeleteScript(Script *pScript)
Delete an instrument script.
If used sample has more than one channel (thus is not mono).
virtual void UpdateChunks(progress_t *pProgress)
Apply sample and its settings to the respective RIFF chunks.
void SetReleaseVelocityResponseCurve(curve_type_t curve)
Updates the respective member variable and the lookup table / cache that depends on this value...
vcf_res_ctrl_t VCFResonanceController
Specifies which external controller has influence on the filter resonance Q.
curve_type_t VCFVelocityCurve
Defines a transformation curve for the incoming velocity values, affecting the VCF.
file_offset_t ReadUint8(uint8_t *pData, file_offset_t WordCount=1)
Reads WordCount number of 8 Bit unsigned integer words and copies it into the buffer pointed by pData...
uint8_t EG1ControllerDecayInfluence
Amount EG1 Controller has influence on the EG1 Decay time (0 - 3, where 0 means off).
List * GetNextSubList()
Returns the next sublist (that is a subchunk with chunk ID "LIST") within the list.
Defines Region information of an Instrument.
Effect 4 Depth (MIDI Controller 94)
double GetVelocityAttenuation(uint8_t MIDIKeyVelocity)
Returns the correct amplitude factor for the given MIDIKeyVelocity.
std::list< RIFF::File * > ExtensionFiles
void UpdateChunks(uint8_t *pData) const
Sample * GetSample()
Returns pointer address to the Sample referenced with this region.
void SetVelocityResponseCurve(curve_type_t curve)
Updates the respective member variable and the lookup table / cache that depends on this value...
double EG1Attack
Attack time of the sample amplitude EG (0.000 - 60.000s).
Chunk * AddSubChunk(uint32_t uiChunkID, file_offset_t ullBodySize)
Creates a new sub chunk.
#define GIG_EXP_ENCODE(x)
void DeleteScriptGroup(ScriptGroup *pGroup)
Delete an instrument script group.
std::list< Region * > RegionList
Region * GetNextRegion()
Returns the next Region of the instrument.
virtual void UpdateChunks(progress_t *pProgress)
Apply all the DLS file's current instruments, samples and settings to the respective RIFF chunks...
virtual void UpdateFileOffsets()
Updates all file offsets stored all over the file.