cAudio 2.1.0 Release!

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: cAudio 2.1.0 Release!

Post by RdR »

Fixt my problem by manually setting the volume of the sounds.
I created a custom scene node for cAudio aswell:

SoundSceneNode.h

Code: Select all

 
/*
 * SoundSceneNode.h
 *
 * Tank @ War Project
 * December 2011
 */
 
#ifndef SOUNDSCENENODE_H_
#define SOUNDSCENENODE_H_
 
#include <irrlicht.h>
#include <cAudio.h>
 
namespace irr {
namespace scene {
 
#ifdef MAKE_IRR_ID
const int SOUND_SCENE_NODE_ID = MAKE_IRR_ID('s','n','d','n');
#else
const int SOUND_SCENE_NODE_ID = 'sndn';
#endif // MAKE_IRR_ID
class SoundSceneNode: public scene::ISceneNode {
private:
        core::aabbox3df box;
        cAudio::IAudioSource* sound;
        cAudio::IAudioManager* soundManager;
        bool deleteWhenFinished;
        f32 soundVolume;
public:
        /**
         * Constructor of SoundSceneNode
         * @param sound
         * @param soundManager
         * @param parent
         * @param smgr
         */
        SoundSceneNode(cAudio::IAudioSource* sound, cAudio::IAudioManager* soundManager, scene::ISceneNode* parent, scene::ISceneManager* smgr);
 
        /**
         * Destructor
         */
        virtual ~SoundSceneNode();
 
        /**
         * Set delete when finished
         * @param deleteWhenFinished
         */
        void setDeleteWhenFinished(bool deleteWhenFinished);
 
        /**
         * On register scene node
         */
        virtual void OnRegisterSceneNode();
 
        /**
         * Render
         */
        virtual void render();
 
        /**
         * On Animate
         * @param timeMs
         */
        virtual void OnAnimate(u32 timeMs);
 
        /**
         * Get AA bounding box
         */
        virtual const core::aabbox3d<f32>& getBoundingBox() const;
 
        /**
         * Get type
         * @return type
         */
        virtual scene::ESCENE_NODE_TYPE getType() const;
 
        /**
         * Get sound source
         * @return sound
         */
        cAudio::IAudioSource* getSound() const;
 
        /**
         * Set sound volume
         * @param volume
         */
        void setVolume(f32 volume);
 
        /**
         * Convert irrlicht to cAudio vector
         * @param v
         * @return vector
         */
        static cAudio::cVector3 irrlichtToCAudioVector(core::vector3df v);
 
        /**
         * Convert cAudio to irrlicht vector
         * @param v
         * @return vector
         */
        static core::vector3df cAudioToIrrlichtVector(cAudio::cVector3 v);
};
 
} // end namespace scene
 
} // end namespace irr
 
#endif /* SOUNDSCENENODE_H_ */
 

SoundSceneNode.cpp

Code: Select all

 
// (c) Tank @ War
 
#include "SoundSceneNode.h"
 
using namespace irr;
using namespace scene;
 
SoundSceneNode::SoundSceneNode(cAudio::IAudioSource* sound, cAudio::IAudioManager* soundManager, scene::ISceneNode* parent, scene::ISceneManager* smgr) :
                scene::ISceneNode(parent, smgr, -1) {
        this->sound = sound;
        this->soundManager = soundManager;
        deleteWhenFinished = true;
 
        if (sound) {
                // Play sound
                cAudio::cVector3 position = irrlichtToCAudioVector(getAbsolutePosition());
                sound->setPosition(position);
                soundVolume = sound->getVolume();
                sound->play3d(position, sound->getStrength(), sound->isLooping());
        }
}
 
SoundSceneNode::~SoundSceneNode() {
        if (sound) {
                if (sound->isPlaying()) {
                        sound->stop();
                }
                soundManager->release(sound);
        }
}
 
void SoundSceneNode::setDeleteWhenFinished(bool deleteWhenFinished) {
        this->deleteWhenFinished = deleteWhenFinished;
}
 
