362 |
Manufacturer = 0; |
Manufacturer = 0; |
363 |
Product = 0; |
Product = 0; |
364 |
SamplePeriod = uint32_t(1000000000.0 / SamplesPerSecond + 0.5); |
SamplePeriod = uint32_t(1000000000.0 / SamplesPerSecond + 0.5); |
365 |
MIDIUnityNote = 64; |
MIDIUnityNote = 60; |
366 |
FineTune = 0; |
FineTune = 0; |
367 |
SMPTEFormat = smpte_format_no_offset; |
SMPTEFormat = smpte_format_no_offset; |
368 |
SMPTEOffset = 0; |
SMPTEOffset = 0; |
1160 |
*/ |
*/ |
1161 |
unsigned long Sample::Write(void* pBuffer, unsigned long SampleCount) { |
unsigned long Sample::Write(void* pBuffer, unsigned long SampleCount) { |
1162 |
if (Compressed) throw gig::Exception("There is no support for writing compressed gig samples (yet)"); |
if (Compressed) throw gig::Exception("There is no support for writing compressed gig samples (yet)"); |
1163 |
|
|
1164 |
|
// if this is the first write in this sample, reset the |
1165 |
|
// checksum calculator |
1166 |
if (pCkData->GetPos() == 0) { |
if (pCkData->GetPos() == 0) { |
1167 |
crc.reset(); |
crc.reset(); |
1168 |
} |
} |
1169 |
unsigned long res = DLS::Sample::Write(pBuffer, SampleCount); |
unsigned long res = DLS::Sample::Write(pBuffer, SampleCount); |
1170 |
crc.update((unsigned char *)pBuffer, SampleCount * FrameSize); |
crc.update((unsigned char *)pBuffer, SampleCount * FrameSize); |
1171 |
|
|
1172 |
|
// if this is the last write, update the checksum chunk in the |
1173 |
|
// file |
1174 |
if (pCkData->GetPos() == pCkData->GetSize()) { |
if (pCkData->GetPos() == pCkData->GetSize()) { |
1175 |
File* pFile = static_cast<File*>(GetParent()); |
File* pFile = static_cast<File*>(GetParent()); |
1176 |
pFile->SetSampleChecksum(this, crc.getValue()); |
pFile->SetSampleChecksum(this, crc.getValue()); |
1420 |
LFO1ControlDepth = 0; |
LFO1ControlDepth = 0; |
1421 |
LFO3ControlDepth = 0; |
LFO3ControlDepth = 0; |
1422 |
EG1Attack = 0.0; |
EG1Attack = 0.0; |
1423 |
EG1Decay1 = 0.0; |
EG1Decay1 = 0.005; |
1424 |
EG1Sustain = 0; |
EG1Sustain = 1000; |
1425 |
EG1Release = 0.0; |
EG1Release = 0.3; |
1426 |
EG1Controller.type = eg1_ctrl_t::type_none; |
EG1Controller.type = eg1_ctrl_t::type_none; |
1427 |
EG1Controller.controller_number = 0; |
EG1Controller.controller_number = 0; |
1428 |
EG1ControllerInvert = false; |
EG1ControllerInvert = false; |
1437 |
EG2ControllerReleaseInfluence = 0; |
EG2ControllerReleaseInfluence = 0; |
1438 |
LFO1Frequency = 1.0; |
LFO1Frequency = 1.0; |
1439 |
EG2Attack = 0.0; |
EG2Attack = 0.0; |
1440 |
EG2Decay1 = 0.0; |
EG2Decay1 = 0.005; |
1441 |
EG2Sustain = 0; |
EG2Sustain = 1000; |
1442 |
EG2Release = 0.0; |
EG2Release = 0.3; |
1443 |
LFO2ControlDepth = 0; |
LFO2ControlDepth = 0; |
1444 |
LFO2Frequency = 1.0; |
LFO2Frequency = 1.0; |
1445 |
LFO2InternalDepth = 0; |
LFO2InternalDepth = 0; |
1446 |
EG1Decay2 = 0.0; |
EG1Decay2 = 0.0; |
1447 |
EG1InfiniteSustain = false; |
EG1InfiniteSustain = true; |
1448 |
EG1PreAttack = 1000; |
EG1PreAttack = 0; |
1449 |
EG2Decay2 = 0.0; |
EG2Decay2 = 0.0; |
1450 |
EG2InfiniteSustain = false; |
EG2InfiniteSustain = true; |
1451 |
EG2PreAttack = 1000; |
EG2PreAttack = 0; |
1452 |
VelocityResponseCurve = curve_type_nonlinear; |
VelocityResponseCurve = curve_type_nonlinear; |
1453 |
VelocityResponseDepth = 3; |
VelocityResponseDepth = 3; |
1454 |
ReleaseVelocityResponseCurve = curve_type_nonlinear; |
ReleaseVelocityResponseCurve = curve_type_nonlinear; |
2973 |
// order (INFO chunk will be moved to first position later) |
// order (INFO chunk will be moved to first position later) |
2974 |
pRIFF->AddSubChunk(CHUNK_ID_VERS, 8); |
pRIFF->AddSubChunk(CHUNK_ID_VERS, 8); |
2975 |
pRIFF->AddSubChunk(CHUNK_ID_COLH, 4); |
pRIFF->AddSubChunk(CHUNK_ID_COLH, 4); |
2976 |
|
pRIFF->AddSubChunk(CHUNK_ID_DLID, 16); |
2977 |
|
|
2978 |
|
GenerateDLSID(); |
2979 |
} |
} |
2980 |
|
|
2981 |
File::File(RIFF::File* pRIFF) : DLS::File(pRIFF) { |
File::File(RIFF::File* pRIFF) : DLS::File(pRIFF) { |
3172 |
|
|
3173 |
// add mandatory chunks to get the chunks in right order |
// add mandatory chunks to get the chunks in right order |
3174 |
lstInstr->AddSubList(LIST_TYPE_INFO); |
lstInstr->AddSubList(LIST_TYPE_INFO); |
3175 |
|
lstInstr->AddSubChunk(CHUNK_ID_DLID, 16); |
3176 |
|
|
3177 |
Instrument* pInstrument = new Instrument(this, lstInstr); |
Instrument* pInstrument = new Instrument(this, lstInstr); |
3178 |
|
pInstrument->GenerateDLSID(); |
3179 |
|
|
3180 |
lstInstr->AddSubChunk(CHUNK_ID_INSH, 12); |
lstInstr->AddSubChunk(CHUNK_ID_INSH, 12); |
3181 |
|
|
3232 |
} |
} |
3233 |
} |
} |
3234 |
|
|
3235 |
|
/// Updates the 3crc chunk with the checksum of a sample. The |
3236 |
|
/// update is done directly to disk, as this method is called |
3237 |
|
/// after File::Save() |
3238 |
void File::SetSampleChecksum(Sample* pSample, uint32_t crc) { |
void File::SetSampleChecksum(Sample* pSample, uint32_t crc) { |
3239 |
RIFF::Chunk* _3crc = pRIFF->GetSubChunk(CHUNK_ID_3CRC); |
RIFF::Chunk* _3crc = pRIFF->GetSubChunk(CHUNK_ID_3CRC); |
3240 |
if (!_3crc) return; |
if (!_3crc) return; |
3241 |
|
|
3242 |
|
// get the index of the sample |
3243 |
int iWaveIndex = -1; |
int iWaveIndex = -1; |
3244 |
File::SampleList::iterator iter = pSamples->begin(); |
File::SampleList::iterator iter = pSamples->begin(); |
3245 |
File::SampleList::iterator end = pSamples->end(); |
File::SampleList::iterator end = pSamples->end(); |
3251 |
} |
} |
3252 |
if (iWaveIndex < 0) throw gig::Exception("Could not update crc, could not find sample"); |
if (iWaveIndex < 0) throw gig::Exception("Could not update crc, could not find sample"); |
3253 |
|
|
3254 |
|
// write the CRC-32 checksum to disk |
3255 |
_3crc->SetPos(iWaveIndex * 8); |
_3crc->SetPos(iWaveIndex * 8); |
3256 |
uint32_t tmp = 1; |
uint32_t tmp = 1; |
3257 |
_3crc->WriteUint32(&tmp); // unknown, always 1? |
_3crc->WriteUint32(&tmp); // unknown, always 1? |