0
0

Hi everyone, I’m new to FMOD and just finished learning C++.
I’ve created a function called setVolume like so:
[code:39i642fg]void setVolume(FMOD_CHANNEL *channel , float val){
FMOD_Channel_SetVolume(channel, val);

}[/code:39i642fg]

This works fine. However, I’m not sure how to use the GetVolume command and have it print out on screen using cout. Could someone give an example of how to use the getVolume command (no need for whole function, just the function prototype). Once I get that, the rest of the commands seem to be used in the same way, so the docs should cover it.
Also, I’ve noticed some examples on the forum are using this format:
[code:39i642fg] channel->setVolume()[/code:39i642fg]
What’s the difference between using FMOD_Channel_SetVolume and channel->setVolume? (besides the upper/lower casing).

Thank you

  • You must to post comments
0
0

Hi wxLyrical++ ๐Ÿ˜‰ ,

This is the prototype:
[code:2sql13uk]
FMOD_RESULT F_API FMOD_Channel_GetVolume (FMOD_CHANNEL *channel, float *volume);
[/code:2sql13uk]

This should be what u are searching for ๐Ÿ˜‰ :
[code:2sql13uk]
// Returns the volume between 0.0 (min) and 1.0 (max)
// If there are any errors the function will return -1.0.
float GetCurrentVolume(FMOD_CHANNEL *channel)
{
if(channel == NULL)
return (-1.0F);
float fVol;
if(FMOD_Channel_GetVolume(channel, &fVol) == FMOD_OK)
return (fVol);
else
return (-1.0F);
}
[/code:2sql13uk]

[quote="wxLyrical++":2sql13uk]
What’s the difference between using FMOD_Channel_SetVolume and channel->setVolume? (besides the upper/lower casing).
[/quote:2sql13uk]

FMOD_Channel_SetVolume is a function and channel seems to be a pointer to a class object.

PS: Hope it helps ya :)

Greetz CodeFinder

  • You must to post comments
0
0

Wow, thanks for the quick reply! 8)
That’s exactly what I needed! ๐Ÿ˜€

edit: Your function worked fine. But instead of
[code:1go58gig]FMOD_Channel_GetVolume[/code:1go58gig]
why can’t I use
[code:1go58gig]channel->getVolume()[/code:1go58gig] ? (Assuming ‘channel’ is the actual name of the channel)

  • You must to post comments
0
0

Which kind of FMOD-Interface do u use ? -> The [b:2vwj2lep]C[/b:2vwj2lep] or the C++ interface ?

Well anyway…

this: FMOD_Channel_GetVolume is C

and this: channel->getVolume() is C++

Greezt CodeFinder

  • You must to post comments
0
0

I’m using C++ (IDE = Dev-C++).

  • You must to post comments
0
0

yea ok, but that’s equally …
DEV C++ is able to compile C and C++ code. ๐Ÿ˜‰

Actually it is not important what kind of interface you choose…but if u decide to use the C interface u cannot call any C++ methods and the other way round ๐Ÿ˜† .

  • You must to post comments
0
0

Ah my bad lol. Where can I choose the interface? I’m including the c++ fmod header file and I’m using this code:
[code:2evmogck]
float getVolume(FMOD_CHANNEL *channel){
if(channel == NULL)
return (-1.0F);
float fVol;
if(channel->getVolume(channel,&fVol) == FMOD_OK)
return (fVol);
else
return(-1.0F);
}[/code:2evmogck]

Sorry, it’s probably a newbie question ๐Ÿ˜ณ

  • You must to post comments
0
0

Just have a look at the FMod Header and the doc.:

[quote="FMod Documentation":14cv69ei]
In C/C++, include "fmod.h" if you want to use the C interface only. Include "fmod.hpp" if you want to use the C++ interface.
Note that the constants, callbacks, defines and enums are stored within fmod.h, so fmod.hpp includes fmod.h. If you are using C++ you will be interchanging between both.
[/quote:14cv69ei]

This is an example of how use the C++ interface (FMod Basics, Init.):
[code:14cv69ei]
FMOD_RESULT result;
FMOD::System *system;

result = FMOD::System_Create(&system); // Create the main system object.
if (result != FMOD_OK)
{
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
exit(-1);
}

result = system->init(100, FMOD_INIT_NORMAL, 0); // Initialize FMOD.
if (result != FMOD_OK)
{
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
exit(-1);
}

[/code:14cv69ei]

  • You must to post comments
0
0

Ah, got it! Thanks a lot for all the help CodeFinder. :)

  • You must to post comments
0
0

Yea np ๐Ÿ˜‰ .

  • You must to post comments
Showing 9 results
Your Answer

Please first to submit.