To put things in context, I'm finally getting around to implementing audio1
for Android (Java). As it turns out, I'm a little confused about how the backends are laid out.
Below are some questions I'd like to know the answers to. Of course, any additional information that comes to mind is welcome as well. My plan is to compile this into a Wiki entry later on, so that people who want to contribute to Kha know what to watch out for.
General questions
- How are the backend sources included in the compilation process?
The library sources and backend sources often overlap. I'm wondering if the packages are remapped before compilation so that the backend types overwrite the library types, or is there something else going on? It's a bit confusing because backend sources often reference types from library sources that aren't implemented for that backend. Makes it difficult to configure the display server and get completion, so far I had to write a couple of stubs or temporarily comment things to appease the parser.
- What is the purpose of stub classes (definitions without implementations) in Kha library sources?
Some classes in the library sources only contain method stubs (e.g. kha.graphics2.Graphics
). Is your intention for these classes to be implemented by the backend?
- Some backends have
kha/<backend name>
folders. When should these be created?
I assume it's for implementations that require more code to be written in order for the end result to conform to Kha's API.
- Is the 'Empty' backend a template for future backends?
It looks like Empty
is just a template, so I'm just looking for confirmation.
kha.audio1
questions
-
Since there are no tests for audio, what would constitute a good test for the implementation?
-
Android audio playback can be handled in different ways, but for
kha.audio1
theSoundPool
class seems like a good choice. However, it puts a limit on the maximum number of simultaneous playback streams. What should the limit be?
@caiopsouza
MediaPlayer
is the general purpose audio/video reproduction API.SoundPool
is an abstraction overMediaPlayer
which simplifies audio playback.The nice thing about
SoundPool
is that it's pretty much a "done deal". You configure it for the environment you want to use it in (e.g. games), and let it worry about the latency and streaming. It also comes with a couple of nifty features, such as playback rate modification which allows for pitch shifting.Alternatively, you could handle
AudioTrack
instances yourself, which requires you to manually pass the buffers around. It's cool, but tedious in the long run.You can read more about media playback here.