Hi, all!
Is there known cross-platform open source spatial audio library for Ogre which does not depend on OpenAL-soft?
miniaudio? any examples?
spatial audio library
-
slapin
- Bronze Sponsor

- Posts: 250
- Joined: Fri May 23, 2025 5:04 pm
- x 16
spatial audio library
-
paroj
- OGRE Team Member

- Posts: 2237
- Joined: Sun Mar 30, 2014 2:51 pm
- x 1216
Re: spatial audio library
whats wrong with openal soft?
-
slapin
- Bronze Sponsor

- Posts: 250
- Joined: Fri May 23, 2025 5:04 pm
- x 16
Re: spatial audio library
It is not exactly wrong but it is non-default dependency and adds hassle to deployment as it is LGPL2
and have to be distributed separately and with some care for license. I look at miniaudio now for ideas.
Also I found that it is very bad idea to link static SDL to libpulse and libasound and found that Godot
worked this around using generated wrapper which allows to avoid linking to nasty sound libs directly...
So I guess I understand the problem now...
-
slapin
- Bronze Sponsor

- Posts: 250
- Joined: Fri May 23, 2025 5:04 pm
- x 16
Re: spatial audio library
@paroj
Did some basic miniaudio integration in my project
Code: Select all
#include <iostream>
#include <miniaudio.h>
#include <Ogre.h>
#include <OgreResourceGroupManager.h>
#include "sound.h"
namespace Sound
{
static ma_decoder decoder;
static ma_device_config deviceConfig;
static ma_device device;
static ma_engine engine;
std::vector<ma_sound> psound_data;
std::map<Ogre::String, int> psounds;
void setup()
{
int i;
ma_result result;
result = ma_engine_init(NULL, &engine);
OgreAssert(result == MA_SUCCESS, "MiniAudio init failed");
Ogre::FileInfoListPtr sounds =
Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"Audio", "*.wav");
psound_data.resize(sounds->size());
for (i = 0; i < sounds->size(); i++) {
Ogre::FileInfo fi = sounds->at(i);
Ogre::String path =
fi.archive->getName() + "/" + fi.path + fi.filename;
std::cout << "sound: " << path << "\n";
std::cout << "sound: " << fi.basename << "\n";
ma_sound_init_from_file(&engine, path.c_str(), 0, NULL, NULL,
&psound_data[i]);
psounds[fi.basename] = i;
}
}
void ding()
{
ma_sound &sound = psound_data[psounds["load.wav"]];
if (ma_sound_is_playing(&sound) && ma_sound_at_end(&sound)) {
ma_sound_stop(&sound);
ma_sound_seek_to_pcm_frame(&sound, 0);
} else if (ma_sound_is_playing(&sound))
return;
ma_sound_start(&sound);
}
}
The most problematic part is resource loading, I did not manage to implement data source to use Ogre's resource system, but that is at least start...
Works well enough and not requires hundreds of dependency libraries. Need suggestions regarding properly using resource system as data source for miniaudio.