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

[audio] Replace OpenAL Soft audio library by mini_al #385

Closed
raysan5 opened this issue Nov 12, 2017 · 22 comments
Closed

[audio] Replace OpenAL Soft audio library by mini_al #385

raysan5 opened this issue Nov 12, 2017 · 22 comments

Comments

@raysan5
Copy link
Owner

raysan5 commented Nov 12, 2017

Since the beginning of raylib I've been looking for a lightweight alternative library to OpenAL Soft (#52) and finally, there seems to be a solid candidate for that: mini_al by @dr-soft and proposed by @gen2brain (#52 (comment)).

Don't misundertood, OpenAL Soft is great, easy-to-use, lots of features... but it's also a big library, sometimes difficult to build, with not-really-zlib-compatible license (#372 (comment))... and adds a big dependency to raylib.

One of the final goals for raylib is avoiding any external dependency, being a self contained library that you can download, compile and run in any platform.

It seems mini_al fits perfectly on what I was looking for, actually, library is in active development and new features and platforms are being added. Additionally, @mackron started working on mini_al support for raylib and also, @gen2brain started porting mini-al to Go language, perfect for raylib-go binding. Also love mini_al logo. :P

Many thanks to @mackron and @gen2brain for their help on this project!

@raysan5
Copy link
Owner Author

raysan5 commented Nov 14, 2017

More issue discussion on mini-al github: mackron/miniaudio#3

@raysan5
Copy link
Owner Author

raysan5 commented Nov 24, 2017

Replacement is almost complete, being tested in multiple platforms, but it is a really big library change so, thinking about some transition mechanism.

Maybe supporting OpenAL Soft and mini_al for some time? Or just move fordward and remove OpenAL Soft completely on next raylib iteration? Thinking about it...

@raysan5
Copy link
Owner Author

raysan5 commented Nov 27, 2017

Before doing the transition I need to verify it works properly on all the platforms. OpenAL is quite an stablished library used for commercial games (proved to be stable) while mini_al is a brand new library still under development. I really like it but I need to test it carefully before a full replacement...

@raysan5
Copy link
Owner Author

raysan5 commented Dec 5, 2017

mini_al implemented in PR #413

@gen2brain
Copy link
Contributor

On macOS you will want to define -DMAL_NO_COREAUDIO as that is not implemented yet, so it can fallback to OpenAL.

I only tested if lib and audio examples can be built with raylib-go, but I cannot test in vmware, OpenGL support in virtual machine is not good enough for GLFW to open window.

@gen2brain
Copy link
Contributor

Also, there is no need to link to -framework OpenAL on macOS, it is dlopen-ed.

@mackron
Copy link
Contributor

mackron commented Dec 5, 2017

Defining MAL_NO_COREAUDIO isn't necessary - it's just placeholder. There shouldn't be anything there that breaks the build (correct me if I'm wrong!).

@gen2brain
Copy link
Contributor

It failed to build, I don't have now the exact error, I will add it in couple of minutes here.

@gen2brain
Copy link
Contributor

 github.com/gen2brain/raylib-go/raylib
In file included from mini_al.c:4:
../go/src/github.com/gen2brain/raylib-go/raylib/external/mini_al.h:2749:18: error: use of undeclared identifier 'mal_backend_coreaudio'

@mackron
Copy link
Contributor

mackron commented Dec 5, 2017

Oops. That will get fixed tonight when I get home. Thanks!

Edit: That's fixed in the mini_al repository (dev branch).

@raysan5
Copy link
Owner Author

raysan5 commented Dec 20, 2017

Transition to mini_al has already been done but still keeping the OpenAL Soft backend for some platforms: HTML5 and OSX. Check commit 61afd07

Also reviewed code formatting on audio module.

A more detailed review on new mini_al based audio implementation is required. I want to understand in detail how it works... Still a bit confussed about AudioBuffer, AudioStream, Sound and Music, probably those structures could be refactored...

@gen2brain
Copy link
Contributor

I thought mini_al will fallback to OpenAL on OSX/macOS, there are maybe some issues with that?

Also, I played with emscripten recently and it seems it will use SDL anyway for main loop and probably some other things, so for HTML5 now it will use both SDL and OpenAL?

@raysan5
Copy link
Owner Author

raysan5 commented Dec 20, 2017

Hi @gen2brain, mini_al fallback for OpenAL Soft seems not to work at the moment due to mackron/miniaudio#3 (comment). It was proposed to use SDL backend for audio but it implied a 4-9 MB builds (includes all SDL library, completely overloading!) vs 1 MB with current raylib OpenAL implementation.

Considering that current OpenAL Soft backend for emscripten does not require any special linkage (emscripten detects and uses it automatically), just enabled that option for HTML5.

As far as I know, raylib does not use SDL at all, it uses GLFW emscripten implementation, more lightweight. Actually OpenAL Soft usage is just a custom emscripten implementation to default browser Audio.

About OSX, I couldn't test it so, before enabling a library that I don't know if it works on that platform, I preferred to just leave the raylib OpenAL Soft backend for the moment.

@gen2brain
Copy link
Contributor

Ok, I thought that main loop in emscripten (emulated/pseudo loop etc.) already uses SDL that comes with emscripten, not sure why I thought that.

@mackron
Copy link
Contributor

mackron commented Dec 21, 2017

A more detailed review on new mini_al based audio implementation is required. I want to understand in detail how it works... Still a bit confussed about AudioBuffer, AudioStream, Sound and Music, probably those structures could be refactored...

I can help you out with that if you have any questions.

@raysan5
Copy link
Owner Author

raysan5 commented Dec 21, 2017

Hi @mackron! Thanks for your help! I'll keep you updated! :)

@SethArchambault
Copy link
Contributor

SethArchambault commented Jan 10, 2018

Hey I just tried out the develop branch today and I'm getting the same error as above when I try to compile my game:

Undefined symbols for architecture x86_64:
  "_mal_convert_frames", referenced from:
      _WaveFormat in libraylib.a(audio.o)
ld: symbol(s) not found for architecture x86_64

I figured it belongs here rather than it's own thread.. any solution?

@raysan5
Copy link
Owner Author

raysan5 commented Jan 10, 2018

Hi @SethArchambault, just tested it and it works on my side...

Are you testing it on Windows 10? Compiling with MinGW?

@SethArchambault
Copy link
Contributor

SethArchambault commented Jan 25, 2018

This is on MacOS Sierra, but I just downloaded now, and seems to be working in the latest commit of the develop branch!

@raysan5
Copy link
Owner Author

raysan5 commented Feb 11, 2018

Just did a quick review on commit 7bf6bec

mini_al implementation just works great! As a side effect, executable size has been reduced from ~1.4MB to ~770KB when using audio, I love it!

@raysan5 raysan5 closed this as completed Feb 11, 2018
@mackron
Copy link
Contributor

mackron commented Feb 11, 2018

Just a quick bug I noticed while scanning this code:

https://github.com/raysan5/raylib/blob/develop/src/audio.c#L636

The master volume is getting to to 1, but should be set to volume.

@raysan5
Copy link
Owner Author

raysan5 commented Feb 11, 2018

Hey @mackron! Thank you very much for detecting that issue! Corrected in commit 231a694

This issue was closed.
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

No branches or pull requests

4 participants