Jump to content
  • Advertisement
Sign in to follow this  
Lil_Lloyd

FMOD set volume, set loop not working....

This topic is 2289 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having some real issues with controlling the looping and volume of audio effects in my game. I have a sample class played by FMOD as follows:


class Sound
{
public:
FMOD_SOUND* soundData;
FMOD_CHANNEL* channel;
Sound();
~Sound();
const std::string& GetName()const {return name;}
void SetName(const std::string& fileName) {name = fileName;}
private:
std::string name;
};




The loading code is as follows


bool Audio::Load(const std::string& fileName,const std::string& name)
{
if(fileName.length() == 0 || name.length() == 0) return false;
Sound* sample = new Sound;
sample->SetName(name);
FMOD_RESULT res;
res = FMOD_System_CreateSound(
system,
fileName.c_str(),
FMOD_DEFAULT,
NULL,
&sample->soundData);
if(res != FMOD_OK) return false;
samples.push_back(sample); //pushes the sample into a vector of sounds for playback later
return true;
}


However the playback code uses FMOD_Channel_Set functions to set different variables, but they don't seem to work! They neither loop or change the volume of the playback. Can someone please help?


bool Audio::Play(const std::string& name,float volume,bool looped,int numLoops)
{
FMOD_RESULT res;
Sound* sample = FindSound(name);
if(sample->soundData != NULL)
{

if(!looped)
{
FMOD_Channel_SetLoopCount(sample->channel,-1);
}
else
{
FMOD_Channel_SetLoopCount(sample->channel,numLoops);
}

//set the sample volume using the channel stored within the sound object
//set during loading

FMOD_Channel_SetVolume(sample->channel,volume);

res = FMOD_System_PlaySound(
system,
FMOD_CHANNEL_FREE,
sample->soundData,
true,
&sample->channel);

if(res!=FMOD_OK)return false;

FMOD_Channel_SetPaused(sample->channel,false);
}
return true;
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!