Loading instruments/samples

You're new to the LinuxSampler world? You don't know where to start and nothing works? Here's the place to ask for help.
Post Reply
User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Loading instruments/samples

Post by dahnielson » Fri Feb 08, 2008 12:03 pm

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

User avatar
cuse
Developer
Posts: 366
Joined: Wed Jan 23, 2008 10:07 pm
Location: Germany

Re: Loading instruments/samples

Post by cuse » Fri Feb 08, 2008 2:36 pm

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:

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++;
}
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.

User avatar
dahnielson
Moderator
Posts: 632
Joined: Wed Jan 23, 2008 11:25 pm
Location: Linköping / Tranås, Sweden
Contact:

Re: Loading instruments/samples

Post by dahnielson » Fri Feb 08, 2008 3:17 pm

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. :geek:
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

Alex
Moderator
Posts: 316
Joined: Wed Jan 23, 2008 9:08 pm

Re: Loading instruments/samples

Post by Alex » Sat Feb 09, 2008 11:19 pm

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.

Post Reply