Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for sound fonts in SF3 format that contain Ogg Vorbis compressed samples #183

Merged
merged 9 commits into from
Aug 11, 2017

Conversation

fabiangreffrath
Copy link
Contributor

Copy link
Member

@derselbst derselbst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked at the code, so far only two minor issues. Could you provide me / point me to some example sf3 files so I can do some testing? Could not find one...

#if LIBSNDFILE_SUPPORT
// virtual file access rountines to allow for handling
// samples as virtual files in memory
static sf_count_t sfvio_pos;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think introducing this global var here is correct. It may work because we only open one sample at a time, do all the necessary work and never come back to it again. However _fluid_sample_t has a member void* userdata, I wouldnt mind at all abusing this one for storing a sf_count_t sfvio_pos for that specific sample. Imagine something like

case SEEK_SET:
      sample->userdata = (void*) offset;
...
sfvio_tell (void* user_data)
{
   fluid_sample_t *sample = (fluid_sample_t *)user_data;
   return (sf_count_t)sample->userdata;
}

... not nice but more suited IMO.

fluid_sample_t *sample = (fluid_sample_t *)user_data;

return (sf_count_t)(sample->end + 1 - sample->start);
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you placed these lonesome ; here and below? Could you remove them? They may cause compiler warnings.

@fabiangreffrath
Copy link
Contributor Author

Could you provide me / point me to some example sf3 files so I can do some testing?

Sure, there is one in the latest musescore sources. It can be considered the reference implementation, since these guys originally came up with the idea of the SF3 format:

https://github.com/musescore/MuseScore/tree/master/share/sound

I wouldnt mind at all abusing this one for storing a sf_count_t sfvio_pos for that specific sample

Ok, will do so, but it was your idea, in case anyone asks! ;)

Why have you placed these lonesome ; here and below?

They are there by accident, will remove them!

sample->userdata = (void *)offset;
break;
case SEEK_CUR:
sample->userdata = (void *)((intptr_t)sample->userdata + offset);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using (intptr_t) here and below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using it for intermediate casts between pointer and int. Shouldn't make a difference to sf_count_t, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it confuses as you're not mangling with pointers, only with sf_count_t. So I'd prefer sf_count_t.

@derselbst
Copy link
Member

Ok, thanks so far for your contribution! After getting #184 to work, I'll have some tests in the next days. If it all goes well we might already have this in 1.1.7, lets see.

@derselbst derselbst merged commit 070dc29 into FluidSynth:master Aug 11, 2017
@derselbst
Copy link
Member

@fabiangreffrath I merged it in and made some changes to mangling with incorrect sample loops. Hopefully this is correct now, at least I tested with FluidR3.sf3 and it sounds really nice. So we'll have this feature in 1.1.7. Anyway, feel free to build recent git and test it yourself.

Thanks again!

@fabiangreffrath
Copy link
Contributor Author

Thank you very much for merging this! I am really looking forward to testing the new feature, though this will have to wait until next week, as I am currently on vacation. ;)

@fabiangreffrath fabiangreffrath deleted the sf3-fonts branch August 12, 2017 14:49
@fabiangreffrath
Copy link
Contributor Author

Just checked out some Doom music from the Alien Vendetta PWAD with Musescore's SF3 sound font and it worked as expected! \o/

@trebmuh
Copy link

trebmuh commented Sep 2, 2017

Awesome. Thanks for that guys !

@trebmuh trebmuh mentioned this pull request Oct 20, 2017
@mmontag
Copy link

mmontag commented Aug 30, 2018

I've been very happy to find out about SF3 format today and see this recently merged PR here.
Bravo @fabiangreffrath !

@fabiangreffrath
Copy link
Contributor Author

@mmontag Thanks! 😁

@fabiangreffrath
Copy link
Contributor Author

Hm, unfortunately I didn't make it neither into the AUTHORS nor into the THANKS file.

@derselbst
Copy link
Member

If you want to be credited, you are welcome to open a PR and add yourself to either one of the files you prefer.

@fabiangreffrath
Copy link
Contributor Author

If you want to be credited, you are welcome to open a PR and add yourself to either one of the files you prefer.

Sorry, I forgot about this but will open a PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support of vorbis-compressed sf3 sound fonts
5 participants