Re: Blastbay Studios Open Source Libraries

Gotta agree with openAL's complexity -- I never liked how it attempted to follow the style of OpenGL. FMOD is pretty easy to get working with, it only takes a few lines of initialization and then your ready to go. Something like this (C++17 mind):

#include <fmod.hpp>

int main() {
FMOD::System *system;
if (auto res = System_Create(&system); res != FMOD_OK) {
// handle error
}
if (auto res = system->init(4093, 0, NULL); res != FMOD_OK) {
// handle error
}
// All is ready. Create a sound:
FMOD::Sound *sound;
if (auto res = system->createSound("c:\\windows\\media\\Windows Proximity Notification.wav", FMOD_LOOP_NORMAL, NULL, &sound); res != FMOD_OK) {
// Error...
}
// Play sound (will loop endlessly)
FMOD::Channel *chan;
if (auto res = system->playSound(sound, NULL, false, &chan); res != FMOD_OK) {
// error
}
while (true) {
system->update();
}
return 1;
}

This example will actually work and will play the sound infinitely. (Trust me, OpenAL is much, much more complicated.) The repetition you noticed above is all of those error checks. Those could be eliminated from remaining code by calling setCallback() on the system object, only verifying that setCallback() succeeded. If that worked, that example could be shortened considerably. Here's a full example with error handling with a callback:

#include <fmod.hpp>
#include <fmod_errors.h>
#include <cstdlib>
#include <iostream>

FMOD_RESULT F_CALLBACK ErrorCallback(FMOD_SYSTEM *system, FMOD_SYSTEM_CALLBACK_TYPE type, void *commanddata1, void *commanddata2, void* userdata);

int main() {
FMOD::System *system;
if (auto res = System_Create(&system); res != FMOD_OK) {
std::cerr << "Error: " << FMOD_ErrorString(res) << std::endl;
return 1;
}
if (auto res = system->init(4093, 0, NULL); res != FMOD_OK) {
std::cerr << "Error: " << FMOD_ErrorString(res) << std::endl;
return 1;
}
// Set error callback
if (auto res = system->setCallback(&ErrorCallback, FMOD_SYSTEM_CALLBACK_ERROR); res != FMOD_OK) {
std::cerr << "Error: " << FMOD_ErrorString(res) << std::endl;
return 1;
}
FMOD::Sound *sound;
system->createSound("c:\\windows\\media\\Windows Proximity Notification.wav", FMOD_LOOP_NORMAL, NULL, &sound);
// Play sound (will loop endlessly)
FMOD::Channel *chan;
system->playSound(sound, NULL, false, &chan);
while (true) {
system->update();
}
return 1;
}

// Error callback
FMOD_RESULT F_CALLBACK ErrorCallback(FMOD_SYSTEM *system, FMOD_SYSTEM_CALLBACK_TYPE type, void *commanddata1, void *commanddata2, void* userdata) {
FMOD_ERRORCALLBACK_INFO* info = (FMOD_ERRORCALLBACK_INFO*)commanddata1;
if (info->result!=FMOD_OK) {
std::cerr << "Error " << info->result << " when calling function " << info->functionname << " with parameters " << info->functionparams << ": " << FMOD_ErrorString(info->result) << std::endl;
std::exit(1);
}
return FMOD_OK;
}

The general consensus is the architecture: pointers are created and then initialized by the system object. You could trivially bundle this up into a set of classes that do all the FMOD calls for you if you so choose, as well as error checking. You could incorporate exceptions for fMOD errors too. But the architecture is triviailly simple to understand; and though its a bit strange, it does work nicely.
I, too, would prefer open-source libraries myself. But FMOD is the number one audio library behind Wwise, and it greatly simplifies the huge amount of work that OpenAL forces you to do. (As a side note, FMOD does support HRTF via the free Steam Audio plugin.) So I think that for this, and only this, I can definitely give the fact that its closed-source (sort of anyway) a pass.
And yes, its (technically) open-source -- FMOD is anyway. One of the perks is that if you pay for a license you get access to FMOD's source code. Does it not follow the GPL/LGPL? Yeah, it doesn't, but even if it did, what FMOD is doing is technically not a violation, at all, of the GPL or LGPL because you can charge for the code so long as people are able to get access to it. (That's GPL 3 only, BTW -- GPL v2 prohibits this kind of thing.)

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : queenslight via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : keithwipf1 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : philip_bennefall via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : philip_bennefall via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : philip_bennefall via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : bgt lover via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : bgt lover via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : jaybird via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : bgt lover via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : philip_bennefall via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : hhleon-mueller via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : philip_bennefall via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Aminiel via Audiogames-reflector

Reply via email to