void SoundSceneNode::OnRegisterSceneNode() {
        ISceneNode::OnRegisterSceneNode();
}
 
void SoundSceneNode::render() {
}
 
void SoundSceneNode::OnAnimate(u32 timeMs) {
        if (sound) {
                // Move to new position
                sound->move(irrlichtToCAudioVector(getAbsolutePosition()));
 
                // Set volume
                f32 distance = cAudioToIrrlichtVector(soundManager->getListener()->getPosition()).getDistanceFrom(getAbsolutePosition());
                if (distance <= sound->getMinDistance()) {
                        sound->setVolume(soundVolume);
                } else if (distance > sound->getMaxDistance()) {
                        sound->setVolume(0);
                } else {
                        f32 gain = (sound->getRolloffFactor() * (distance - sound->getMinDistance()) / (sound->getMaxDistance() - sound->getMinDistance()));
                        sound->setVolume(soundVolume - (soundVolume * gain));
                }
 
                // Delete sound when not looping and finished playing
                if (deleteWhenFinished && !sound->isLooping() && sound->isStopped()) {
                        SceneManager->addToDeletionQueue(this);
                }
        } else {
                SceneManager->addToDeletionQueue(this);
        }
 
        ISceneNode::OnAnimate(timeMs);
}
 
void SoundSceneNode::setVolume(f32 volume) {
        soundVolume = volume;
        if (soundVolume == 0) {
                sound->setVolume(0);
        }
}
 
const core::aabbox3d<f32>& SoundSceneNode::getBoundingBox() const {
        return box;
}
 
scene::ESCENE_NODE_TYPE SoundSceneNode::getType() const {
        return (scene::ESCENE_NODE_TYPE) SOUND_SCENE_NODE_ID;
}
 
cAudio::IAudioSource* SoundSceneNode::getSound() const {
        return sound;
}
 
cAudio::cVector3 SoundSceneNode::irrlichtToCAudioVector(core::vector3df v) {
        return cAudio::cVector3(v.X, v.Y, v.Z);
}
 
core::vector3df SoundSceneNode::cAudioToIrrlichtVector(cAudio::cVector3 v) {
        return core::vector3df(v.x, v.y, v.z);
}
 
 
Example

Code: Select all

 
cAudio::IAudioSource* sound = soundManager->create(filename, filename);
if (sound) {
        sound->setVolume(1);
        sound->setMinDistance(30.f);
        sound->setMaxDistance(200.f);
        // etc
 
        scene::SoundSceneNode* soundNode = new scene::SoundSceneNode(sound, soundManager, parent, smgr);
        soundNode->drop();
        return soundNode;
}
 
Last edited by RdR on Sat Jan 21, 2012 7:42 pm, edited 1 time in total.
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: cAudio 2.1.0 Release!

Post by ACE247 »

Hey that's a nice Sound Scene Node, I haven't read all of it but it looks like it supports 3D positional and ranged sounds, playback modes(looping,playonce..) Can be animated through a scene too so the sound moves?
Certainly going to give this a try in my project. :)
Maybe will add sound effects and a param eq aswell.
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: cAudio 2.1.0 Release!

Post by RdR »

ACE247 wrote:Hey that's a nice Sound Scene Node, I haven't read all of it but it looks like it supports 3D positional and ranged sounds, playback modes(looping,playonce..) Can be animated through a scene too so the sound moves?
Certainly going to give this a try in my project. :)
Maybe will add sound effects and a param eq aswell.
Thanks.
Yes, you can attach it to another scene node (as child) and the sound will me moving as well.
Ofcourse you can also use setPosition() on the sound node to move it.
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: cAudio 2.1.0 Release!

Post by polylux »

Good evening cAudioers!

I'm afraid I have to use this thread for my issue as cAudio's forum seems to have bigger troubles.
Using cmake to build the lib I run into the following compile error:

Code: Select all

