Replace audio-API instead of forking an old one #145

Closed
opened 2016-03-09 09:59:01 +00:00 by psykauze · 7 comments
psykauze commented 2016-03-09 09:59:01 +00:00 (Migrated from github.com)

Dear Ancurio,

The SDL_sound API is now unmaintained by its author. It's now a little old and you have to patch it.

So, there is some alternative like SDL_mixer that do the same job than SDL_sound and it still maintained. But it still can't play WMA files.

I think the best solution is to use "libav" to decode audio files and also video files.

The purpose of this change is to make compilation easier and to not have to share patched version of library. So, final user can use his own system library.

Regards.

Dear Ancurio, The SDL_sound API is now unmaintained by its author. It's now a little old and you have to patch it. So, there is some alternative like SDL_mixer that do the same job than SDL_sound and it still maintained. But it still can't play WMA files. I think the best solution is to use "libav" to decode audio files and also video files. The purpose of this change is to make compilation easier and to not have to share patched version of library. So, final user can use his own system library. Regards.
carstene1ns commented 2016-03-09 15:02:07 +00:00 (Migrated from github.com)

Please read #36 and #109 for the reasons behind this decision.

Please read #36 and #109 for the reasons behind this decision.
psykauze commented 2016-03-09 17:14:27 +00:00 (Migrated from github.com)

OK. As I understand, the main reason of the use of SDL_sound instead anything else is for decoding sound format (ogg, WAV..) and play it via OpenAL.

But at the end of the homepage project, one goal is to be able to play WMA files. SDL_sound can't play WMA so Ancurio should patch it again with WMA support.

I suggest to use libav because it can decode anything (images, sound & videos). Also, for shared builds, you can limit formats to decode.

Changing to this would be a lot of work but I think it will be easier to add new functionnalities After.

Regards.

OK. As I understand, the main reason of the use of SDL_sound instead anything else is for decoding sound format (ogg, WAV..) and play it via OpenAL. But at the end of the homepage project, one goal is to be able to play WMA files. SDL_sound can't play WMA so Ancurio should patch it again with WMA support. I suggest to use libav because it can decode anything (images, sound & videos). Also, for shared builds, you can limit formats to decode. Changing to this would be a lot of work but I think it will be easier to add new functionnalities After. Regards.
Ancurio commented 2016-03-09 17:31:53 +00:00 (Migrated from github.com)

But at the end of the homepage project, one goal is to be able to play WMA files. SDL_sound can't play WMA so Ancurio should patch it again with WMA support.

Yes, I've tried a few times looking over the ffmpeg WMA decoder code, thinking about how to port it to SDL_sound. But it's not very well commented, and lossy audio decoding algorithms are definitely not something I'm comfortable with, so it goes kinda over my head.

I suggest to use libav because it can decode anything (images, sound & videos). Also, for shared builds, you can limit formats to decode.

Hmmm, you make an interesting point. I assume libav delegates the decoding to respective satellite libs (libpng, libjpeg, libvorbis etc.) for this? Or is it all statically included? Switching to libav sounds just like replacing one lib with another, and the scope of SDL_sound/image is a lot smaller, so it's kinda easier to deal with them.

Changing to this would be a lot of work but I think it will be easier to add new functionnalities After.

It would only add WMA support, which is nice, but really low on priority because so few games even have wma files (and those can be easily converted if need be).

As for Theora video playback, I was thinking of using TheoraPlay due to its extreme minimalism and focus on games. Not sure how it measures up against full blown ffmpeg/libav.

On the other hand, switching something as integral as decoding libs would really have to justify the cost. I don't think SDL_sound not being well maintained is a good argument, and I'm trying to fix this as well.

