Discussion:
[fluid-dev] Extracting preset names and numbers
Ben Gonzales
2018-09-26 21:52:42 UTC
Permalink
Hi all.

I'm playing around with a headless RPi with fluidsynth and I'm thinking
of incorporating a small display with button controls to select things
like the preset, the octave, transpose, etc.   I'd like to be able to
extract the preset names and numbers from the target sf2 file so I could
use them in the display program, but I'm having difficulty finding a
suitable utility.

Any suggestions? Python would be nice...

Ben
Ben Gonzales
2018-09-27 10:55:02 UTC
Permalink
OK, I have discovered
<inst number>

and will use that via telnet or somesuch...

Ben
Post by Ben Gonzales
Hi all.
I'm playing around with a headless RPi with fluidsynth and I'm
thinking of incorporating a small display with button controls to
select things like the preset, the octave, transpose, etc.   I'd like
to be able to extract the preset names and numbers from the target sf2
file so I could use them in the display program, but I'm having
difficulty finding a suitable utility.
Any suggestions? Python would be nice...
Ben
_______________________________________________
fluid-dev mailing list
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Marcus Weseloh
2018-09-27 11:13:55 UTC
Permalink
Hey Ben,

there's the sf2utils package: https://pypi.org/project/sf2utils/

I've used this for a while for exactly the same use-case: reading the
preset names and displaying them in a list. It works quite well, but is a
little slow opening Soundfonds with a large number of presets / instruments
/ zones.

I've since created my own module that is much faster, as it only reads the
preset names and doesn't load all the information about generators,
modulators, instruments etc. You can find the code here:
https://github.com/midigurdy/mg-core/blob/7af42f4bedc7fd071fab139b21e7444d24e5b361/mgurdy/src/mg/sf2.py#L160

Cheers,

Marcus
Post by Ben Gonzales
Hi all.
I'm playing around with a headless RPi with fluidsynth and I'm thinking
of incorporating a small display with button controls to select things
like the preset, the octave, transpose, etc. I'd like to be able to
extract the preset names and numbers from the target sf2 file so I could
use them in the display program, but I'm having difficulty finding a
suitable utility.
Any suggestions? Python would be nice...
Ben
_______________________________________________
fluid-dev mailing list
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Andreas Müller
2018-09-27 11:49:05 UTC
Permalink
Post by Marcus Weseloh
Hey Ben,
there's the sf2utils package: https://pypi.org/project/sf2utils/
I've used this for a while for exactly the same use-case: reading the preset
names and displaying them in a list. It works quite well, but is a little
slow opening Soundfonds with a large number of presets / instruments /
zones.
I've since created my own module that is much faster, as it only reads the
preset names and doesn't load all the information about generators,
https://github.com/midigurdy/mg-core/blob/7af42f4bedc7fd071fab139b21e7444d24e5b361/mgurdy/src/mg/sf2.py#L160
Cheers,
Marcus
And I wrote something in C [1] - if I only had known about sf2utils...

Andreas

[1] https://github.com/schnitzeltony/soundfont-cmdline-tools
Post by Marcus Weseloh
Post by Ben Gonzales
Hi all.
I'm playing around with a headless RPi with fluidsynth and I'm thinking
of incorporating a small display with button controls to select things
like the preset, the octave, transpose, etc. I'd like to be able to
extract the preset names and numbers from the target sf2 file so I could
use them in the display program, but I'm having difficulty finding a
suitable utility.
Any suggestions? Python would be nice...
Ben
_______________________________________________
fluid-dev mailing list
https://lists.nongnu.org/mailman/listinfo/fluid-dev
_______________________________________________
fluid-dev mailing list
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Ben Gonzales
2018-09-27 21:58:06 UTC
Permalink
Thanks Marcus (and Andreas).

I'll give both of those a try. Is there a way of just getting the preset
no. and name using sf2utils?

The following works, but it's difficult to separate the "name" from
other info

sf2parse filename.sf2 | grep Preset

I get:

Preset[000:056] Trumpet 2 bag(s) from #0
Preset[000:057] Trombone 2 bag(s) from #2
Preset[000:064] Soprano Sax 2 bag(s) from #4
Preset[000:065] Alto Sax 2 bag(s) from #6
Preset[000:066] Tenor Sax 6 bag(s) from #8
Preset[000:068] Oboe 2 bag(s) from #14
Preset[000:071] Clarinet 6 bag(s) from #16
Preset[000:070] Bassoon 3 bag(s) from #22
Preset[000:073] Flute 5 bag(s) from #25
Preset[000:074] Recorder 3 bag(s) from #30
Preset[001:056] Trumpet 2 9 bag(s) from #33
Preset[001:057] Trombone 2 4 bag(s) from #42
Preset[001:060] Solo French Horn 2 bag(s) from #46
Preset EOP

Of course, it can be done, but is there an easier way?

