fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] Getting all instrument names from a loaded soundfont fil


From: Reinhold Hoffmann
Subject: Re: [fluid-dev] Getting all instrument names from a loaded soundfont file
Date: Thu, 11 Jul 2019 11:30:32 +0200

Hi Kjetil,

Thanks for the immediate response. libgig and the code sample really looks
good, simple and easy. However, libgig is under the GPL license. Our
software is a commercial software where we use the libfluidsynth library
strictly under the LGPL license. libgig does not offer the LGPL license but
only the GPL license which we therefore cannot use.

Reinhold

-----Urspr√ľngliche Nachricht-----
Von: fluid-dev [mailto:fluid-dev-bounces+reinhold=address@hidden]
Im Auftrag von Kjetil Matheussen
Gesendet: Donnerstag, 11. Juli 2019 10:54
An: FluidSynth mailing list
Betreff: Re: [fluid-dev] Getting all instrument names from a loaded
soundfont file

On Thu, Jul 11, 2019 at 10:26 AM Reinhold Hoffmann
<address@hidden> wrote:
>
> Hi,
>
>
>
> I want to display to the user the instrument names of the samples of a
loaded soundfont file (sf2, sf3 format).
>
>
>
> Is there a public interface available in the libfluidsynth library where
the instrument names of the soundfont samples can be obtained after a
soundfont file is loaded with fluid_synth_sfload to a fluidsynth
synthesizer? It looks as if those sample names are handled internally but I
am not sure if those instrument sample names can be read using the public
interface.
>
>
>
> Any idea, help, advice or code example is highly appreciated.
>

libgig has a pretty clear interface to parse sf2 files

This is from sf2dump.cpp in libgig:

void PrintPeresets(sf2::File* sf) {
    cout << "Presets (" << sf->GetPresetCount() << "): " << endl;
    for (int i = 0; i < sf->GetPresetCount(); i++) { /* exclude the
terminal header - EOP */
        sf2::Preset* p = sf->GetPreset(i);
        cout << "\t" << p->Name << " (Preset: " << p->PresetNum << ",
Bank: " << p->Bank;
        if (p->pGlobalRegion) PrintRegion(-1, p->pGlobalRegion);

        for (int j = 0; j < p->GetRegionCount(); j++) {
            PrintRegion(j, p->GetRegion(j));
        }
        cout << endl;
       cout << endl;
    }
}


void PrintInstruments(sf2::File* sf) {
    cout << "Instruments (" << sf->GetInstrumentCount() << "): " << endl;
    for (int i = 0; i < sf->GetInstrumentCount(); i++) {
        sf2::Instrument* instr = sf->GetInstrument(i);
        cout << "Instrument bag: " << instr->InstBagNdx << ")" << endl;
        cout << "\t    Regions (" << instr->GetRegionCount() << ")" << endl;

        if (instr->pGlobalRegion) PrintRegion(-1, instr->pGlobalRegion);

        for (int j = 0; j < instr->GetRegionCount(); j++) {
            PrintRegion(j, instr->GetRegion(j));
        }
       cout << "\t" << instr->Name << " (";
        cout << endl;
    }
}

To find out which samples are used in instruments and presets, you
look at the regions:

void PrintRegion(int idx, sf2::Region* reg) {
    if (idx == -1) cout << "\t\tGlobal Region " << endl;
    else cout << "\t\tRegion " << idx << endl;
    sf2::Sample* s = reg->GetSample();
    if (s != NULL) {
        cout << "\t\t    Sample: " << s->Name << ", Fine Tune: " <<
reg->fineTune;
        ...
        cout << endl;
    }
    ...
}

void PrintSamples(sf2::File* sf) {
    cout << "Samples (" << sf->GetSampleCount() << "): " << endl;
    for (int i = 0; i < sf->GetSampleCount(); i++) {
        sf2::Sample* s = sf->GetSample(i);
        cout << "\t" << s->Name << " (Depth: " << ((s->GetFrameSize()
/ s->GetChannelCount()) * 8);
        ...
    }
}

_______________________________________________
fluid-dev mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fluid-dev




reply via email to

[Prev in Thread] Current Thread [Next in Thread]