/(...)/cOpenALAudioDeviceList.cpp: In constructor »cAudio::cOpenALAudioDeviceList::cOpenALAudioDeviceList(cAudio::IDeviceType)«:
/(...)/cOpenALAudioDeviceList.cpp:28:17: Error: »ALC_ALL_DEVICES_SPECIFIER« was not declared in this scope
/(...)/cOpenALAudioDeviceList.cpp:29:21: Error: »ALC_DEFAULT_ALL_DEVICES_SPECIFIER« was not declared in this scope
Investigating this a little further, the above class tries to find enums being declared in one of openAL's includes, namely alc.h.
The only thing I can find there that's somewhat close to them is:

Code: Select all

#define ALC_DEFAULT_DEVICE_SPECIFIER             0x1004
#define ALC_DEVICE_SPECIFIER                     0x1005
Maybe I'm missing something, maybe the API's changed, maybe spiders from Mars.

Hints greatly appreciated,
p.

Versioning:
cAudio's version is 2.2
AL's version is 1.13-2
Sys is Arch-Linux (x86_64)
beer->setMotivationCallback(this);
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: cAudio 2.1.0 Release!

Post by mongoose7 »

Err, grep. You want to see the variable that receives the flag setting and what effect that setting on that variable has in other parts of the code. Then give it a value consistent with other values in the header. You should also verify that the flags you have identified have a different use and not confuse the two.
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: cAudio 2.1.0 Release!

Post by polylux »

Thanks.
Contrary to the naming, both missing ALC_ enums are not in alc.h but in alext.h. Including this file in cOpenALAudioDeviceList is necessary. Checked for both, Arch- and Ubuntu Linux.

Maybe this is helpful for somebody.
beer->setMotivationCallback(this);
wildrj
Posts: 301
Joined: Thu Mar 23, 2006 12:49 am
Location: Texas/ Cyberspace
Contact:

Re: cAudio 2.1.0 Release!

Post by wildrj »

Hey everyone its been a while. Rather then make a new post im just going to post here. Currently i have found freetime this weekend to work on cAudio.
We have moved hosting to github *ill link below* if you could submit "Issue reports" for any bugs you find i will take a look at them.

https://github.com/wildicv/cAudio

^ This is the most up to date code.
http://wild.deathtouchstudios.com << My gamedev blog
<Programming is a way of life>
If at first you don't succeed press the delete key till you do :)
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: cAudio 2.1.0 Release!

Post by polylux »

Hey wildrj!

Just a quick question regarding the versioning. In the git repo a version 2.2 is always mentioned whereas the latest official one still seems to be the 2.1
Is this because of an immanent version step or something else?
I ask this, as the current version in the Arch Linux User Repository (AUR)[1] is still 2.1 which fails to build due to known issues. The git version builds fine right out of the box.

Thanks for clarification,
p.

[1] https://aur.archlinux.org/packages.php?ID=36243
beer->setMotivationCallback(this);
wildrj
Posts: 301
Joined: Thu Mar 23, 2006 12:49 am
Location: Texas/ Cyberspace
Contact:

Re: cAudio 2.1.0 Release!

Post by wildrj »

Late reply is better than no reply.

The arch AUR package is indeed out of date however i am not the person who manages the AUR package that is Svenstaro.

The reason cAudio 2.2.0 is still in dev is for two reasons mostly:
1. I currently am still making small changes to the code to help improve and optimize it.
2. The community is still posting fixes and making pull request.

I do not know when the next official stable release will be to be honest however i do recommend using the dev builds has all pull request / changes are tested thoroughly to make sure no functionality is broken because of a push.
http://wild.deathtouchstudios.com << My gamedev blog
<Programming is a way of life>
If at first you don't succeed press the delete key till you do :)
wildrj
Posts: 301
Joined: Thu Mar 23, 2006 12:49 am
Location: Texas/ Cyberspace
Contact:

Re: cAudio 2.1.0 Release!

Post by wildrj »

For anyone who might need to know. I finally tagged the "2.2.0 stable" release on github and am moving to 2.3.0. So if anyone comes to this thread looking for a "stable" release its on github.
http://wild.deathtouchstudios.com << My gamedev blog
<Programming is a way of life>
If at first you don't succeed press the delete key till you do :)
Post Reply