0
0

i’m using this chunk of code to play an mp3 when my menu loads for my game:

FSOUND_Init(44100, 32, FSOUND_INIT_GLOBALFOCUS);
FSOUND_SAMPLE *song = NULL;
FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
song = FSOUND_Sample_Load(FSOUND_UNMANAGED, "Data/menu_music.mp3", FSOUND_2D, 0);
FSOUND_PlaySound(FSOUND_FREE, song);
FSOUND_SetVolume(FSOUND_ALL, music_volume*25);

now, that works fine…
although in the options i have an option to adjust the volume of music, but how can i detect what channel to modify the volume of (what channel the ‘song’ is being played on)? without it affecting the other sound effects within the game. (not applying to all channels using FSOUND_ALL, just the specific channel that was chosen when FSOUND_FREE was used in FSOUND_PlaySound)

I still want to use FSOUND_FREE as it’s reliable in finding a real free channel, i dont want to have to use a fixed channel, which could cause problems most likely.

thanks in advance.

  • You must to post comments
0
0

i was thinking about how i could do that.. but i’m not sure, i’m a newbie coder, so please be nice ๐Ÿ˜‰

  • You must to post comments
0
0

chan = FSOUND_PlaySound(FSOUND_FREE, song);

  • You must to post comments
0
0

i’m more confused now ๐Ÿ˜ฅ

if i was to use that, what would i define “chan” as?
and how could i use it later on when adjusting volume?

i need code examples, as i’m completely lost now :(

  • You must to post comments
0
0

im a complete newbie as i said, so none of this is making sense to me

int sfx_channel;
i declared that as a global int.

i then try and do,
sfx_channel = FSOUND_PlaySound(FSOUND_FREE, “data/menu4.wav”);

but all i get is:
error C2664: ‘FSOUND_PlaySound’ : cannot convert parameter 2 from ‘char [15]’ to ‘struct FSOUND_SAMPLE *’
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

  • You must to post comments
0
0

sorry, i initialised the sound first, i just didn’t post that code because i figured it was logical…
music volume works, i’m just now trying to figure out why the normal sfx one doesn’t ๐Ÿ˜ฅ

here’s the code i have:

void InitFMOD_SFX ()
{
sound_menu_moveupdown = FSOUND_Sample_Load(FSOUND_UNMANAGED, “data/menu1.wav”, FSOUND_2D, 0);
sound_menu_moveleftright = FSOUND_Sample_Load(FSOUND_UNMANAGED, “data/menu2.wav”, FSOUND_2D, 0);
sound_menu_forward = FSOUND_Sample_Load(FSOUND_UNMANAGED, “data/menu3.wav”, FSOUND_2D, 0);
sound_menu_back = FSOUND_Sample_Load(FSOUND_UNMANAGED, “data/menu4.wav”, FSOUND_2D, 0);

sfx_channel = FSOUND_PlaySound(FSOUND_FREE, sound_menu_back);
FSOUND_SetVolume(sfx_channel, sound_volume*25);

}

// initialise fmod, load music for menu
void InitFMOD(void)
{
FSOUND_Init(44100, 32, FSOUND_INIT_GLOBALFOCUS);
FSOUND_SAMPLE song = NULL;
FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
song = FSOUND_Sample_Load(FSOUND_UNMANAGED, “Data/menu_music.mp3”, FSOUND_2D, 0);
music_channel = FSOUND_PlaySound(FSOUND_FREE, song);
FSOUND_PlaySound(music_channel, song);
FSOUND_SetVolume(music_channel, music_volume
25);

InitFMOD_SFX();

}

  • You must to post comments
0
0

both sound_volume and music_volume are integers
0 to 10 are their ranges
0 being off, 10 max

whenever a setvolume is done, i simply take that value, and *25

  • You must to post comments
0
0

when i did some printing
volume is indeed working… channels that were chosen were:
sfx_channel = #4097
music_channel = #4096

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.