257 |
} |
} |
258 |
} |
} |
259 |
|
|
260 |
|
Info::~Info() { |
261 |
|
} |
262 |
|
|
263 |
/** @brief Load given INFO field. |
/** @brief Load given INFO field. |
264 |
* |
* |
265 |
* Load INFO field from INFO chunk with chunk ID \a ChunkID from INFO |
* Load INFO field from INFO chunk with chunk ID \a ChunkID from INFO |
269 |
RIFF::Chunk* ck = lstINFO->GetSubChunk(ChunkID); |
RIFF::Chunk* ck = lstINFO->GetSubChunk(ChunkID); |
270 |
if (ck) { |
if (ck) { |
271 |
// TODO: no check for ZSTR terminated strings yet |
// TODO: no check for ZSTR terminated strings yet |
272 |
s = (char*) ck->LoadChunkData(); |
s.assign((char*) ck->LoadChunkData(), ck->GetSize()); |
273 |
ck->ReleaseChunkData(); |
ck->ReleaseChunkData(); |
274 |
} |
} |
275 |
} |
} |
898 |
} |
} |
899 |
|
|
900 |
void Instrument::LoadRegions() { |
void Instrument::LoadRegions() { |
901 |
|
if (!pRegions) pRegions = new RegionList; |
902 |
RIFF::List* lrgn = pCkInstrument->GetSubList(LIST_TYPE_LRGN); |
RIFF::List* lrgn = pCkInstrument->GetSubList(LIST_TYPE_LRGN); |
903 |
if (!lrgn) throw DLS::Exception("DLS::Instrument doesn't seem to have any Region (mandatory chunks in <ins > chunk not found)"); |
if (lrgn) { |
904 |
uint32_t regionCkType = (lrgn->GetSubList(LIST_TYPE_RGN2)) ? LIST_TYPE_RGN2 : LIST_TYPE_RGN; // prefer regions level 2 |
uint32_t regionCkType = (lrgn->GetSubList(LIST_TYPE_RGN2)) ? LIST_TYPE_RGN2 : LIST_TYPE_RGN; // prefer regions level 2 |
905 |
RIFF::List* rgn = lrgn->GetFirstSubList(); |
RIFF::List* rgn = lrgn->GetFirstSubList(); |
906 |
while (rgn) { |
while (rgn) { |
907 |
if (rgn->GetListType() == regionCkType) { |
if (rgn->GetListType() == regionCkType) { |
908 |
if (!pRegions) pRegions = new RegionList; |
pRegions->push_back(new Region(this, rgn)); |
909 |
pRegions->push_back(new Region(this, rgn)); |
} |
910 |
|
rgn = lrgn->GetNextSubList(); |
911 |
} |
} |
|
rgn = lrgn->GetNextSubList(); |
|
912 |
} |
} |
913 |
} |
} |
914 |
|
|
915 |
Region* Instrument::AddRegion() { |
Region* Instrument::AddRegion() { |
916 |
if (!pRegions) pRegions = new RegionList; |
if (!pRegions) LoadRegions(); |
917 |
RIFF::List* lrgn = pCkInstrument->GetSubList(LIST_TYPE_LRGN); |
RIFF::List* lrgn = pCkInstrument->GetSubList(LIST_TYPE_LRGN); |
918 |
if (!lrgn) lrgn = pCkInstrument->AddSubList(LIST_TYPE_LRGN); |
if (!lrgn) lrgn = pCkInstrument->AddSubList(LIST_TYPE_LRGN); |
919 |
RIFF::List* rgn = lrgn->AddSubList(LIST_TYPE_RGN); |
RIFF::List* rgn = lrgn->AddSubList(LIST_TYPE_RGN); |
920 |
Region* pNewRegion = new Region(this, rgn); |
Region* pNewRegion = new Region(this, rgn); |
921 |
pRegions->push_back(pNewRegion); |
pRegions->push_back(pNewRegion); |
922 |
|
Regions = pRegions->size(); |
923 |
return pNewRegion; |
return pNewRegion; |
924 |
} |
} |
925 |
|
|
928 |
RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pRegion); |
RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pRegion); |
929 |
if (iter == pRegions->end()) return; |
if (iter == pRegions->end()) return; |
930 |
pRegions->erase(iter); |
pRegions->erase(iter); |
931 |
|
Regions = pRegions->size(); |
932 |
delete pRegion; |
delete pRegion; |
933 |
} |
} |
934 |
|
|
1088 |
if (pWavePoolTable) delete[] pWavePoolTable; |
if (pWavePoolTable) delete[] pWavePoolTable; |
1089 |
if (pWavePoolTableHi) delete[] pWavePoolTableHi; |
if (pWavePoolTableHi) delete[] pWavePoolTableHi; |
1090 |
if (pVersion) delete pVersion; |
if (pVersion) delete pVersion; |
1091 |
|
for (std::list<RIFF::File*>::iterator i = ExtensionFiles.begin() ; i != ExtensionFiles.end() ; i++) |
1092 |
|
delete *i; |
1093 |
} |
} |
1094 |
|
|
1095 |
Sample* File::GetFirstSample() { |
Sample* File::GetFirstSample() { |
1106 |
} |
} |
1107 |
|
|
1108 |
void File::LoadSamples() { |
void File::LoadSamples() { |
1109 |
|
if (!pSamples) pSamples = new SampleList; |
1110 |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
1111 |
if (wvpl) { |
if (wvpl) { |
1112 |
unsigned long wvplFileOffset = wvpl->GetFilePos(); |
unsigned long wvplFileOffset = wvpl->GetFilePos(); |
1113 |
RIFF::List* wave = wvpl->GetFirstSubList(); |
RIFF::List* wave = wvpl->GetFirstSubList(); |
1114 |
while (wave) { |
while (wave) { |
1115 |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
|
if (!pSamples) pSamples = new SampleList; |
|
1116 |
unsigned long waveFileOffset = wave->GetFilePos(); |
unsigned long waveFileOffset = wave->GetFilePos(); |
1117 |
pSamples->push_back(new Sample(this, wave, waveFileOffset - wvplFileOffset)); |
pSamples->push_back(new Sample(this, wave, waveFileOffset - wvplFileOffset)); |
1118 |
} |
} |
1126 |
RIFF::List* wave = dwpl->GetFirstSubList(); |
RIFF::List* wave = dwpl->GetFirstSubList(); |
1127 |
while (wave) { |
while (wave) { |
1128 |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
|
if (!pSamples) pSamples = new SampleList; |
|
1129 |
unsigned long waveFileOffset = wave->GetFilePos(); |
unsigned long waveFileOffset = wave->GetFilePos(); |
1130 |
pSamples->push_back(new Sample(this, wave, waveFileOffset - dwplFileOffset)); |
pSamples->push_back(new Sample(this, wave, waveFileOffset - dwplFileOffset)); |
1131 |
} |
} |
1147 |
__ensureMandatoryChunksExist(); |
__ensureMandatoryChunksExist(); |
1148 |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
1149 |
// create new Sample object and its respective 'wave' list chunk |
// create new Sample object and its respective 'wave' list chunk |
|
if (!pSamples) pSamples = new SampleList; |
|
1150 |
RIFF::List* wave = wvpl->AddSubList(LIST_TYPE_WAVE); |
RIFF::List* wave = wvpl->AddSubList(LIST_TYPE_WAVE); |
1151 |
Sample* pSample = new Sample(this, wave, 0 /*arbitrary value, we update offsets when we save*/); |
Sample* pSample = new Sample(this, wave, 0 /*arbitrary value, we update offsets when we save*/); |
1152 |
pSamples->push_back(pSample); |
pSamples->push_back(pSample); |
1182 |
} |
} |
1183 |
|
|
1184 |
void File::LoadInstruments() { |
void File::LoadInstruments() { |
1185 |
|
if (!pInstruments) pInstruments = new InstrumentList; |
1186 |
RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS); |
RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS); |
1187 |
if (lstInstruments) { |
if (lstInstruments) { |
1188 |
RIFF::List* lstInstr = lstInstruments->GetFirstSubList(); |
RIFF::List* lstInstr = lstInstruments->GetFirstSubList(); |
1189 |
while (lstInstr) { |
while (lstInstr) { |
1190 |
if (lstInstr->GetListType() == LIST_TYPE_INS) { |
if (lstInstr->GetListType() == LIST_TYPE_INS) { |
|
if (!pInstruments) pInstruments = new InstrumentList; |
|
1191 |
pInstruments->push_back(new Instrument(this, lstInstr)); |
pInstruments->push_back(new Instrument(this, lstInstr)); |
1192 |
} |
} |
1193 |
lstInstr = lstInstruments->GetNextSubList(); |
lstInstr = lstInstruments->GetNextSubList(); |
1205 |
Instrument* File::AddInstrument() { |
Instrument* File::AddInstrument() { |
1206 |
if (!pInstruments) LoadInstruments(); |
if (!pInstruments) LoadInstruments(); |
1207 |
__ensureMandatoryChunksExist(); |
__ensureMandatoryChunksExist(); |
|
if (!pInstruments) pInstruments = new InstrumentList; |
|
1208 |
RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS); |
RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS); |
1209 |
RIFF::List* lstInstr = lstInstruments->AddSubList(LIST_TYPE_INS); |
RIFF::List* lstInstr = lstInstruments->AddSubList(LIST_TYPE_INS); |
1210 |
Instrument* pInstrument = new Instrument(this, lstInstr); |
Instrument* pInstrument = new Instrument(this, lstInstr); |