barsoosayque / libgdx-oboe

🎶 libGDX audio replacement for Android (API 16+) built on top of Oboe.
MIT License
54 stars 10 forks source link

How to add libgdx-oboe to my libgdx project? #16

Closed HAL9000Thomas closed 1 year ago

HAL9000Thomas commented 1 year ago

Hi,

How can I add this promising tool to my project? I added

@Override public AndroidAudio createAudio(Context context, AndroidApplicationConfiguration config) { return new OboeAudio(context.getAssets()); }

to my AndroidLauncher class, but it says "Cannot resolve symbol 'OboeAudio'" and IntelliJ does not offer any import selection. I tried using https://jitpack.io/#barsoosayque/libgdx-oboe, but no luck. Any hint please?

barsoosayque commented 1 year ago

I.. don't have a jitpack subscription, so I'm not surprised it didn't work. As for now, there is no way to just get it, there is no place where you can download build artifacts (since I couldn't find any oss maven repo which wouldn't be a big pain to update to). Feel free to suggest services that support maven artifacts for github repositories for free !

The only way to use this library in your projects, is to clone the repository and use it as a local dependency. In this case, you would need to set up NDK in Android Studio or in any other environment that you are using. I'll update the "using" doc with more info.

Unless I misunderstood your particular usecase, this is duplicate of #10. If I did, please, add more info. Otherwise I will close it after I update docs.

HAL9000Thomas commented 1 year ago

Yes, you understood my particular usecase. Just didn't got it how to add this to my project. Will follow your mentioned way by cloning it. Thank you!

medieninformatik commented 1 year ago

@barsoosayque sry to ask you again. should that local dependency be provided as a jar file? if so, which class should i select as main class?

another question: do you know any strategy or tool when "Why is my libGDX app music is so broken ?" applies to iOS too?

barsoosayque commented 1 year ago

I would just include this repo in the main project and declare dependency on it. Basically just:

// settings.gradle.kts
include(":app")
include(":libgdx-oboe")
project(":libgdx-oboe").projectDir = file("/path/to/cloned/library")

// build.gradle.kts
dependenices {
    implementations(":libgdx-oboe")
}

Something like that. Hopefully this even works (note that this is in Kotlin DSL). See this SO answer.

As for iOS, I honestly have no idea. I would assume audio is better on apple devices, if that's not the case, I'm not aware of anything that could help, sorry. It is possible to port this library, but it would require a lot of work: a substitute for oboe audio backend (since it's only for android), crosscompile ffmpeg libraries using apple toolchain, write a bridge between native code and apple code (I even don't know in what language it's written, something like objective c or swift even ?). But even then, I don't own any apple devices, so I couldn't even work on that if I wanted to.

HAL9000Thomas commented 1 year ago

Thank you for the provided snippet. Much appreciated. Was able to declare it as dependency, but ran into few issues regarding cmake. Guess its related to version mismatch since I use different gradle and java version in my project. Will try to fix that next week.

Regarding iOS, yes audio is much better there compared to default Android. Got things working when switching from libGDX Music class to Sound class (with few drawbacks of course).