Beispiel #1
0
void
CFModExDriver::setMasterVolume(const float& volume){
    // FMOD_Channel / float
    // can try overrideVolume too
    FMOD_ChannelGroup_SetVolume(_masterGroup, volume);

}
Beispiel #2
0
//---------------------------------------------------------------------------
// Name: sound_volume 
// Desc: Sets sound volume.
//---------------------------------------------------------------------------
static int csl_sound_volume(void)
{
    int argc = csl_argc()+1;
	    
	    
	if(argc!=2)
	{
		csl_textout(1, "syntax: sound_volume [0 - 255]");
		csl_textoutf(1, "Current sound_volume is \"%d\".",fiend_sound_volume);
	}
	else
	{
		fiend_sound_volume = atoi(csl_argv(1));
		
		if(sound_is_on) {
			//FSOUND_SetSFXMasterVolume(fiend_sound_volume);
			FMOD_CHANNELGROUP *cgroup = NULL;
			FMOD_System_GetMasterChannelGroup(fmod_system, &cgroup);
			FMOD_ChannelGroup_SetVolume(cgroup, ((float)fiend_sound_volume)/256);
		}

		csl_textoutf(1, "Sound_volume is set to \"%d\".", fiend_sound_volume);
	}

		
	return CSLMSG_O_K;
    
}
Beispiel #3
0
void AudioManager::Allocate( const int32_t MaxChannels, const FMOD_INITFLAGS InitFlags, void* ExDriverData )
{
	// Create local variables.

		size_t GroupIndex = 1;

	// Initialize audio system.

		if( !Initialized )
		{
			if( FMOD_System_Create( &SystemInstance ) != FMOD_OK )
				throw exception();

			if( FMOD_System_Init( SystemInstance, MaxChannels, InitFlags, ExDriverData ) != FMOD_OK )
				throw exception();

			for( size_t Index = 0; Index < MaxAudioTypes; Index += 2 )
			{
				AudioMaps[ Index ].Group = AudioMaps[ ( Index + 1 ) ].Group = GroupIndex;
				GroupIndex++;
			}

			if( FMOD_System_GetMasterChannelGroup( SystemInstance, &ChannelGroups[ MasterGroup ].Instance ) != FMOD_OK )
				throw exception();

			ChannelGroups[ MasterGroup ].Volume = AUDIOMANAGER_DEF_VOLUME;

			if( FMOD_ChannelGroup_SetVolume( ChannelGroups[ MasterGroup ].Instance, AUDIOMANAGER_DEF_VOLUME ) != FMOD_OK )
				throw exception();

			for( size_t Index = 1; Index < MaxChannelGroups; Index++ )
			{
				if( FMOD_System_CreateChannelGroup( SystemInstance, nullptr, &ChannelGroups[ Index ].Instance ) != FMOD_OK )
					throw exception();

				ChannelGroups[ Index ].Volume = AUDIOMANAGER_DEF_VOLUME;

				if( FMOD_ChannelGroup_SetVolume( ChannelGroups[ Index ].Instance, AUDIOMANAGER_DEF_VOLUME ) != FMOD_OK )
					throw exception();

				if( FMOD_ChannelGroup_AddGroup( ChannelGroups[ MasterGroup ].Instance, ChannelGroups[ Index ].Instance ) != FMOD_OK )
					throw exception();
			}

			Initialized = true;
		}
}
Beispiel #4
0
int main(int argc, char *argv[])
{
    FMOD_SYSTEM       *system;
    FMOD_SOUND        *sound[6];
    FMOD_CHANNEL      *channel[6];
    FMOD_CHANNELGROUP *groupA, *groupB, *masterGroup;
    FMOD_RESULT        result;
    int                key, count;
    unsigned int       version;

    /*
        Create a System object and initialize.
    */
    result = FMOD_System_Create(&system);
    ERRCHECK(result);

    result = FMOD_System_GetVersion(system, &version);
    ERRCHECK(result);

    if (version < FMOD_VERSION)
    {
        printf("Error!  You are using an old version of FMOD %08x.  This program requires %08x\n", version, FMOD_VERSION);
        return 0;
    }

    result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, 0);
    ERRCHECK(result);

    result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_LOOP_NORMAL, 0, &sound[0]);
    ERRCHECK(result);
    result = FMOD_System_CreateSound(system, "../media/jaguar.wav", FMOD_LOOP_NORMAL, 0, &sound[1]);
    ERRCHECK(result);
    result = FMOD_System_CreateSound(system, "../media/swish.wav", FMOD_LOOP_NORMAL, 0, &sound[2]);
    ERRCHECK(result);
    result = FMOD_System_CreateSound(system, "../media/c.ogg", FMOD_LOOP_NORMAL, 0, &sound[3]);
    ERRCHECK(result);
    result = FMOD_System_CreateSound(system, "../media/d.ogg", FMOD_LOOP_NORMAL, 0, &sound[4]);
    ERRCHECK(result);
    result = FMOD_System_CreateSound(system, "../media/e.ogg", FMOD_LOOP_NORMAL, 0, &sound[5]);
    ERRCHECK(result);

    result = FMOD_System_CreateChannelGroup(system, "Group A", &groupA);
    ERRCHECK(result);

    result = FMOD_System_CreateChannelGroup(system, "Group B", &groupB);
    ERRCHECK(result);

    result = FMOD_System_GetMasterChannelGroup(system, &masterGroup);
    ERRCHECK(result);

    printf("=======================================================================\n");
    printf("ChannelGroups Example.  Copyright (c) Firelight Technologies 2004-2011.\n");
    printf("=======================================================================\n");
    printf("\n");
    printf("Group A : drumloop.wav, jaguar.wav, swish.wav\n");
    printf("Group B : c.ogg, d.ogg, e.ogg\n");
    printf("\n");
    printf("Press 'A' to mute/unmute group A\n");
    printf("Press 'B' to mute/unmute group B\n");
    printf("Press 'C' to mute/unmute group A and B (master group)\n");
    printf("Press 'Esc' to quit\n");
    printf("\n");

    /*
        Instead of being independent, set the group A and B to be children of the master group.
    */
    result = FMOD_ChannelGroup_AddGroup(masterGroup, groupA);
    ERRCHECK(result);

    result = FMOD_ChannelGroup_AddGroup(masterGroup, groupB);
    ERRCHECK(result);

    /*
        Start all the sounds!
    */
    for (count = 0; count < 6; count++)
    {
        result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound[count], TRUE, &channel[count]);
        ERRCHECK(result);
        if (count < 3)
        {
            result = FMOD_Channel_SetChannelGroup(channel[count], groupA);
        }
        else
        {
            result = FMOD_Channel_SetChannelGroup(channel[count], groupB);
        }
        ERRCHECK(result);
        result = FMOD_Channel_SetPaused(channel[count], FALSE);
        ERRCHECK(result);
    }

    /*
        Change the volume of each group, just because we can!  (And makes it less of a loud noise).
    */
    result = FMOD_ChannelGroup_SetVolume(groupA, 0.5f);
    ERRCHECK(result);
    result = FMOD_ChannelGroup_SetVolume(groupB, 0.5f);
    ERRCHECK(result);

    /*
        Main loop.
    */
    do
    {
        if (_kbhit())
        {
            key = _getch();

            switch (key)
            {
                case 'a' : 
                case 'A' : 
                {
                    static int mute = TRUE;

                    FMOD_ChannelGroup_SetMute(groupA, mute);

                    mute = !mute;
                    break;
                }
                case 'b' : 
                case 'B' : 
                {
                    static int mute = TRUE;

                    FMOD_ChannelGroup_SetMute(groupB, mute);

                    mute = !mute;
                    break;
                }
                case 'c' : 
                case 'C' : 
                {
                    static int mute = TRUE;

                    FMOD_ChannelGroup_SetMute(masterGroup, mute);

                    mute = !mute;
                    break;
                }
            }
        }

        FMOD_System_Update(system);

        {
            int  channelsplaying = 0;

            FMOD_System_GetChannelsPlaying(system, &channelsplaying);

            printf("Channels Playing %2d\r", channelsplaying);
        }

        Sleep(10);

    } while (key != 27);

    printf("\n");

    /*
        A little fade out. (over 2 seconds)
    */
    printf("Goodbye!\n");
    {
        float pitch = 1.0f;
        float vol = 1.0f;

        for (count = 0; count < 200; count++)
        {
            FMOD_ChannelGroup_SetPitch(masterGroup, pitch);
            FMOD_ChannelGroup_SetVolume(masterGroup, vol);

            vol   -= (1.0f / 200.0f);
            pitch -= (0.5f / 200.0f);

            Sleep(10);
        }
    }

    /*
        Shut down
    */
    for (count = 0; count < 6; count++)
    {
        result = FMOD_Sound_Release(sound[count]);
        ERRCHECK(result);
    }

    result = FMOD_ChannelGroup_Release(groupA);
    ERRCHECK(result);
    result = FMOD_ChannelGroup_Release(groupB);
    ERRCHECK(result);

    result = FMOD_System_Close(system);
    ERRCHECK(result);
    result = FMOD_System_Release(system);
    ERRCHECK(result);

    return 0;
}
// ----------------------------------------------------------------------------
void ofxSoundSetVolume(float vol)
{
	ofxSoundInitialize();
	FMOD_ChannelGroup_SetVolume(channelgroup, vol);
}
Beispiel #6
0
int main(int argc, char *argv[])
{
	int continuer = 1;
	float volume = 1.0;
	Touche tab[NB_TOUCHES];
	SDL_Surface *ecran = NULL, *fde = NULL;
	SDL_Event event;
	SDL_Rect positionFond;
	FMOD_SYSTEM *system;
	FMOD_CHANNELGROUP* channel = null;
	
	positionFond.x = 0;
	positionFond.y = 0;
	
	/*SONS*/
	/* Création et initialisation d'un objet système pour le FMOD*/
	FMOD_System_Create(&system);
	FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);
	
	/* Chargement des sons */
	if(init_touches(system, tab))
		return EXIT_FAILURE;
	
	/*SDL*/
	/* Initialisation de la SDL */
	SDL_Init(SDL_INIT_VIDEO);
	
	ecran = SDL_SetVideoMode(283, 200, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
	SDL_WM_SetCaption("Launchpad de la TIPS", NULL);
	
	fde = IMG_Load("../files/fde.png");
	SDL_WM_SetIcon(fde, NULL);
	SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
	SDL_BlitSurface(fde, NULL, ecran, &positionFond);
	SDL_Flip(ecran);
	
	while (continuer)
	{
		SDL_WaitEvent(&event);
		switch(event.type)
		{
			case SDL_QUIT:
				continuer = 0;
				break;
			case SDL_MOUSEBUTTONDOWN: /* Si clique de la souris */
				/* Non utile pour le moment*/
				break;
			case SDL_KEYDOWN: /* Si appuie sur une touche */
				
				/* Esc pour quitter */
				if(event.key.keysym.sym == SDLK_ESCAPE)
					continuer = 0;
				/* UP pour monter le son */
				else if(event.key.keysym.sym == SDLK_UP)
				{
					FMOD_System_GetMasterChannelGroup(system, &channel);
					volume += 0.1;
					FMOD_ChannelGroup_SetVolume(channel, volume);
				}
				/* DOWN pour baisser le son */
				else if(event.key.keysym.sym == SDLK_DOWN)
				{
					FMOD_System_GetMasterChannelGroup(system, &channel);
					volume -= 0.1;
					FMOD_ChannelGroup_SetVolume(channel, volume);
				}
				/* LEFT ou RIGHT pour stopper la musique */
				else if((event.key.keysym.sym == SDLK_LEFT) || (event.key.keysym.sym == SDLK_RIGHT))
				{
					FMOD_System_GetMasterChannelGroup(system, &channel);
					FMOD_ChannelGroup_Stop(channel);
				}
				else if(tab[event.key.keysym.sym].son != NULL)
				{
					FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, tab[event.key.keysym.sym].son, 0, NULL);
				}
				break;
		}
	}

	/* On ferme la SDL */
	SDL_FreeSurface(fde);
	SDL_Quit();

	/* On libère le son et on ferme et libère l'objet système */
	libere_touches(tab);
	FMOD_System_Close(system);
	FMOD_System_Release(system);
	
	return EXIT_SUCCESS;
}
Beispiel #7
0
//--------------------
void ofFmodSoundSetVolume(float vol){
	ofFmodSoundPlayer::initializeFmod();
	FMOD_ChannelGroup_SetVolume(channelgroup, vol);
}
void SoundEngine::setVolumeAllChannel(float volume)
{
    FMOD_ChannelGroup_SetVolume(getChannelGroup(),volume);
}