problem with OpenAL in wiki
-
- Gnoblar
- Posts: 13
- Joined: Mon Aug 08, 2005 10:22 am
- Location: Sydney, Australia
problem with OpenAL in wiki
I am attempting to implement the OpenAL code from the wiki (http://www.ogre3d.org/wiki/index.php/OpenAL), but it seems that OpenAL has made some updates and removed some of the header files that are included (namely alutypes.h and aluttypes.h)
Does anyone know what changes I need to make in order to get this to work, or could someone post a link to an older version of OpenAL that works with this code?
Does anyone know what changes I need to make in order to get this to work, or could someone post a link to an older version of OpenAL that works with this code?
-
- Halfling
- Posts: 41
- Joined: Sat Jun 25, 2005 5:07 am
- Location: London, UK
I've not used the sound manager code I'm afraid (I'm working on my own instead.. just my luck one appears when I'm half way through!).
I'm just guessing, but I've not tried.. try changing the includes to the following..
I've only done a bit of OpenAL stuff, but as far as I can see from the sound manager code there doesn't seem to be any calls to things that these includes don't contain. I've only had a quick look mind.. just give it a go and see what happens!
Anyway, a good starting point for OpenAL are the DevMaster tutorials. The steps take you through the basics of getting sound playing, moving the sound around, buffered playback, etc.
One thing to note, the function alutLoadWAVFile is platform dependent (why they've done it quite like this I don't know). A table can be found near the bottom of here detailing which to use for your OS. I noticed that they're also in the sound manager code, but you should probably create a wrapper function with #ifdef's to call the appropriate one on each platform.
When I've got more time I'll look at getting SoundManager working. Perhaps later this evening.
- Jelly.
I'm just guessing, but I've not tried.. try changing the includes to the following..
Code: Select all
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alu.h>
#include <AL/alut.h>
Anyway, a good starting point for OpenAL are the DevMaster tutorials. The steps take you through the basics of getting sound playing, moving the sound around, buffered playback, etc.
One thing to note, the function alutLoadWAVFile is platform dependent (why they've done it quite like this I don't know). A table can be found near the bottom of here detailing which to use for your OS. I noticed that they're also in the sound manager code, but you should probably create a wrapper function with #ifdef's to call the appropriate one on each platform.
When I've got more time I'll look at getting SoundManager working. Perhaps later this evening.
- Jelly.
-
- OGRE Retired Team Member
- Posts: 209
- Joined: Mon Sep 05, 2005 8:11 pm
- Location: Phoenix, AZ
clsAudioEngine
I am using the OpenAL SDK provided through openAL.org, not the creative labs one.
Well the source compiles with the removal of the mentioned headers...
my includes look like this...
Now after a quick compile i get the following errors...
To fix these errors was simple...
first i take care of the _DB_AUDIO and _DB_AUDIO_DIR
add this to the top of the .cpp file
#define _DB_AUDIO "mydb.txt"
#define _DB_AUDIO_DIR "../"
I figure i wont use the audio database functions right now, so i will fix them later...
Then it complaines about the MinGain, this will fix it..
add this to the top of the .cpp file
#define MinGain 1.0f
now the AudioSourceID error, this one looks like it should be pAudioSourceID.
Ok So lasty I just made my alutInit(0, NULL); look like so alutInit(0, NULL, NULL);
It compiles. I'm going to test it and i'll let you all know.
Well the source compiles with the removal of the mentioned headers...
my includes look like this...
Code: Select all
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alctypes.h>
#include <AL/altypes.h>
#include <ALUT/alut.h>
Code: Select all
------ Build started: Project: OGREest, Configuration: Debug Win32 ------
Compiling...
clsAudioEngine.cpp
c:\My Documents\Visual Studio Projects\OGREest\src\clsAudioEngine.cpp(77) : error C2660: 'alutInit' : function does not take 2 arguments
c:\My Documents\Visual Studio Projects\OGREest\src\clsAudioEngine.cpp(228) : error C2065: 'MinGain' : undeclared identifier
c:\My Documents\Visual Studio Projects\OGREest\src\clsAudioEngine.cpp(350) : error C2065: 'AudioSourceID' : undeclared identifier
c:\My Documents\Visual Studio Projects\OGREest\src\clsAudioEngine.cpp(352) : error C3861: 'AudioSourceID': identifier not found, even with argument-dependent lookup
c:\My Documents\Visual Studio Projects\OGREest\src\clsAudioEngine.cpp(367) : error C2065: '_DB_AUDIO' : undeclared identifier
c:\My Documents\Visual Studio Projects\OGREest\src\clsAudioEngine.cpp(369) : error C3861: '_DB_AUDIO': identifier not found, even with argument-dependent lookup
c:\My Documents\Visual Studio Projects\OGREest\src\clsAudioEngine.cpp(441) : error C2065: '_DB_AUDIO_DIR' : undeclared identifier
Build log was saved at "file://c:\My Documents\Visual Studio Projects\OGREest\obj\Debug\BuildLog.htm"
OGREest - 7 error(s), 0 warning(s)
first i take care of the _DB_AUDIO and _DB_AUDIO_DIR
add this to the top of the .cpp file
#define _DB_AUDIO "mydb.txt"
#define _DB_AUDIO_DIR "../"
I figure i wont use the audio database functions right now, so i will fix them later...
Then it complaines about the MinGain, this will fix it..
add this to the top of the .cpp file
#define MinGain 1.0f
now the AudioSourceID error, this one looks like it should be pAudioSourceID.
Ok So lasty I just made my alutInit(0, NULL); look like so alutInit(0, NULL, NULL);
It compiles. I'm going to test it and i'll let you all know.
-
- OGRE Retired Team Member
- Posts: 209
- Joined: Mon Sep 05, 2005 8:11 pm
- Location: Phoenix, AZ
-
- Gnoll
- Posts: 657
- Joined: Mon Feb 28, 2005 1:53 pm
- Location: Australia - Canberra (ex - Switzerland - Geneva)
Hello
I made several changes to the code found on the wiki.
http://www.ogre3d.org/wiki/index.php/OpenAL
[EDIT] == WIKIED == [/EDIT]
I would like to have the feedback of Van Stokes before updating the Wiki.
Because the code is fairly different.
Purposes :
- Adapted to the new OpenAL version
- Correct several bugs
- Removed useless code
- Add some tests
- Use more "java" like names
- and several minor changes.
Note :
- I didn't use Ogre links to be as independent as possible.
I have my own vector3 implementation so that I can compile
this library as a separate dll.
- You should replace all "printf" by your own version log message.
[EDIT]==
Please, take the code on the wiki. Corrections will be applied on the wiki version.== [/EDIT]
I made several changes to the code found on the wiki.
http://www.ogre3d.org/wiki/index.php/OpenAL
[EDIT] == WIKIED == [/EDIT]
I would like to have the feedback of Van Stokes before updating the Wiki.
Because the code is fairly different.
Purposes :
- Adapted to the new OpenAL version
- Correct several bugs
- Removed useless code
- Add some tests
- Use more "java" like names
- and several minor changes.
Note :
- I didn't use Ogre links to be as independent as possible.
I have my own vector3 implementation so that I can compile
this library as a separate dll.
- You should replace all "printf" by your own version log message.
[EDIT]==
Please, take the code on the wiki. Corrections will be applied on the wiki version.== [/EDIT]
Code: Select all
#include <iostream>
#include "src/SoundManager.h"
int main()
{
std::cout << "Simple Sound Manager test application !" << std::endl;
SoundManager* soundMgr = SoundManager::createManager();
std::cout << soundMgr->listAvailableDevices();
soundMgr->init();
// careful : should not be used it doesn't use the resource limitation
//soundMgr->testSound( "test.wav" );
soundMgr->setAudioPath( ".\\" );
unsigned int audioId;
soundMgr->loadAudio( "test.wav", &audioId, false );
/*
// Set our LISTENER Location (i.e. the ears)
// The listener is what hears the sounds emitted by audio sources.
// Note: you only have ONE set of ears - i.e. there is only ONE listener.
soundMgr->setListenerPosition( mPlayerSceneNode->getWorldPosition(),
Ogre::Vector3::ZERO, mPlayerSceneNode->getOrientation() );
// Set the Audio SOURCE location/position AND by default PLAY the audio.
// Note how we reference the correct audio source by using 'mAudioSource'.
soundMgr->setSound( audioId, mSomeObjectSceneNode->getWorldPosition(),
Ogre::Vector3::ZERO, Ogre::Vector3::ZERO, 1000.0f, true, true, 1.0f );
*/
// Play an Audio source - force a restart from the begining of the buffer.
// That means, re-play the media file from the begining.
soundMgr->playAudio( audioId, true );
//Or else we risk to destroy the manager too quickly to here anything !
for (int i=0;i<20000; i++) {printf(".");};
soundMgr->playAudio( audioId, true );
for (int i=0;i<20000; i++) {printf(".");};
// Force an audio source to stop playing.
soundMgr->stopAudio( audioId );
// Release an audio source when we are done with it.
// This isn't required if you destruct the AudioEngine - as it cleans itself up.
// But, you *SHOULD* do this when, for example, your SceneObject is no longer
// in the scene for some reason. In other words, if you don't need this source
// anymore then free up the resource. Remember, you are limited in audio sources.
soundMgr->releaseAudio( audioId );
delete soundMgr;
return 0;
}
Code: Select all
/**
* SoundManager.h
*
* Original Code : Van Stokes, Jr. (http://www.EvilMasterMindsInc.com) - Aug 05
* Modified Code : Steven Gay - mec3@bluewin.ch - Septembre 2005
*
*
* Partial Documentation
* =====================
*
* Very simple SoundManager using OpenAl. For a more complete one,
* you should see OpenAL++ http://alpp.sourceforge.net/
*
* 1. Create the object from the class with createManager()
*
* 2. Call the init() function
*
* 3. Call the loadDefaultSounds() function to PRE-LOAD audio into the buffers.
* This is optional. Review the function to make changes that you need.
*
* 4. Set the Listener Location by calling setListenerPosition() function
* continually call this as your Listener (camera) position changes!
*
* 5. For each object that emits sound, call the loadSound() function.
* CAREFUL : The filename must be unique.
*
* 6. Optional : For each object you can set the all the parameters of the
* sound with setSound() or only the position, velocity and direction with
* setSoundPosition().
*
* 7. Call the playAudioSource() to play the sound at some event.
* This function will play the sound and then stop. It will NOT repeat playing.
* Use stopAudioSource() to stop a sound from playing if its still playing
*
* 8. When your object is done emitting sounds (when out of range for example)
* call releaseAudioSource().
* It is important to release your source when you are no longer going to
* need it because you are limited in the number of sources you can have.
*
* 9. If your objects moves (other than the listener/camera) then
* continually update the objects position by calling setSourcePosition().
*
******************************************************************************
*
* Additional informations :
*
* Ogg Vorbis - http://www.xiph.org/downloads/
* - http://www.illiminable.com/ogg/
* Flac - http://flac.sourceforge.net/features.html
* Theora - http://www.theora.org/
*
*
******************************************************************************
*
* TODO
*
* loadOGG()
* alSourcePause()
* bool stopAllAudio( void );
* bool pauseAudio( unsigned int audioID );
* bool pauseAllAudio( void );
* bool resumeAudio( unsigned int audioID );
* bool resumeAllAudio( void );
*
******************************************************************************/
#ifndef __SOUNDMANAGER_H__
#define __SOUNDMANAGER_H__
#include <stdio.h>
#include <string>
// Comment this line if you don't have the EAX 2.0 SDK installed
//#define _USEEAX
#ifdef _USEEAX
#include "eax.h"
#endif
#include <al/alctypes.h>
#include <al/altypes.h>
#include <al/alc.h>
#include <al/al.h>
#include <alut/alut.h>
#include "OgreVector3.h"
// Be very careful with these two parameters
// It is very dependant on the audio hardware your
// user is using. It you get too large, it may work
// on one persons system but not on another.
// TODO Write a fct testing the hardware !
#define MAX_AUDIO_BUFFERS 64
#define MAX_AUDIO_SOURCES 16
// Used to store sound filenames
#define MAX_FILENAME_LENGTH 40
using namespace Ogre;
class SoundManager
{
private:
// EAX related
bool isEAXPresent;
#ifdef _USEEAX
// EAX 2.0 GUIDs
const GUID DSPROPSETID_EAX20_ListenerProperties
= { 0x306a6a8, 0xb224, 0x11d2, { 0x99, 0xe5, 0x0, 0x0, 0xe8, 0xd8, 0xc7, 0x22 } };
const GUID DSPROPSETID_EAX20_BufferProperties
= { 0x306a6a7, 0xb224, 0x11d2, {0x99, 0xe5, 0x0, 0x0, 0xe8, 0xd8, 0xc7, 0x22 } };
EAXSet eaxSet; // EAXSet function, retrieved if EAX Extension is supported
EAXGet eaxGet; // EAXGet function, retrieved if EAX Extension is supported
#endif // _USEEAX
bool isInitialised;
ALCdevice* mSoundDevice;
ALCcontext* mSoundContext;
std::string mAudioPath;
bool isSoundOn;
ALfloat position[3];
ALfloat velocity[3];
ALfloat orientation[6];
// Needed because of hardware limitation
// Audio sources
unsigned int mAudioSourcesInUseCount;
unsigned int mAudioSources[ MAX_AUDIO_SOURCES ];
bool mAudioSourceInUse[ MAX_AUDIO_SOURCES ];
// Audio buffers
unsigned int mAudioBuffersInUseCount;
unsigned int mAudioBuffers[ MAX_AUDIO_BUFFERS ];
bool mAudioBufferInUse[ MAX_AUDIO_BUFFERS ];
char mAudioBufferFileName[ MAX_AUDIO_BUFFERS ][ MAX_FILENAME_LENGTH ];
// Function to check if the soundFile is already loaded into a buffer
int locateAudioBuffer( std::string filename );
int loadAudioInToSystem( std::string filename, bool loop );
bool loadWAV( std::string filename, ALuint pDestAudioBuffer );
bool loadOGG( std::string filename, ALuint pDestAudioBuffer );
// TODO bool loadAU( std::string filename, ALuint pDestAudioBuffer );
// Ogg Vorbis extension
bool bOggExtensionPresent;
public:
static SoundManager* mSoundManager;
SoundManager( void );
virtual ~SoundManager( void );
void SoundManager::selfDestruct( void );
static SoundManager* createManager( void );
static SoundManager* getSingletonPtr( void ) { return mSoundManager; };
bool init( void );
bool getIsSoundOn( void ) { return isSoundOn; };
void setAudioPath( char* path ) { mAudioPath = std::string( path ); };
bool checkALError( void );
bool checkALError( char* pMsg );
/** See http://www.openal.org/windows_enumeration.html for installing other
* devices. You should at least have "Generic Hardware".
*/
std::string listAvailableDevices( void );
// careful : testSound should not be used it doesn't use the resource limitation
void testSound( const char* wavFile );
// Aquire an Audio Source
// filename = pass in the sound file to play for this source (ex. "myfile.wav")
// audioId = returns the AudioSource identifier you will need for the PlayAudioSource();
bool loadAudio( std::string filename, unsigned int *audioId, bool loop );
bool releaseAudio( unsigned int audioID );
// deprecated
bool aquireAudioSource( char* file, unsigned int *audioId )
{ return loadAudio( std::string(file), audioId, false ); };
// Returns true if the audio is started from the beginning
// false if error or if already playing
bool playAudio( unsigned int audioId, bool forceRestart );
bool stopAudio( unsigned int audioID );
// TODO bool stopAllAudio( void );
// TODO bool pauseAudio( unsigned int audioID );
// TODO bool pauseAllAudio( void );
// TODO bool resumeAudio( unsigned int audioID );
// TODO bool resumeAllAudio( void );
bool setSoundPosition( unsigned int audioID, Vector3 position );
bool setSoundPosition( unsigned int audioID, Vector3 position,
Vector3 velocity, Vector3 direction );
bool setSound( unsigned int audioID, Vector3 position,
Vector3 velocity, Vector3 direction, float maxDistance,
bool playNow, bool forceRestart, float minGain );
bool setListenerPosition( Vector3 position, Vector3 velocity,
Quaternion orientation );
bool isOggExtensionPresent( void );
/**
* Preload audio files into the system.
* Not obligatory, the files can also be loaded on the fly.
*/
//TODO bool loadDefaultSounds( std::string filename );
};
#endif /*__SOUNDMANAGER_H__*/
Code: Select all
/**
* SoundManager.cpp
*
* Original Code : Van Stokes, Jr. (http://www.EvilMasterMindsInc.com) - Aug 05
* Modified Code : Steven Gay - mec3@bluewin.ch - Septembre 2005
*
*/
#include "SoundManager.h"
SoundManager* SoundManager::mSoundManager = NULL;
/****************************************************************************/
SoundManager::SoundManager( void )
{
mSoundManager = this;
isInitialised = false;
isSoundOn = false;
mSoundDevice = 0;
mSoundContext = 0;
mAudioPath = "";
// EAX related
isEAXPresent = false;
// Initial position of the listener
position[0] = 0.0;
position[1] = 0.0;
position[2] = 0.0;
// Initial velocity of the listener
velocity[0] = 0.0;
velocity[1] = 0.0;
velocity[2] = 0.0;
// Initial orientation of the listener = direction + direction up
orientation[0] = 0.0;
orientation[1] = 0.0;
orientation[2] = -1.0;
orientation[3] = 0.0;
orientation[4] = 1.0;
orientation[5] = 0.0;
// Needed because of hardware limitation
mAudioBuffersInUseCount = 0;
mAudioSourcesInUseCount = 0;
for ( int i=0; i < MAX_AUDIO_SOURCES; i++ )
{
mAudioSources[i] = 0;
mAudioSourceInUse[i] = false;
}
for ( int i=0; i < MAX_AUDIO_BUFFERS; i++ )
{
mAudioBuffers[i] = 0;
strcpy( mAudioBufferFileName[i], "--" );
mAudioBufferInUse[i] = false;
}
printf("SoudManager Created.\n");
}
/****************************************************************************/
SoundManager::~SoundManager( void )
{
// Delete the sources and buffers
alDeleteSources( MAX_AUDIO_SOURCES, mAudioSources );
alDeleteBuffers( MAX_AUDIO_BUFFERS, mAudioBuffers );
// Destroy the sound context and device
mSoundContext = alcGetCurrentContext();
mSoundDevice = alcGetContextsDevice( mSoundContext );
alcMakeContextCurrent( NULL );
alcDestroyContext( mSoundContext );
if ( mSoundDevice)
alcCloseDevice( mSoundDevice );
alutExit();
printf("SoudManager Destroyed.\n");
}
/****************************************************************************/
void SoundManager::selfDestruct( void )
{
if ( getSingletonPtr() ) delete getSingletonPtr();
}
/****************************************************************************/
SoundManager* SoundManager::createManager( void )
{
if (mSoundManager == 0)
mSoundManager = new SoundManager();
return mSoundManager;
}
/****************************************************************************/
bool SoundManager::init( void )
{
// It's an error to initialise twice OpenAl
if ( isInitialised ) return true;
// Open an audio device
mSoundDevice = alcOpenDevice( NULL ); // TODO ((ALubyte*) "DirectSound3D");
// mSoundDevice = alcOpenDevice( "DirectSound3D" );
// Check for errors
if ( !mSoundDevice )
{
printf( "SoundManager::init error : No sound device.\n");
return false;
}
mSoundContext = alcCreateContext( mSoundDevice, NULL );
// if ( checkAlError() || !mSoundContext ) // TODO seems not to work! why ?
if ( !mSoundContext )
{
printf( "SoundManager::init error : No sound context.\n");
return false;
}
// Make the context current and active
alcMakeContextCurrent( mSoundContext );
if ( checkALError( "Init()" ) )
{
printf( "SoundManager::init error : could not make sound context current and active.\n");
return false;
}
// Check for EAX 2.0 support and
// Retrieves function entry addresses to API ARB extensions, in this case,
// for the EAX extension. See Appendix 1 (Extensions) of
// http://www.openal.org/openal_webstf/specs/OpenAL1-1Spec_html/al11spec7.html
//
// TODO EAX fct not used anywhere in the code ... !!!
isEAXPresent = alIsExtensionPresent( "EAX2.0" );
if ( isEAXPresent )
{
printf( "EAX 2.0 Extension available\n" );
#ifdef _USEEAX
eaxSet = (EAXSet) alGetProcAddress( "EAXSet" );
if ( eaxSet == NULL )
isEAXPresent = false;
eaxGet = (EAXGet) alGetProcAddress( "EAXGet" );
if ( eaxGet == NULL )
isEAXPresent = false;
if ( !isEAXPresent )
checkALError( "Failed to get the EAX extension functions adresses.\n" );
#else
isEAXPresent = false;
printf( "... but not used.\n" );
#endif // _USEEAX
}
// Test if Ogg Vorbis extension is present
isOggExtensionPresent();
// Create the Audio Buffers
alGenBuffers( MAX_AUDIO_BUFFERS, mAudioBuffers );
if (checkALError("init::alGenBuffers:") )
return false;
// Generate Sources
alGenSources( MAX_AUDIO_SOURCES, mAudioSources );
if (checkALError( "init::alGenSources :") )
return false;
// Setup the initial listener parameters
// -> location
alListenerfv( AL_POSITION, position );
// -> velocity
alListenerfv( AL_VELOCITY, velocity );
// -> orientation
alListenerfv( AL_ORIENTATION, orientation );
// Gain
alListenerf( AL_GAIN, 1.0 );
// Initialise Doppler
alDopplerFactor( 1.0 ); // 1.2 = exaggerate the pitch shift by 20%
alDopplerVelocity( 343.0f ); // m/s this may need to be scaled at some point
// Ok
isInitialised = true;
isSoundOn = true;
printf( "SoundManager initialised.\n\n");
return true;
}
/****************************************************************************/
bool SoundManager::checkALError( void )
{
ALenum errCode;
if ( ( errCode = alGetError() ) != AL_NO_ERROR )
{
std::string err = "ERROR SoundManager:: ";
err += (char*) alGetString( errCode );
printf( "%s\n", err.c_str());
return true;
}
return false;
}
/****************************************************************************/
std::string SoundManager::listAvailableDevices( void )
{
std::string str = "Sound Devices available : ";
if ( alcIsExtensionPresent( NULL, "ALC_ENUMERATION_EXT" ) == AL_TRUE )
{
str = "List of Devices : ";
str += (char*) alcGetString( NULL, ALC_DEVICE_SPECIFIER );
str += "\n";
}
else
str += " ... eunmeration error.\n";
return str;
}
/****************************************************************************/
bool SoundManager::checkALError( char* pMsg )
{
ALenum error = 0;
if ( (error = alGetError()) == AL_NO_ERROR )
return false;
char mStr[256];
switch ( error )
{
case AL_INVALID_NAME:
sprintf(mStr,"ERROR SoundManager::%s Invalid Name", pMsg);
break;
case AL_INVALID_ENUM:
sprintf(mStr,"ERROR SoundManager::%s Invalid Enum", pMsg);
break;
case AL_INVALID_VALUE:
sprintf(mStr,"ERROR SoundManager::%s Invalid Value", pMsg);
break;
case AL_INVALID_OPERATION:
sprintf(mStr,"ERROR SoundManager::%s Invalid Operation", pMsg);
break;
case AL_OUT_OF_MEMORY:
sprintf(mStr,"ERROR SoundManager::%s Out Of Memory", pMsg);
break;
default:
sprintf(mStr,"ERROR SoundManager::%s Unknown error (%i) case in testALError()", pMsg, error);
break;
};
printf( "%s\n", mStr );
return true;
}
/*****************************************************************************/
void SoundManager::testSound( const char* wavFile )
{
ALuint buffer;
ALuint source;
ALenum format;
ALsizei size;
ALvoid* data;
ALsizei freq;
ALboolean loop;
alGenBuffers( 1, &buffer );
if ( checkALError( "testSound()" ) )
return;
// This is the same for alutLoadWAVMemory
#ifndef MACINTOSH_AL
alutLoadWAVFile( (ALbyte*) wavFile, &format, &data, &size, &freq, &loop );
#else
alutLoadWAVFile( (ALbyte*) wavFile, &format, &data, &size, &freq );
#endif
alBufferData( buffer, format, data, size, freq );
alutUnloadWAV( format, data, size, freq );
alGenSources( 1, &source );
alSourcei( source, AL_BUFFER, buffer );
alSourcef( source, AL_PITCH, 1.0f );
alSourcef( source, AL_GAIN, 1.0f );
#ifndef MACINTOSH_AL
alSourcei( source, AL_LOOPING, loop );
#else
alSourcei( source, AL_LOOPING, false ); // TODO ! But how to get from file?
#endif
alSourcePlay( source );
//Or else we risk to destroy the manager too quickly to here anything !
for (int i=0;i<50000; i++) {printf(".");};
}
// Attempts to aquire an empty audio source and assign it back to the caller
// via AudioSourceID. This will lock the source
/*****************************************************************************/
bool SoundManager::loadAudio( std::string filename, unsigned int *audioId,
bool loop )
{
if ( filename.empty() || filename.length() > MAX_FILENAME_LENGTH )
return false;
if ( mAudioSourcesInUseCount == MAX_AUDIO_SOURCES )
return false; // out of Audio Source slots!
int bufferID = -1; // Identity of the Sound Buffer to use
int sourceID = -1; // Identity of the Source Buffer to use
alGetError(); // Clear Error Code
// Check and see if the pSoundFile is already loaded into a buffer
bufferID = locateAudioBuffer( filename );
if ( bufferID < 0 )
{
// The sound file isn't loaded in a buffer, lets attempt to load it on the fly
bufferID = loadAudioInToSystem( filename, loop );
if ( bufferID < 0 ) return false; // failed!
}
// If you are here, the sound the requester wants to reference is in a buffer.
// Now, we need to find a free Audio Source slot in the sound system
sourceID = 0;
while ( mAudioSourceInUse[ sourceID ] == true ) sourceID++;
// When you are here, 'mSourceID' now represents a free Audio Source slot
// The free slot may not be at the end of the array but in the middle of it.
*audioId = sourceID; // return the Audio Source ID to the caller
mAudioSourceInUse[ sourceID ] = true; // mark this Source slot as in use
mAudioSourcesInUseCount++; // bump the 'in use' counter
// Now inform OpenAL of the sound assignment and attach the audio buffer
// to the audio source
alSourcei( mAudioSources[sourceID], AL_BUFFER, mAudioBuffers[bufferID] );
// Steven : Not in the original code !!!!!
alSourcei( mAudioSources[sourceID], AL_LOOPING, loop );
if ( checkALError( "loadSource()::alSourcei" ) )
return false;
return true;
}
// Function to check and see if the pSoundFile is already loaded into a buffer
/*****************************************************************************/
int SoundManager::locateAudioBuffer( std::string filename )
{
for ( unsigned int b = 0; b < MAX_AUDIO_BUFFERS; b++ )
{
if ( filename == mAudioBufferFileName[b] ) return (int) b; // TODO Careful : converts unsigned to int!
}
return -1; // not found
}
// Function to load a sound file into an AudioBuffer
/*****************************************************************************/
int SoundManager::loadAudioInToSystem( std::string filename, bool loop )
{
if ( filename.empty() )
return -1;
// Make sure we have audio buffers available
if ( mAudioBuffersInUseCount == MAX_AUDIO_BUFFERS ) return -1;
// Find a free Audio Buffer slot
int bufferID = 0; // Identity of the Sound Buffer to use
while ( mAudioBufferInUse[ bufferID ] == true ) bufferID++;
// load .wav, .ogg or .au
if ( filename.find( ".wav", 0 ) != std::string::npos )
{
printf(" ---> found Wav\n");
// When you are here, bufferID now represents a free Audio Buffer slot
// Attempt to load the SoundFile into the buffer
if ( !loadWAV( filename, mAudioBuffers[ bufferID ] ), loop ) return -1;
}
else if ( filename.find( ".ogg", 0 ) != std::string::npos )
{
printf(" ---> found ogg\n");
// TODO if ( !loadOGG( filename, mAudioBuffers[mBufferID]), loop ) return -1;
}
else if ( filename.find( ".au", 0 ) != std::string::npos )
{
printf(" ---> found au\n");
// TODO if ( !loadAU( filename, mAudioBuffers[mBufferID]), loop ) return -1;
}
// Successful load of the file into the Audio Buffer.
mAudioBufferInUse[ bufferID ] = true; // Buffer now in use
strcpy( mAudioBufferFileName[ bufferID ], filename.c_str() ); // save the file descriptor
mAudioBuffersInUseCount++; // bump the 'in use' counter
return bufferID;
}
// Function to load a wave file and assigned it to a buffer
/****************************************************************************/
bool SoundManager::loadWAV( std::string filename, ALuint pDestAudioBuffer )
{
ALenum format; //for the buffer format
ALsizei size; //the bit depth
ALsizei freq; //for the frequency of the buffer
ALboolean loop; //looped
ALvoid* data; //data for the buffer
std::string mFullPath = mAudioPath;
alGetError(); // Clear Error Code
// Load in the WAV file from disk
//mFullPath += "\\";
mFullPath += filename;
#ifndef MACINTOSH_AL
alutLoadWAVFile( (ALbyte*)mFullPath.c_str(), &format, &data, &size, &freq, &loop);
#else
alutLoadWAVFile( (ALbyte*)mFullPath.c_str(), &format, &data, &size, &freq);
#endif
if ( checkALError("loadWAV::alutLoadWAVFile: ") )
return false;
// Copy the new WAV data into the buffer
alBufferData(pDestAudioBuffer, format, data, size, freq);
if ( checkALError("loadWAV::alBufferData: ") )
return false;
// Unload the WAV file
alutUnloadWAV(format, data, size, freq);
if ( checkALError("loadWAV::alutUnloadWAV: ") )
return false;
return true;
}
/****************************************************************************/
bool SoundManager::playAudio( unsigned int audioID, bool forceRestart )
{
// Make sure the audio source ident is valid and usable
if ( audioID >= MAX_AUDIO_SOURCES || !mAudioSourceInUse[audioID])
return false;
int sourceAudioState = 0;
alGetError();
// Are we currently playing the audio source?
alGetSourcei( mAudioSources[audioID], AL_SOURCE_STATE, &sourceAudioState );
if ( sourceAudioState == AL_PLAYING )
{
if ( forceRestart )
stopAudio( audioID );
else
return false; // Not forced, so we don't do anything
}
alSourcePlay( mAudioSources[ audioID ] );
if ( checkALError( "playAudio::alSourcePlay: ") )
return false;
return true;
}
/****************************************************************************/
bool SoundManager::stopAudio( unsigned int audioID )
{
// Make sure the audio source ident is valid and usable
if ( audioID >= MAX_AUDIO_SOURCES || !mAudioSourceInUse[audioID] )
return false;
alGetError();
alSourceStop( mAudioSources[audioID] );
if ( checkALError( "stopAudio::alSourceStop ") )
return false;
return true;
}
/****************************************************************************/
bool SoundManager::releaseAudio( unsigned int audioID )
{
if ( audioID >= MAX_AUDIO_SOURCES )
return false;
alSourceStop( mAudioSources[audioID] );
mAudioSourceInUse[ audioID ] = false;
mAudioSourcesInUseCount--;
return true;
}
/****************************************************************************/
bool SoundManager::setSound( unsigned int audioID, Vector3 position,
Vector3 velocity, Vector3 direction, float maxDistance,
bool playNow, bool forceRestart, float minGain )
{
if ( audioID >= MAX_AUDIO_SOURCES || !mAudioSourceInUse[ audioID ] )
return false;
// Set the position
ALfloat pos[] = { position.x, position.y, position.z };
alSourcefv( mAudioSources[ audioID ], AL_POSITION, pos );
if ( checkALError( "setSound::alSourcefv:AL_POSITION" ) )
return false;
// Set the veclocity
ALfloat vel[] = { velocity.x, velocity.y, velocity.z };
alSourcefv( mAudioSources[ audioID ], AL_VELOCITY, vel );
if ( checkALError( "setSound::alSourcefv:AL_VELOCITY" ) )
return false;
// Set the direction
ALfloat dir[] = { velocity.x, velocity.y, velocity.z };
alSourcefv( mAudioSources[ audioID ], AL_DIRECTION, dir );
if ( checkALError( "setSound::alSourcefv:AL_DIRECTION" ) )
return false;
// Set the max audible distance
alSourcef( mAudioSources[ audioID ], AL_MAX_DISTANCE, maxDistance );
// Set the MIN_GAIN ( IMPORTANT - if not set, nothing audible! )
alSourcef( mAudioSources[ audioID ], AL_MIN_GAIN, minGain );
// Set the max gain
alSourcef( mAudioSources[ audioID ], AL_MAX_GAIN, 1.0f ); // TODO as parameter ? global ?
// Set the rollof factor
alSourcef( mAudioSources[ audioID ], AL_ROLLOFF_FACTOR, 1.0f ); // TODO as parameter ?
// Do we play the sound now ?
if ( playNow ) return playAudio( audioID, forceRestart ); // TODO bof... not in this fct
return true;
}
/****************************************************************************/
bool SoundManager::setSoundPosition( unsigned int audioID, Vector3 position )
{
if ( audioID >= MAX_AUDIO_SOURCES || !mAudioSourceInUse[ audioID ] )
return false;
// Set the position
ALfloat pos[] = { position.x, position.y, position.z };
alSourcefv( mAudioSources[ audioID ], AL_POSITION, pos );
if ( checkALError( "setSound::alSourcefv:AL_POSITION" ) )
return false;
return true;
}
/****************************************************************************/
bool SoundManager::setSoundPosition( unsigned int audioID, Vector3 position,
Vector3 velocity, Vector3 direction )
{
if ( audioID >= MAX_AUDIO_SOURCES || !mAudioSourceInUse[ audioID ] )
return false;
// Set the position
ALfloat pos[] = { position.x, position.y, position.z };
alSourcefv( mAudioSources[ audioID ], AL_POSITION, pos );
if ( checkALError( "setSound::alSourcefv:AL_POSITION" ) )
return false;
// Set the veclocity
ALfloat vel[] = { velocity.x, velocity.y, velocity.z };
alSourcefv( mAudioSources[ audioID ], AL_VELOCITY, vel );
if ( checkALError( "setSound::alSourcefv:AL_VELOCITY" ) )
return false;
// Set the direction
ALfloat dir[] = { velocity.x, velocity.y, velocity.z };
alSourcefv( mAudioSources[ audioID ], AL_DIRECTION, dir );
if ( checkALError( "setSound::alSourcefv:AL_DIRECTION" ) )
return false;
return true;
}
/****************************************************************************/
bool SoundManager::setListenerPosition( Vector3 position, Vector3 velocity,
Quaternion orientation )
{
Vector3 axis;
// Set the position
ALfloat pos[] = { position.x, position.y, position.z };
alListenerfv( AL_POSITION, pos );
if ( checkALError( "setListenerPosition::alListenerfv:AL_POSITION" ) )
return false;
// Set the veclocity
ALfloat vel[] = { velocity.x, velocity.y, velocity.z };
alListenerfv( AL_VELOCITY, vel );
if ( checkALError( "setListenerPosition::alListenerfv:AL_VELOCITY" ) )
return false;
// Orientation of the listener : look at then look up
axis = Vector3::ZERO;
axis.x = orientation.getYaw().valueRadians();
axis.y = orientation.getPitch().valueRadians();
axis.z = orientation.getRoll().valueRadians();
// Set the direction
ALfloat dir[] = { axis.x, axis.y, axis.z };
alListenerfv( AL_ORIENTATION, dir );
if ( checkALError( "setListenerPosition::alListenerfv:AL_DIRECTION" ) )
return false;
// TODO as parameters ?
alListenerf( AL_MAX_DISTANCE, 10000.0f );
alListenerf( AL_MIN_GAIN, 0.0f );
alListenerf( AL_MAX_GAIN, 1.0f );
alListenerf( AL_GAIN, 1.0f );
return true;
}
/****************************************************************************/
bool SoundManager::isOggExtensionPresent( void )
{
if ( alIsExtensionPresent( "AL_EXT_vorbis" ) != AL_TRUE )
{
printf( "ERROR: SoundManager::isOggExtensionPresent : Ogg Vorbis extension not availablee!\n" );
bOggExtensionPresent = false;
return false;
}
return true;
}
// Function to load a wave file and assigned it to a buffer
// This code was taken from the plugin found on this forum :
// http://www.ogre3d.org/phpBB2/viewtopic.php?t=7234
//
// TODO I didn't integrate it fow now .. because I don't need it now :-)
//
/****************************************************************************/
bool SoundManager::loadOGG( std::string filename, ALuint pDestAudioBuffer )
{
if ( !bOggExtensionPresent )
{
printf( "SoundManager::loadOgg() : OGG extension not present... useless to load an ogg audio!\n");
return false;
}
printf( " TODO SoundManager::loadOgg() : not implemented.\n" );
/*
ALbyte *data;
ALsizei freq = 0;
void *ovdata;
unsigned int g_ovSize;
ALuint tempBuffers[4];
alGenSources(1, &mSourceID);
if ( checkALError() ) return false;
alGenBuffers( 4, tempBuffers ); // 4 ??
alSourceStop( mSourceID );
if ( checkALError() ) return false;
alSourcei( mSourceID, AL_BUFFER, 0 );
FILE *fp = fopen ( filename.c_str(), "rb" );
if ( fp == NULL )
{
printf( "Failed to open %d\n", filename );
retrun false;
}
alGetError();
struct stat sbuf;
if (stat( filename.c_str(), %sbuf) != -1)
{
g_ovSize = sbuf.st_size;
ovdata = malloc( g_ovSize );
}
int actual;
data = (ALbyte*) malloc((g_ovSize / 4) + 1));
if (data != 0)
{
for (int i=0; i<4; i++)
{
actual = fread(data, 1, ((g_ovSize / 4) + 1), fp);
// #define AL_FORMAT_VORBIS_EXT 0x10003
alBufferData( tempBuffers[i], AL_FORMAT_VORBIS_EXT, data, actual, 0);
}
alSourceQueueBuffers( mSourceID, 4, tempBuffers );
alSourcef( mSourceID, AL_GAIN, 1.0f );
if ( checkALError() ) return false;
free( (void*) data);
}
else
{
printf( "ERROR: SoundManager:loadOgg() failed memory allocation.\n");
}
fclose( fp );
isVorbis = true; // !!! TODO this should be used in
// an update() fct if the Vorbis is looped !
*/
return true;
}
Last edited by steven on Mon Oct 17, 2005 8:43 pm, edited 3 times in total.
-
- Hobgoblin
- Posts: 512
- Joined: Fri Nov 19, 2004 3:56 am
Go for it! Make the changes to the Wiki. It was put there for this community and if improvements and corrections are made please make them on the wiki!
I haven't updated our code in sometime and I haven't downloaded the new lib/api. I thought I removed all of our defs so that it would work out of the bag. I guess I missed a few.
I haven't updated our code in sometime and I haven't downloaded the new lib/api. I thought I removed all of our defs so that it would work out of the bag. I guess I missed a few.
-
- Halfling
- Posts: 59
- Joined: Fri Jul 22, 2005 3:35 pm
- Location: Ukraine
- x 1
Code: Select all
// Set the max gain
alSourcef( mAudioSources[ audioID ], AL_MIN_GAIN, 5.0f );
OpenAL1-1Spec.pdf says:
AL_MAX_GAIN - [0.0f, 1.0f]
Maybe this:
Code: Select all
// Set the max gain
alSourcef( mAudioSources[ audioID ], AL_MAX_GAIN, 1.0f );
-
- Gnoll
- Posts: 657
- Joined: Mon Feb 28, 2005 1:53 pm
- Location: Australia - Canberra (ex - Switzerland - Geneva)
I think you are right. I will make the edits.Alexis wrote: Maybe this:Code: Select all
// Set the max gain alSourcef( mAudioSources[ audioID ], AL_MAX_GAIN, 1.0f );
I didn't change the code from the original code because the gain CAN be higher than 1.0f : http://www.openal.org/openal_webstf/spe ... spec4.html
ThanksAL_GAIN larger than 1 (amplification) is permitted for source and listener. However, the implementation is free to clamp the total gain (effective gain per source times listener gain) to 1 to prevent overflow.
-
- Halfling
- Posts: 59
- Joined: Fri Jul 22, 2005 3:35 pm
- Location: Ukraine
- x 1
As I have understood there are at least three different gains.
I am currently trying to adjust this example to my needs and can not figure out what distance model is used here. I did not find any call of function
- AL_GAIN ---------- Any except NaN
AL_MIN_GAIN ----- [0.0f, 1.0f]
AL_MAX_GAIN ---- [0.0f, 1.0f]
I am currently trying to adjust this example to my needs and can not figure out what distance model is used here. I did not find any call of function
Code: Select all
void alDistanceModel(ALenum modelName);
-
- Gnoll
- Posts: 657
- Joined: Mon Feb 28, 2005 1:53 pm
- Location: Australia - Canberra (ex - Switzerland - Geneva)
The default model I guessAlexis wrote: I am currently trying to adjust this example to my needs and can not figure out what distance model is used here. I did not find any call of functionCode: Select all
void alDistanceModel(ALenum modelName);

As learning OpenAl is not on my priority list, I just adapted the original code to the new api and corrected the most obvious bugs.
I needed something very basic : make a sound when an explosion occurs. Hence my actual need is ... very basic.
Feel free to add any improvements to the code (with a small documentation ).

-
- Halfling
- Posts: 59
- Joined: Fri Jul 22, 2005 3:35 pm
- Location: Ukraine
- x 1
I am experimenting with this example.
I have installed a sound source in (0,0,0) and linked listeneer to a camera.
And when I'm flying around the sound it seems to be ok - near the source the sound is louder, when moving away it becomes lower. When I'm moving left - sound is in the right speaker. So it seems to be all right.
BUT. Sound is clamping at some distance - maybe AL_MAX_DISTANCE parameter works. But I can not change this parameter.
First inexplicable experiment:
Set listener to (0,0,0).
Set sound to (0,0,0).
Call this function every frame
I think that I have to hear the sound with gain 1.0 all the time.
But I hear sound that rises and falls by sine law.
Can anybody explain it?
First inexplicable experiment:
I have installed a sound source in (0,0,0) and linked listeneer to a camera.
And when I'm flying around the sound it seems to be ok - near the source the sound is louder, when moving away it becomes lower. When I'm moving left - sound is in the right speaker. So it seems to be all right.
BUT. Sound is clamping at some distance - maybe AL_MAX_DISTANCE parameter works. But I can not change this parameter.
First inexplicable experiment:
Set listener to (0,0,0).
Set sound to (0,0,0).
Call this function every frame
Code: Select all
void SoundManager::OnTimer(Real dTime)
{
static double t = 0;
t += dTime;
alSourcef( mAudioSources[ m_last_sound_id ], AL_MIN_GAIN, fabs(1.0 + sin(t))/2.0);
}
But I hear sound that rises and falls by sine law.
Can anybody explain it?
First inexplicable experiment:
Code: Select all
void SoundManager::OnTimer(Real dTime)
{
static double t = 0;
t += dTime;
// only this line do changes
alSourcef( mAudioSources[ m_last_sound_id ], AL_MIN_GAIN, fabs(1.0 + sin(t))/2.0);
// this lines have no effect whereever listener is
alDistanceModel(AL_NONE);
alSourcef( mAudioSources[ m_last_sound_id ], AL_MAX_DISTANCE , fabs(sin(t))*1000.0);
alSourcef( mAudioSources[ m_last_sound_id ], AL_REFERENCE_DISTANCE, fabs(1.0 + sin(t))*100.0);
alSourcef( mAudioSources[ m_last_sound_id ], AL_ROLLOFF_FACTOR, fabs(1.0 + sin(t))*100.0);
}
-
- Gnoblar
- Posts: 4
- Joined: Mon Oct 17, 2005 7:00 pm
I've been trying out the improved Wiki code posted here earlier.
It works for me except for these bugs:
Thanks.
It works for me except for these bugs:
Could anyone please help me out?error C2664: 'alIsExtensionPresent' : cannot convert parameter 1 from 'const char [7]' to 'const ALubyte *'
error C2664: 'alcIsExtensionPresent' : cannot convert parameter 2 from 'const char [20]' to 'const ALCubyte *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2664: 'alIsExtensionPresent' : cannot convert parameter 1 from 'const char [14]' to 'const ALubyte *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Thanks.
-
- Gnoll
- Posts: 657
- Joined: Mon Feb 28, 2005 1:53 pm
- Location: Australia - Canberra (ex - Switzerland - Geneva)
Please, take the code on the wiki it contains slight corrections. But not for your problem.
As the bugs mention it you can try to cast the paramter to the type mentioned. Something like :
and/or
However, the bugs could come from the library version you are using.
I wonder if you are not trying to compile against OpenAL 1.0 because the wiki code is writen for OpenAL 1.1.
OpenAl 1.1 is work in progress so if you want to use 1.0 you will need to make a few change in the wiki code.
Hope it helps.
As the bugs mention it you can try to cast the paramter to the type mentioned. Something like :
Code: Select all
isEAXPresent = alIsExtensionPresent( (const ALubyte*) ("EAX2.0" ) );
Code: Select all
if( alcIsExtensionPresent( NULL, reinterpret_cast<const ALubyte*> ("ALC_ENUMERATION_EXT") ) == AL_TRUE )
I wonder if you are not trying to compile against OpenAL 1.0 because the wiki code is writen for OpenAL 1.1.
OpenAl 1.1 is work in progress so if you want to use 1.0 you will need to make a few change in the wiki code.
Hope it helps.
-
- Gnoblar
- Posts: 4
- Joined: Mon Oct 17, 2005 7:00 pm
-
- Gnoblar
- Posts: 4
- Joined: Mon Oct 17, 2005 7:00 pm
Ok, so i took OpenAL 1.1, made sure everything was in order(Linker->libs, VC++ dirs and so on) and then took the code from the wiki.
Now I only get 1 error:
Demo error PRJ0019: A tool returned an error code from "Copying exe to samples bin directory ..."
which kinda leaves me dumbfounded.
Thx for the support.
Now I only get 1 error:
Demo error PRJ0019: A tool returned an error code from "Copying exe to samples bin directory ..."
which kinda leaves me dumbfounded.
Thx for the support.
-
- Gnoll
- Posts: 657
- Joined: Mon Feb 28, 2005 1:53 pm
- Location: Australia - Canberra (ex - Switzerland - Geneva)
-
- Gnome
- Posts: 363
- Joined: Wed Mar 23, 2005 11:05 am
- Location: Chisinau/Moldova
-
- Gnoblar
- Posts: 7
- Joined: Thu Oct 27, 2005 2:03 am
bit of a problem
Hi, after some initial trouble with openal and the SoundManager, I managed to get it compiled and linked fine, but when I run the exectuable it gives me the error
I've tried with the 1.1 SDK from the creative site, and the CVS, and I get the same problems each time. Now, what I did to get to this stage is create a simple app that consists of nothing more than the SoundManager files from the Wiki article, and it compiles and links without any trouble.
I've had to comment out #include <al/alctypes.h> and #include <al/altypes.h>, because neither header exists in either release (though the Mac folder in the CVS release has both headers).
I've been searching the web for a fix to the problem but I haven't been able to figure it out yet. If anyone has a suggestion I'd appreciate it.
Thanks in advance for any help
'OpenAL_Test.exe': Loaded 'C:\!!OgreStuff\!!Projects\OpenAL_Test\Release\OpenAL_Test.exe', Symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\mscoree.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\!!OgreStuff\!!Projects\OpenAL_Test\Release\OgreMain.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\!!OgreStuff\!!Projects\OpenAL_Test\Release\zlib1.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\msvcp71.dll', Symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\msvcr71.dll', Symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\!!OgreStuff\!!Projects\OpenAL_Test\Release\devil.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\!!OgreStuff\!!Projects\OpenAL_Test\Release\ilu.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\!!OgreStuff\!!Projects\OpenAL_Test\Release\OpenAL32.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\Syncor11.dll', Symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorwks.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\fusion.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\assembly\NativeImages1_v1.1.4322\mscorlib\1.0.5000.0__b77a5c561934e089_4635d2e2\mscorlib.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorsn.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorjit.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\apphelp.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\diasymreader.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
The thread 'Win32 Thread' (0xa9c) has exited with code 0 (0x0).
'OpenAL_Test.exe': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'OpenAL_Test.exe': Loaded 'C:\!!OgreStuff\!!Projects\OpenAL_Test\Release\OpenAL_Test.exe', Symbols loaded.
An unhandled exception of type 'System.TypeLoadException' occurred in OpenAL_Test.exe
Additional information: Could not load type ALCdevice_struct from assembly OpenAL_Test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
The thread 'Win32 Thread' (0x254) has exited with code -532459699 (0xe0434f4d).
The program '[412] OpenAL_Test.exe' has exited with code 0 (0x0).
The program '[412] OpenAL_Test.exe: Native' has exited with code 0 (0x0).
I've tried with the 1.1 SDK from the creative site, and the CVS, and I get the same problems each time. Now, what I did to get to this stage is create a simple app that consists of nothing more than the SoundManager files from the Wiki article, and it compiles and links without any trouble.
I've had to comment out #include <al/alctypes.h> and #include <al/altypes.h>, because neither header exists in either release (though the Mac folder in the CVS release has both headers).
I've been searching the web for a fix to the problem but I haven't been able to figure it out yet. If anyone has a suggestion I'd appreciate it.
Thanks in advance for any help
-
- Gnoll
- Posts: 657
- Joined: Mon Feb 28, 2005 1:53 pm
- Location: Australia - Canberra (ex - Switzerland - Geneva)
Which exe ? The main.cpp from the wiki ? If not, can you give some of the code.... when I run the exectuable...
Regarding the 1.1 SDK from creative, it is very recent (about 1-2 weeks).
And yes they changed the path for alc.h, al.h and alut.h.
I tested the code with the new sdk and it worked fine for me.
I can only suggest that you use a debugger and/or comment out the code in the main.cpp to determine the offending part.
-
- Gnoblar
- Posts: 7
- Joined: Thu Oct 27, 2005 2:03 am
Yes, I ran the compiled version of the code from the wiki. It's all the same except i've had to comment out
When I debug the program, it throws up the error whenever it reaches soundMgr->init();
Inside the dissassembly window, each line will run fine until it reaches the line 000000c1 nop
because those files didn't exist in the SDk.#include <al/alctypes.h>
#include <al/altypes.h>
When I debug the program, it throws up the error whenever it reaches soundMgr->init();
Inside the dissassembly window, each line will run fine until it reaches the line 000000c1 nop
I've got a printf line at the beginning of the init function before any other code in it, except the program crashes without writing the line to screen.000000aa jmp eax
000000ac lea ecx,[ebp+FFFFFF78h]
000000b2 call dword ptr ds:[00BB7E44h]
soundMgr->init();
000000b8 mov ecx,dword ptr [ebp-18h]
000000bb call dword ptr ds:[00BB7DF4h]
000000c1 nop
soundMgr->setAudioPath( (char*) ".\\" );
000000c2 lea ecx,[ebp-6Ch]
-
- Orc
- Posts: 419
- Joined: Thu Apr 07, 2005 2:11 pm
- Location: UK
Hello,
I am trying to integrate some sound in Ogre using openAL. I managed to compile the class from the WIKI. I have some problems though when I try to use it. He is what I have in the log:
SoudManager Created.
List of Devices : Generic Hardware
EAX 2.0 Extension available
... but not used
ERROR: SoundManager::isOggExtensionPresent : Ogg Vorbis extension not available !
SoundManager initialised
---> found wav
ERROR SoundManager::loadWAV::alBufferData: Invalid Value
I tried with different wave files but i always got the same problem.
Any help is welcome!
Thank you
I am trying to integrate some sound in Ogre using openAL. I managed to compile the class from the WIKI. I have some problems though when I try to use it. He is what I have in the log:
SoudManager Created.
List of Devices : Generic Hardware
EAX 2.0 Extension available
... but not used
ERROR: SoundManager::isOggExtensionPresent : Ogg Vorbis extension not available !
SoundManager initialised
---> found wav
ERROR SoundManager::loadWAV::alBufferData: Invalid Value
I tried with different wave files but i always got the same problem.
Any help is welcome!
Thank you
-
- Orc
- Posts: 419
- Joined: Thu Apr 07, 2005 2:11 pm
- Location: UK
-
- Gnoll
- Posts: 657
- Joined: Mon Feb 28, 2005 1:53 pm
- Location: Australia - Canberra (ex - Switzerland - Geneva)
-
- Gnoblar
- Posts: 7
- Joined: Thu Oct 27, 2005 2:03 am
Solved, not per se
I switched to Fmod
I'm on xp with vs.net 7.1
I did try again just then though,. I started a new win32 console app, and used the files straight from wiki. Linked everything and after commenting some stuff out, it works fine now. Essentially I did the same thing as before, but last time i'm not sure whether I'd created the project as a console app or as a regular app.
I commented out alctypes.h and altypes.h again.
I changed
if ( loadAudioInToSystem(key, false) < 0 )
to
if ( loadAudioInToSystem(key) < 0 )
because it said if loadAudioInToSystem only takes one parameter
I also changed
and now it all works fine.
Thanks for your help everyone. Chances are it wasn't working cause I'm a bit of a dumbarse sometimes, so cheers.
I switched to Fmod
I'm on xp with vs.net 7.1
I did try again just then though,. I started a new win32 console app, and used the files straight from wiki. Linked everything and after commenting some stuff out, it works fine now. Essentially I did the same thing as before, but last time i'm not sure whether I'd created the project as a console app or as a regular app.
I commented out alctypes.h and altypes.h again.
I changed
if ( loadAudioInToSystem(key, false) < 0 )
to
if ( loadAudioInToSystem(key) < 0 )
because it said if loadAudioInToSystem only takes one parameter
I also changed
to comment out everything but the ogre includes, because it couldn't find Vector3.h// Modify this as you need.
//#ifdef OGRE
#include "OgreVector3.h"
#include "OgreQuaternion.h"
using namespace Ogre;
//#else
// #include "Vector3.h"
// using namespace gameengine::utilities;
//#endif
and now it all works fine.
Thanks for your help everyone. Chances are it wasn't working cause I'm a bit of a dumbarse sometimes, so cheers.
-
- Gnoblar
- Posts: 2
- Joined: Thu Nov 10, 2005 6:22 am
OpenAL sound manager run time issue
Using OpenAL 1.1, VC++ .NET 2003, WinXP Pro, and by commenting out the lines
//#include <alctypes.h>
//#include <altypes.h>
and changing
if ( loadAudioInToSystem(key, false) < 0 )
to
if ( loadAudioInToSystem(key) < 0 )
like other people on this thread, I get the code to compile. But when I try to initialize the SoundManager, I get the same error that ClarkCulver got above:
As far as I can tell, ACLdevice_struct is not getting defined for some reason. However, I can't figure out why this is the case. I am linking both ALut.lib and OpenAL32.lib into the project, in that order. What is the problem here?
//#include <alctypes.h>
//#include <altypes.h>
and changing
if ( loadAudioInToSystem(key, false) < 0 )
to
if ( loadAudioInToSystem(key) < 0 )
like other people on this thread, I get the code to compile. But when I try to initialize the SoundManager, I get the same error that ClarkCulver got above:
Code: Select all
An unhandled exception of type 'System.TypeLoadException' occurred in OpenAL_Test.exe
Additional information: Could not load type ALCdevice_struct from assembly OpenAL_Test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.