# FMOD SetVolume in C

**URL:** <https://qa.fmod.com/t/fmod-setvolume-in-c/14615>\
**Category:** Unity\
**Created:** [April 26, 2019, 10:16am UTC](https://qa.fmod.com/t/fmod-setvolume-in-c/14615 "2019-04-26T10:16:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben1900](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/ben1900/32/316_2.png) [@ben1900](https://qa.fmod.com/u/ben1900)\
**Post date:** [April 26, 2019, 10:16am UTC](https://qa.fmod.com/t/fmod-setvolume-in-c/14615/1 "2019-04-26T10:16:34Z")

</div>

Hello I’m asking for help,  
I’m trying to change volume in C (i’m using CodeBlocks) but i get this error : |error: expected declaration specifiers or ‘…’ before ‘volume’|

```
int MUSIQUE()
{
    SDL_Event event;
    int continuer = 1;

    FMOD_SYSTEM *system;
    FMOD_SOUND *musique;
    FMOD_RESULT resultat;
    FMOD_System_Create(&system);
    FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);

    resultat = FMOD_System_CreateSound(system, "Zeze.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &musique);
    FMOD_CHANNEL *channel;
    FMOD_System_GetChannel(system, 9, &channel);
    if (resultat != FMOD_OK)
    {
        fprintf(stderr, "Impossible de lire le fichier mp3\n");
        exit(EXIT_FAILURE);
    }
    //FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, musique, 0, NULL);
    FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, musique, 0, NULL);
    FMOD_RESULT FMOD_ChannelGroup_SetVolume(FMOD_CHANNELGROUP * channel, float 0.3);
}

```

This error is at last line with float 0.3…  
I hope somebody could help me

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [April 27, 2019, 11:13am UTC](https://qa.fmod.com/t/fmod-setvolume-in-c/14615/2 "2019-04-27T11:13:56Z")

</div>

Hi,  
This is some basic misunderstanding with C, the C functions that you call dont start by putting in the type at the start (ie FMOD\_RESULT). You also did it with ‘float 0.3’ … you dont use that keyword at all. you just pass the number, ie 0.3

FMOD\_RESULT is the thing the function returns. To capture that, you can declare a variable of type FMOD\_RESULT if you want. ie

`FMOD_RESULT result;`

then receive the ‘return value’ of FMOD\_Channel\_SetVolume into ‘result’.  
ie

`result = FMOD_ChannelGroup_SetVolume...`  
etc

Also, there are some issues there with pointers. You’re supposed to pass the address of your pointer to playsound, then that’s your handle that you can use to set the volume on.  
You then pass the channel as the handle to SetVolume. You dont use the type in the parameter… You should just be using ‘channel’ as the parameter.

Also you mixed up ChannelGroup and Channel. You dont pass a channel as the handle to a ChannelGroup function. It should be FMOD\_Channel\_SetVolume not FMOD\_ChannelGroup\_SetVolume

---

<div class="post-metadata">

**Author:** ![ben1900](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/ben1900/32/316_2.png) [@ben1900](https://qa.fmod.com/u/ben1900)\
**Post date:** [April 27, 2019, 1:52pm UTC](https://qa.fmod.com/t/fmod-setvolume-in-c/14615/3 "2019-04-27T13:52:48Z")

</div>

Thank you a lot  
I have fixed up all my errors and it now works
