OpenAL viable sound option?

Started by
7 comments, last by Cacks 9 years, 3 months ago

Hi Guys,

is OpenAL a viable option for programming sound?

I see Minecraft uses OpenAL Soft,

any advice?

cheers

Reject the basic asumption of civialisation especially the importance of material possessions
Advertisement
I see Minecraft uses OpenAL Soft,

Mainly because there is no other choice.

There isn't FMOD wrappers for Java, so if they wanted to use something else, they'd have to write the native bindings on their own. IIRC, Minecraft uses a library called "Paul's Sound System", which comes from Java-Gaming.org forums and uses OpenAL as a backend. It also uses LWJGL, which comes with OpenGL and OpenAL wrappers. So its kinda of a no brainer.

Its also the same issue with D3D, you don't see Java games using D3D11 simply because there is no wrapper for it. And the only D3D9 wrapper hasn't been updated in 8 years.

More on your question, you asked if OpenAL is viable, then immediately after referenced a very popular game using it. So I guess you answered yourself.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

Hi TheChubu,

Is it viable for a C++ application though?

My game is a very simple 1 but I have never used it, is it difficult to use?

Any recent AAA games using OpenAL?

Would you recommend it?

cheers

Reject the basic asumption of civialisation especially the importance of material possessions


Is it viable for a C++ application though?

So from that question using parts of TheChubu's response we can parse the question:

Is there a wrapper for OpenAL in C++?

If yes

OpenAL is viable

else

OpenAl is not viable

Also screw AAA games... tongue.png

You don't need a wrapper as it's written in C

When I say viable I mean is it worth using?

Reject the basic asumption of civialisation especially the importance of material possessions

Hi TheChubu,

Is it viable for a C++ application though?

My game is a very simple 1 but I have never used it, is it difficult to use?

Any recent AAA games using OpenAL?

Would you recommend it?

cheers

I haven't used OpenAL nor FMOD so I can't help you there specifically on deciding which is easier to use (you could totally just look at tutorials/docs and decide on your own whats "easy" to use though).

What I can say is that you're missing the point. Are you making an AAA game? If not, then I don't see how the usage of OpenAL in AAA games affects you.

Euphoria middleware (smart animation engine) is used in GTA 4 and GTA 5, does it means it will work for you? Mirror's Edge used Beast lighting engine middleware, does it means it will work for you?

Your use case and the use case for an AAA title are probably very, very different. So don't go out and think that because Infinity Ward uses something it must be good for you.

I can also say that if Minecraft could use OpenAL successfully, and thats with the horrible JNI layer in between, you could most certainly use it for a C++ application.

What you have to understand is that you're asking if a low level API for audio (OpenAL) is "viable" for you. And I can't answer that, you decide it given the project you want to make. What I can tell you is that for C++ there are tons of libraries that can handle details in a higher level fashion for you (say, SDL, SMFL, I think FMOD has a high level version and indie friendly licences, openFrameworks audio parts, etc).

So shop around, download the libs, see the docs, see what fits your use case better. Then again, you could totally just wait until another user comes with an "In my experience..." type of answer, its your call.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

I've been using OpenAL in my C++ game for years without any issues. We used SDL_Mixer in the past, but decided to switch to OpenAL as it was a bit more powerful and had features that we wanted to make use of, such as distance attenuation. My project is open source and you can study the source code for our audio engine freely. Note that it's licensed under the GPLv2 license, so you are not permitted to use the code unless you make the source available under the same license.

Source location:

https://sourceforge.net/p/allacrost/code/HEAD/tree/trunk/game/src/engine/audio/

Documentation (somewhat incomplete):

http://www.allacrost.org/wiki/index.php/Audio_Engine

This code took about two 8-hour days to make. (SDL_Mixer took a single day). Using OpenAL is pretty simple and straight forward to use.

Hero of Allacrost - A free, open-source 2D RPG in development.
Latest release June, 2015 - GameDev annoucement

I was looking for that lib which could work on all systems ( crossplatformity ). After some tries to implement it, I got nice results - it works great. I am using OpenAL 1.1 ( not soft ). I don't think that I will have any problem in future. Also as I said in previous thread, I got 3d sound working.

Here's my header as example, you don't need to do that much to implement it.


//
//  ALSoundManager.h
//  Nanocat engine.
//
//  Sound manager.
//
//  Created by Neko Code on 12/25/14.
//  Copyright (c) 2014 Neko Code. All rights reserved.
//


#ifndef __sound_h__
#define __sound_h__

#include "SystemShared.h"
#include "GameMath.h"

const int MAX_SOUNDS = 128;
const int MAX_SOUNDNAME_LENGTH = 18;

/*
    WAVE sound.
*/
class ncWaveSound {
public:
    char    type[4];
    int     size, chunkSize;
    short   formatType, channels;
    int     sampleRate, avgBps;
    short   bytesPerSample, bitsPerSample;
    int     dataSize;

    Byte *soundBuffer;
};

/*
    OpenAL sound class.
*/
class ncALSound {
public:
    ncALSound();

    void Play();
    void Stop();

    ALuint sSource;
    ALuint sBuffer;

    ALuint sFormat;
    ALuint sFrequency;

    ALuint sGain;
    ALuint sPitch;

    bool sLoops;
    bool sDistanceNotCare;

    ncVec3 Position;
    ncVec3 Velocity;

    char sName[MAX_SOUNDNAME_LENGTH];
};

class ncSoundManager {
public:
    ncSoundManager();

    void Initialize();
    void Feedback();

    // Shutdown sound system.
    void Shutdown();

    // Find sound by name.
    ncALSound *GetSoundByName( const NString sSound );

    // sound,wav,ocean,1.0,1.0,false,false,oceanwave
    void LoadSound( const NString mSoundType, const NString mSoundName, const float& mGain, const float& mPitch, bool mLoops, bool mDistanceCare, const NString mSoundFile );
    void CreateSound( const NString aName, ALuint aFrequency, ALenum aFormat, Byte *aBuffer, ALuint aSize, ALuint aGain, ALuint aPitch, bool aLoops, bool aDistanceCare );

    void LoadSoundWav( const NString soundname, ncWaveSound *wav );

    ncALSound *SpawnSoundAt( const NString mName, const ncVec3& mPos, const ncVec3& mVel, bool mLoops, bool mDistanceCare );

    // Update listener position and rotation.
    void UpdateListener();

    bool mUpdateListener;

private:
    ALCdevice    *pDevice;
    ALCcontext   *pContext;

    ncALSound   *mSoundBuffers;

    ALuint mTotalBuffers;

    bool Initialized;
};

extern ncSoundManager *g_soundManager;

#endif

Thanks guys,

good to get people's input before committing time to a library,

cheers :)

Reject the basic asumption of civialisation especially the importance of material possessions

This topic is closed to new replies.

Advertisement