Discussion:
accessing soundfont data in SC
michaelgeis
2011-08-17 06:15:40 UTC
Permalink
Hi,
I have been asked to investigate what it takes to access soundfont data from
within SC. I am new to SC itself, but have been asked to look into this
because of my experience bit twiddling with MIDI and .wav files. It would
help me tremendously to receive feedback on my process of reasoning below so
as to get a sense whether I am on a viable track or not (and whether there
is a simpler way).

Judging from the soundfont specification, parsing the soundfont format looks
like a rather finicky enterprise. So I was glad to see that the code in
fluidsynth that achieves this is conveniently all in one location (it turns
it has been taken from an app called 'Smurf Editor').

So my thought was I need to create an sc class/set of classes that interface
with that piece of fluidsynth C code. Running a find on
~/share/SuperCollider/quarks reveals essentially no .c files, which leads me
to conclude that quarks (with the possible exception of UGens) are not
allowed to/able to call C code. Is this correct?

That in turn seems to imply that I would need to create a primitive in order
to call C code, which looks like a bit more involved than creating a quark.

I downloaded the SC source tarball and got the impression that my code would
least be out of place in SuperCollider-Source/common/Source/common and that
the names of the class(es) should be added to commonSources in
SuperCollider-Source/common/SConstruct. After which I'd cross my fingers
that the build process still works...

Are there documents that describe how the build scripts need to be edited
under Linux in order to add a primitive? While I found the chapter on
primitives in the supercollider book very insightful, it gave no
instructions on how to modify/perform the actual build for a given OS.

Does this sound like it could work? Is someone aware of a simpler way of
achieving this (e.g. implementing the .sf2 parsing code in .sc and bypassing
fluisynth)?

Thanks for your consideration.

Best,
Michael



P.S.: I have read the thread at
http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/SoundFonts-in-SC-td5194018.html#a5194873
Since the app that is intended to use the soundfont data will need to be
live playable, I have been told that wiring sc to an instance of fluidsynth
via the alsa sequencer and a jack connection is not an option
(as elegant as the approach may be).




--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/accessing-soundfont-data-in-SC-tp6694322p6694322.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Click Nilson
2011-08-17 08:47:47 UTC
Permalink
Hi Michael,

It would be a very worthy project to bring soundfont support to SC, thank you for exploring this.
Post by michaelgeis
So my thought was I need to create an sc class/set of classes that interface
with that piece of fluidsynth C code. Running a find on
~/share/SuperCollider/quarks reveals essentially no .c files, which leads me
to conclude that quarks (with the possible exception of UGens) are not
allowed to/able to call C code. Is this correct?
quarks are SuperCollider language code. There is no facility yet for language plugins. So you would need to pursue the primitive angle in SC main source if you're doing this language side; though it may well be possible to parse sf files just with SC code and no C (I know you want to reuse the fluidsynth components, though you may need to get into the nittygritty of the file formats anyway to interpret the fluidsynth load with respect to SC lang representation).
Post by michaelgeis
Are there documents that describe how the build scripts need to be edited
under Linux in order to add a primitive? While I found the chapter on
primitives in the supercollider book very insightful, it gave no
instructions on how to modify/perform the actual build for a given OS.
You might want to ask questions on the sc-dev mailing list here as you go.
Post by michaelgeis
Does this sound like it could work? Is someone aware of a simpler way of
achieving this (e.g. implementing the .sf2 parsing code in .sc and bypassing
fluisynth)?
I had a brief think about sf support before and didn't proceed because I could see it was a bit too fiddly for the time I had. To fit the SC paradigm, you'd probably want to load soundfont data to buffers, and use PlayBuf or a new derived UGen for playback. The language side could involve some sort of sound font manager to regulate the server side synthesis bit.

Another option is to put fluidsynth in a UGen; possible, but will involve lots of NRT render stuff, especially for load and initialisation. If fluidsynth makes lots of alloc/dealloc memory calls while in operation, they can be problematic if not converted to use SC synth's own memory calls, or by call out to NRT thread every time (which could critically delay operation; hence why I'm thinking about the buffer+UGen approach).

It is a good project, all the same!

cheers
Nick
michaelgeis
2011-08-17 18:31:42 UTC
Permalink
Thanks everyone, that is great feedback.
I think I need a bit of introspection on which one of the three options
would work best for our needs:
primitive, quark parsing .sf2, or quark parsing 3rd party format.

Will think a bit and probably come back with a lot more questions.

Best,
Michael



--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/accessing-soundfont-data-in-SC-tp6694322p6696555.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

felix
2011-08-17 11:59:28 UTC
Permalink
another simpler way to approach it would be to convert the soundfonts to wav

either manually with an another application

or

if you have to then by compiling your own little c app,
you could then call this by the command line and could do that from inside
SC if you need to automate anything

or

it looks like fluidsynth converts midi to wav using soundfonts

http://wootangent.net/2010/11/converting-midi-to-wav-or-mp3-the-easy-way/

so you could just create a midi file that plays only one note !
use SC to create all the midi files for each note / sample

and then you would have all samples saved as WAV

SC is a good language to use for these types of batch processes
Post by michaelgeis
Is someone aware of a simpler way of
achieving this (e.g. implementing the .sf2 parsing code in .sc and bypassing
fluisynth)?
Thanks for your consideration.
Best,
Michael
Andrzej Kopeć
2011-08-17 14:31:40 UTC
Permalink
Post by felix
another simpler way to approach it would be to convert the
soundfonts to wav
either manually with an another application
maybe this can be of some help:
http://code.google.com/p/pysf/

ak
_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Loading...