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 |
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 |
|
|
1104 |
} |
} |
1105 |
|
|
1106 |
void File::LoadSamples() { |
void File::LoadSamples() { |
1107 |
|
if (!pSamples) pSamples = new SampleList; |
1108 |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
1109 |
if (wvpl) { |
if (wvpl) { |
1110 |
unsigned long wvplFileOffset = wvpl->GetFilePos(); |
unsigned long wvplFileOffset = wvpl->GetFilePos(); |
1111 |
RIFF::List* wave = wvpl->GetFirstSubList(); |
RIFF::List* wave = wvpl->GetFirstSubList(); |
1112 |
while (wave) { |
while (wave) { |
1113 |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
|
if (!pSamples) pSamples = new SampleList; |
|
1114 |
unsigned long waveFileOffset = wave->GetFilePos(); |
unsigned long waveFileOffset = wave->GetFilePos(); |
1115 |
pSamples->push_back(new Sample(this, wave, waveFileOffset - wvplFileOffset)); |
pSamples->push_back(new Sample(this, wave, waveFileOffset - wvplFileOffset)); |
1116 |
} |
} |
1124 |
RIFF::List* wave = dwpl->GetFirstSubList(); |
RIFF::List* wave = dwpl->GetFirstSubList(); |
1125 |
while (wave) { |
while (wave) { |
1126 |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
if (wave->GetListType() == LIST_TYPE_WAVE) { |
|
if (!pSamples) pSamples = new SampleList; |
|
1127 |
unsigned long waveFileOffset = wave->GetFilePos(); |
unsigned long waveFileOffset = wave->GetFilePos(); |
1128 |
pSamples->push_back(new Sample(this, wave, waveFileOffset - dwplFileOffset)); |
pSamples->push_back(new Sample(this, wave, waveFileOffset - dwplFileOffset)); |
1129 |
} |
} |
1145 |
__ensureMandatoryChunksExist(); |
__ensureMandatoryChunksExist(); |
1146 |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL); |
1147 |
// 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; |
|
1148 |
RIFF::List* wave = wvpl->AddSubList(LIST_TYPE_WAVE); |
RIFF::List* wave = wvpl->AddSubList(LIST_TYPE_WAVE); |
1149 |
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*/); |
1150 |
pSamples->push_back(pSample); |
pSamples->push_back(pSample); |
1180 |
} |
} |
1181 |
|
|
1182 |
void File::LoadInstruments() { |
void File::LoadInstruments() { |
1183 |
|
if (!pInstruments) pInstruments = new InstrumentList; |
1184 |
RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS); |
RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS); |
1185 |
if (lstInstruments) { |
if (lstInstruments) { |
1186 |
RIFF::List* lstInstr = lstInstruments->GetFirstSubList(); |
RIFF::List* lstInstr = lstInstruments->GetFirstSubList(); |
1187 |
while (lstInstr) { |
while (lstInstr) { |
1188 |
if (lstInstr->GetListType() == LIST_TYPE_INS) { |
if (lstInstr->GetListType() == LIST_TYPE_INS) { |
|
if (!pInstruments) pInstruments = new InstrumentList; |
|
1189 |
pInstruments->push_back(new Instrument(this, lstInstr)); |
pInstruments->push_back(new Instrument(this, lstInstr)); |
1190 |
} |
} |
1191 |
lstInstr = lstInstruments->GetNextSubList(); |
lstInstr = lstInstruments->GetNextSubList(); |
1203 |
Instrument* File::AddInstrument() { |
Instrument* File::AddInstrument() { |
1204 |
if (!pInstruments) LoadInstruments(); |
if (!pInstruments) LoadInstruments(); |
1205 |
__ensureMandatoryChunksExist(); |
__ensureMandatoryChunksExist(); |
|
if (!pInstruments) pInstruments = new InstrumentList; |
|
1206 |
RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS); |
RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS); |
1207 |
RIFF::List* lstInstr = lstInstruments->AddSubList(LIST_TYPE_INS); |
RIFF::List* lstInstr = lstInstruments->AddSubList(LIST_TYPE_INS); |
1208 |
Instrument* pInstrument = new Instrument(this, lstInstr); |
Instrument* pInstrument = new Instrument(this, lstInstr); |