Ben
Post by Andreas Müller
Post by Marcus Weseloh
Hey Ben,
there's the sf2utils package: https://pypi.org/project/sf2utils/
I've used this for a while for exactly the same use-case: reading the preset
names and displaying them in a list. It works quite well, but is a little
slow opening Soundfonds with a large number of presets / instruments /
zones.
I've since created my own module that is much faster, as it only reads the
preset names and doesn't load all the information about generators,
https://github.com/midigurdy/mg-core/blob/7af42f4bedc7fd071fab139b21e7444d24e5b361/mgurdy/src/mg/sf2.py#L160
Cheers,
Marcus
And I wrote something in C [1] - if I only had known about sf2utils...
Andreas
[1] https://github.com/schnitzeltony/soundfont-cmdline-tools
Post by Marcus Weseloh
Post by Ben Gonzales
Hi all.
I'm playing around with a headless RPi with fluidsynth and I'm thinking
of incorporating a small display with button controls to select things
like the preset, the octave, transpose, etc. I'd like to be able to
extract the preset names and numbers from the target sf2 file so I could
use them in the display program, but I'm having difficulty finding a
suitable utility.
Any suggestions? Python would be nice...
Ben
_______________________________________________
fluid-dev mailing list
https://lists.nongnu.org/mailman/listinfo/fluid-dev
_______________________________________________
fluid-dev mailing list
https://lists.nongnu.org/mailman/listinfo/fluid-dev
_______________________________________________
fluid-dev mailing list
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Marcus Weseloh
2018-09-28 05:10:42 UTC
Permalink
Hi,

here is some documentation about sf2utils:
https://pypi.org/project/sf2utils/
Especially the "Library use" and "High level library API" sections are
interesting for you use-case.

Cheers,

Marcus
Post by Ben Gonzales
Thanks Marcus (and Andreas).
I'll give both of those a try. Is there a way of just getting the preset
no. and name using sf2utils?
The following works, but it's difficult to separate the "name" from
other info
sf2parse filename.sf2 | grep Preset
Preset[000:056] Trumpet 2 bag(s) from #0
Preset[000:057] Trombone 2 bag(s) from #2
Preset[000:064] Soprano Sax 2 bag(s) from #4
Preset[000:065] Alto Sax 2 bag(s) from #6
Preset[000:066] Tenor Sax 6 bag(s) from #8
Preset[000:068] Oboe 2 bag(s) from #14
Preset[000:071] Clarinet 6 bag(s) from #16
Preset[000:070] Bassoon 3 bag(s) from #22
Preset[000:073] Flute 5 bag(s) from #25
Preset[000:074] Recorder 3 bag(s) from #30
Preset[001:056] Trumpet 2 9 bag(s) from #33
Preset[001:057] Trombone 2 4 bag(s) from #42
Preset[001:060] Solo French Horn 2 bag(s) from #46
Preset EOP
Of course, it can be done, but is there an easier way?
Ben
Post by Andreas Müller
Post by Marcus Weseloh
Hey Ben,
there's the sf2utils package: https://pypi.org/project/sf2utils/
I've used this for a while for exactly the same use-case: reading the
preset
Post by Andreas Müller
Post by Marcus Weseloh
names and displaying them in a list. It works quite well, but is a
little
Post by Andreas Müller
Post by Marcus Weseloh
slow opening Soundfonds with a large number of presets / instruments /
zones.
I've since created my own module that is much faster, as it only reads
the
Post by Andreas Müller
Post by Marcus Weseloh
preset names and doesn't load all the information about generators,
https://github.com/midigurdy/mg-core/blob/7af42f4bedc7fd071fab139b21e7444d24e5b361/mgurdy/src/mg/sf2.py#L160
Post by Andreas Müller
Post by Marcus Weseloh
Cheers,
Marcus
And I wrote something in C [1] - if I only had known about sf2utils...
Andreas
[1] https://github.com/schnitzeltony/soundfont-cmdline-tools
Post by Marcus Weseloh
Post by Ben Gonzales
Hi all.
I'm playing around with a headless RPi with fluidsynth and I'm thinking
of incorporating a small display with button controls to select things
like the preset, the octave, transpose, etc. I'd like to be able to
extract the preset names and numbers from the target sf2 file so I
could
Post by Andreas Müller
Post by Marcus Weseloh
Post by Ben Gonzales
use them in the display program, but I'm having difficulty finding a
suitable utility.
Any suggestions? Python would be nice...
Ben
_______________________________________________
fluid-dev mailing list
https://lists.nongnu.org/mailman/listinfo/fluid-dev
_______________________________________________
fluid-dev mailing list
https://lists.nongnu.org/mailman/listinfo/fluid-dev
_______________________________________________
fluid-dev mailing list
https://lists.nongnu.org/mailman/listinfo/fluid-dev
_______________________________________________
fluid-dev mailing list
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Loading...