> But at the end of the homepage project, one goal is to be able to play WMA files. SDL_sound can't play WMA so Ancurio should patch it again with WMA support. Yes, I've tried a few times looking over the ffmpeg WMA decoder code, thinking about how to port it to SDL_sound. But it's not very well commented, and lossy audio decoding algorithms are definitely not something I'm comfortable with, so it goes kinda over my head. > I suggest to use libav because it can decode anything (images, sound & videos). Also, for shared builds, you can limit formats to decode. Hmmm, you make an interesting point. I assume libav delegates the decoding to respective satellite libs (libpng, libjpeg, libvorbis etc.) for this? Or is it all statically included? Switching to libav sounds just like replacing one lib with another, and the scope of SDL_sound/image is a lot smaller, so it's kinda easier to deal with them. > Changing to this would be a lot of work but I think it will be easier to add new functionnalities After. It would only add WMA support, which is nice, but really low on priority because so few games even have wma files (and those can be easily converted if need be). As for Theora video playback, I was thinking of using [TheoraPlay](https://icculus.org/theoraplay/) due to its extreme minimalism and focus on games. Not sure how it measures up against full blown ffmpeg/libav. On the other hand, switching something as integral as decoding libs would **really** have to justify the cost. I don't think SDL_sound not being well maintained is a good argument, and I'm trying to fix this as well.
psykauze commented 2016-03-09 18:04:01 +00:00 (Migrated from github.com)

I assume libav delegates the decoding to respective satellite libs (libpng, libjpeg, libvorbis etc.) for this? Or is it all statically included?

Not for all codec. For example, png, jpg, mpg, mp3 and h263 is natively decoded by libav/ffmpeg but it needs libvorbis, libtheora or libx264 for decoding their respective format.

> I assume libav delegates the decoding to respective satellite libs (libpng, libjpeg, libvorbis etc.) for this? Or is it all statically included? Not for all codec. For example, png, jpg, mpg, mp3 and h263 is natively decoded by libav/ffmpeg but it needs libvorbis, libtheora or libx264 for decoding their respective format.
psykauze commented 2016-03-09 18:19:02 +00:00 (Migrated from github.com)

Maybe I'm wrong about libvorbis, libtheora ans libx264. Maybe libav needs those libs only for encoding but can decode it natively.

Edit: I've checked I WAS WRONG. libav can decode natively all you need and the shared library is less than 5MB.

Maybe I'm wrong about libvorbis, libtheora ans libx264. Maybe libav needs those libs only for encoding but can decode it natively. Edit: I've checked I WAS WRONG. libav can decode natively all you need and the shared library is less than 5MB.
Ghabry commented 2016-07-17 13:43:06 +00:00 (Migrated from github.com)

As an information from the "partner project" for RPG2k/2k3: We used SDL_mixer since years and we always had problems with it's brokeness. Resampling was flawed, MP3 was broken for most cases, no pitch changes... BUT we found a solution which works without patching SDL_mixer and allows us to alter the buffer before SDL_mixer sends it to the soundcard: Mix_HookMusic

https://github.com/EasyRPG/Player/blob/master/src/audio_sdl.cpp#L54

This callback replaces the music playback of SDL2 mixer and you can use it to play anything you want. The only problem is that you lose all of SDL2s decoding functionality (which usually decodes to noise :p), you have to write your own decoders... We have written them for WAV (libsndfile), MP3 (mpg123), OGG (libvorbis), MIDI (fmmidi & wildmidi) and do arbitrary resampling with speexdsp. All problems solved 👍

Though we also have no WMA playback yet (not supported by the engine ;))

As an information from the "partner project" for RPG2k/2k3: We used SDL_mixer since years and we always had problems with it's brokeness. Resampling was flawed, MP3 was broken for most cases, no pitch changes... BUT we found a solution which works without patching SDL_mixer and allows us to alter the buffer before SDL_mixer sends it to the soundcard: `Mix_HookMusic` https://github.com/EasyRPG/Player/blob/master/src/audio_sdl.cpp#L54 This callback replaces the music playback of SDL2 mixer and you can use it to play anything you want. The only problem is that you lose all of SDL2s decoding functionality (which usually decodes to noise :p), you have to write your own decoders... We have written them for WAV (libsndfile), MP3 (mpg123), OGG (libvorbis), MIDI (fmmidi & wildmidi) and do arbitrary resampling with speexdsp. All problems solved :+1: Though we also have no WMA playback yet (not supported by the engine ;))
hanetzer commented 2017-03-09 12:24:00 +00:00 (Migrated from github.com)

This is a very interesting idea in all honesty... Could open up a lot of formats and maybe simplify things for the developer (eg, someone making local builds with special features not upstream).

This is a very interesting idea in all honesty... Could open up a lot of formats and maybe simplify things for the developer (eg, someone making local builds with special features not upstream).
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: MapleShrine/mkxp#145
No description provided.