Loading instruments/samples
- dahnielson
- Moderator
- Posts: 632
- Joined: Wed Jan 23, 2008 11:25 pm
- Location: Linköping / Tranås, Sweden
- Contact:
Loading instruments/samples
Here's a fairly n00bie question for ya': When loading an instrument, are all samples in the .gig loaded or is it just the samples referenced by the loaded instrument?
Anders Dahnielson
Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux
Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux
Re: Loading instruments/samples
But definitely an eligible question. The meta informations of all samples in the instrument's gig file will be loaded in RAM (small though), but only the referenced samples will be cached. If you're interested in the code, you can find it in src/engines/gig/InstrumenResourceManager.cpp, method InstrumentResourceManager::Create() (around line 481), here the relevant part:
Furthermore, if you change sample reference(s) on the fly with gigedit, the respective unused samples will immediately be freed from memory as well.
But one thing you might argue, is that we also cache samples referenced by the Region (as you see in the code above). Even though the gig format only plays samples referenced by the Dimension Regions (the subregions of a region if you will). The gig synthesis format doesnt care about the samples referenced by Regions at all. That's just an unused legacy of the DLS format. So that's one thing we could drop out. Shouldn't make much a difference in practice though I think.
Code: Select all
::gig::Region* pRgn = pInstrument->GetFirstRegion();
while (pRgn) {
// we randomly schedule 90% for the .gig file loading and the remaining 10% now for sample caching
const float localProgress = 0.9f + 0.1f * (float) iRegion / (float) pInstrument->Regions;
DispatchResourceProgressEvent(Key, localProgress);
if (pRgn->GetSample() && !pRgn->GetSample()->GetCache().Size) {
dmsg(2,("C"));
CacheInitialSamples(pRgn->GetSample(), (gig::EngineChannel*) pConsumer);
}
for (uint i = 0; i < pRgn->DimensionRegions; i++) {
CacheInitialSamples(pRgn->pDimensionRegions[i]->pSample, (gig::EngineChannel*) pConsumer);
}
pRgn = pInstrument->GetNextRegion();
iRegion++;
}
But one thing you might argue, is that we also cache samples referenced by the Region (as you see in the code above). Even though the gig format only plays samples referenced by the Dimension Regions (the subregions of a region if you will). The gig synthesis format doesnt care about the samples referenced by Regions at all. That's just an unused legacy of the DLS format. So that's one thing we could drop out. Shouldn't make much a difference in practice though I think.
- dahnielson
- Moderator
- Posts: 632
- Joined: Wed Jan 23, 2008 11:25 pm
- Location: Linköping / Tranås, Sweden
- Contact:
Re: Loading instruments/samples
Ok, that makes sense in regards to the choice of loading strategy specified in a instrument map. The reason I asked was because I wondered if there was an added "cost" to load a second instrument from the same gig file in terms of cached samples or if it came free. Thinking about it more I realized that only referenced samples was dealt with otherwise it would be a huge waste of sample streams.
Anders Dahnielson
Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux
Ardour2, Qtractor, Linuxsampler, M-AUDIO Delta 1010, Axiom 61, Korg D12, AKAI S2000, E-MU Proteus 2k, Roland R-5, Roland HP 1300e, Zoom RFX-1000, 4GB RAM x86_64 Intel Pentium Dual 1.80GHz Gentoo Linux
Re: Loading instruments/samples
Good question this one.
There's definitely a difference when accessing instruments (articulations?) from the same gig file. My violin down bows load quickly enough, but when i add the up bows from the same gig file, they load almost instantly.
Makes short work of loading a complete orchestra!
Alex.
There's definitely a difference when accessing instruments (articulations?) from the same gig file. My violin down bows load quickly enough, but when i add the up bows from the same gig file, they load almost instantly.
Makes short work of loading a complete orchestra!
Alex.