Create Sound


08-11-2007 12:36:07

Hey Sorry im back :<

I've created sounds for all my bugs<vechiles> in my game, though i get a crash when i try create another instance of an already created sound.

so like i create a grasshopper motor noise because player 1 wants to be a grashopper, then i try and create another grass hopper noise because player 2 wants to be a grasshopper too, and thats when it crashes.

My Code:

mBugSounds[itrBugSoundStart->first] = OgreAL::SoundManager::getSingletonPtr()->createSound(itrBugSoundStart->first + mUniqueID, itrBugSoundStart->second, true);

Crashes in Here:

Sound::Sound(BufferRef buffer, const Ogre::String& name, const Ogre::String& fileName, bool loop)

on this line of code

mBuffers[0] = buffer;

is mBuffers an array? seems to be just a typedef int.

p.s Cant wait to show you guys some of the sound tracks we have, they are pretty awesome, made by my artist who has created music for television commercials like Lexus in Australia.




08-11-2007 21:45:06

You are absolutely right!! Sorry about that. The mBuffers variable wasn't being initialized in that case. I also have to tweak the clean up o account fot this case. These fixes are in SVN now. Thanks!

I can't wait to hear your tracks!!


09-11-2007 08:57:42

Hi Casey, just a question, we made some new Wavs for our basic game sounds like driving noises and jump noises but they trigger an error on the following section, and i dont know what this FMT sub chunk is :<... The other wav sounds work fine.

// check 'fmt ' sub chunk (1)
CheckCondition(mSoundStream->read(magic, 4) == 4, 13, "Cannot read wav file " + mFileName);
CheckCondition(std::string(magic) == "fmt ", 13, "Wrong wav file format. This file is not a .wav file (no 'fmt ' subchunk): " + mFileName);

*EDIT* My Artist found that the new update of CUBASE 4.1 has export problems and is not exporting format chunks properly!


09-11-2007 10:00:56

Yeah, that is a problem, the format chunk is not an optional section of the wav file! Hope they can get they cleared up for you!


09-11-2007 10:45:28

Im getting a setPitch error, it happens kinda randomly in the game its werid, i set the engine pitch in relation to the current speed of my cars engine RPMS.

21:24:39: OGRE EXCEPTION(40963:): Failed to set Pitch: OpenAL Error: The value pointer given is not valid in OgreAL::Sound::setPitch
21:25:36: OGRE EXCEPTION(40964:): Failed to delete Buffers, must still be in use.: OpenAL Error: There is no current context in OgreAL::Sound::~Sound
21:25:36: OGRE EXCEPTION(40964:): Failed to delete Buffers, must still be in use.: OpenAL Error: There is no current context in OgreAL::Sound::~Sound

My code to set pitch:
float tmpPitch = getMotorPitch();
if(tmpPitch < 0.5f)
tmpPitch = 0.5f;
else if(tmpPitch > 2.0f)
tmpPitch = 2.0f;


we tried using mono and stereo sounds but both crash out, and im not sure the reason why :oops:


09-11-2007 19:17:42

In researching this issue it turns out that I was looking at the old OpenAL 1.0 spec when I put the comment in there that valid values are from 0.5-2.0, now they are (0.0 - any]. Zero is not a valid value and the hardware reserves the right to clip the top range to whatever it wants, but it shouldn't cause an error. Here's the method:mPitch = pitch;

alSourcef(mSource, AL_PITCH, mPitch);
CheckError(alGetError(), "Failed to set Pitch");
So there really isn't much else in there to go wrong! Can you try something? Can you put this line in Sound::setPitch right between mPitch = pitch; and alSourcef(mSource, AL_PITCH, mPitch);OgreAL::CheckError(alGetError(), "There was an error BEFORE setting the pitch");This will let us know if there is an error popping up somewhere before that point that I am not checking for. I don't think there is, I ran through and put a check after every al call, but it can't hurt to check.