示例#1
0
void set_music_volume(int vol)
{
	if(music_volume() == vol) {
		return;
	}

	preferences::set("music_volume", lexical_cast_default<std::string>(vol, "100"));
	sound::set_music_volume(music_volume());
}
示例#2
0
void set_music_volume(int vol)
{
	if(music_volume() == vol) {
		return;
	}

	prefs["music_volume"] = vol;
	sound::set_music_volume(music_volume());
}
示例#3
0
文件: options.c 项目: zid/naev
/**
 * @brief Callback to set the music level.
 *
 *    @param wid Window calling the callback.
 *    @param str Name of the widget calling the callback.
 */
static void opt_setMusicLevel( unsigned int wid, char *str )
{
   double vol;

   vol = window_getFaderValue(wid, str);
	music_volume(vol);
}
示例#4
0
文件: options.c 项目: isfos/naev
/**
 * @brief Callback to set the music level.
 *
 *    @param wid Window calling the callback.
 *    @param str Name of the widget calling the callback.
 */
static void opt_setMusicLevel( unsigned int wid, char *str )
{
    char buf[32];
    double vol;

    /* Update fader. */
    vol = window_getFaderValue(wid, str);
    music_volume(vol);

    /* Update message. */
    snprintf( buf, sizeof(buf), "Music Volume: %.2f", music_getVolume() );
    window_modifyText( wid, "txtMusic", buf );
}
示例#5
0
文件: options.c 项目: s0be/naev
/**
 * @brief Callback to set the sound or music level.
 *
 *    @param wid Window calling the callback.
 *    @param str Name of the widget calling the callback.
 *    @param type 0 for sound, 1 for audio.
 */
static void opt_setAudioLevel( unsigned int wid, char *str )
{
   char buf[32], *widget;
   double vol;

   vol = window_getFaderValue(wid, str);
   if (strcmp(str,"fadSound")==0) {
      sound_volume(vol);
      widget = "txtSound";
      opt_audioLevelStr( buf, sizeof(buf), 0, vol );
   }
   else {
      music_volume(vol);
      widget = "txtMusic";
      opt_audioLevelStr( buf, sizeof(buf), 1, vol );
   }

   window_modifyText( wid, widget, buf );
}
示例#6
0
文件: options.c 项目: s0be/naev
/**
 * @brief Sets the audio defaults.
 */
static void opt_audioDefaults( unsigned int wid, char *str )
{
   (void) str;

   /* Ask user. */
   if (!dialogue_YesNoRaw( "Restore Defaults", "Are you sure you want to restore default audio settings?" ))
      return;

   /* Set defaults. */
   conf_setAudioDefaults();

   /* Have sound levels affect. */
   sound_volume(conf.sound);
	music_volume(conf.music);

   /* Update widgets. */
   opt_audioUpdate( wid, NULL );

   /* Alert user it worked. */
   dialogue_msgRaw( "Defaults Restored", "Audio settings restored to defaults.");
}
示例#7
0
文件: music.c 项目: Superkoop/naev
/**
 * @brief Initializes the music subsystem.
 *
 *    @return 0 on success.
 */
int music_init (void)
{
   if (music_disabled)
      return 0;

   if ((conf.sound_backend != NULL) &&
         (strcmp(conf.sound_backend,"sdlmix")==0)) {
#if USE_SDLMIX
      /*
       * SDL_mixer backend.
       */
      /* Init/exit. */
      music_sys_init = music_mix_init;
      music_sys_exit = music_mix_exit;
      /* Loading. */
      music_sys_load = music_mix_load;
      music_sys_free = music_mix_free;
      /* Music control. */
      music_sys_volume = music_mix_volume;
      music_sys_getVolume = music_mix_getVolume;
      music_sys_getVolumeLog = music_mix_getVolume;
      music_sys_load = music_mix_load;
      music_sys_play = music_mix_play;
      music_sys_stop = music_mix_stop;
      music_sys_pause = music_mix_pause;
      music_sys_resume = music_mix_resume;
      music_sys_setPos = music_mix_setPos;
      music_sys_isPlaying = music_mix_isPlaying;
#else /* USE_SDLMIX */
      WARN("SDL_mixer support not compiled in!");
      return -1;
#endif /* USE_SDLMIX */
   }
   else if ((conf.sound_backend != NULL) &&
         (strcmp(conf.sound_backend,"openal")==0)) {
#if USE_OPENAL
      /*
       * OpenAL backend.
       */
      /* Init/exit. */
      music_sys_init = music_al_init;
      music_sys_exit = music_al_exit;
      /* Loading. */
      music_sys_load = music_al_load;
      music_sys_free = music_al_free;
      /* Music control. */
      music_sys_volume = music_al_volume;
      music_sys_getVolume = music_al_getVolume;
      music_sys_getVolumeLog = music_al_getVolumeLog;
      music_sys_load = music_al_load;
      music_sys_play = music_al_play;
      music_sys_stop = music_al_stop;
      music_sys_pause = music_al_pause;
      music_sys_resume = music_al_resume;
      music_sys_setPos = music_al_setPos;
      music_sys_isPlaying = music_al_isPlaying;
#else /* USE_OPENAL */
      WARN("OpenAL support not compiled in!");
      return -1;
#endif /* USE_OPENAL*/
   }
   else {
      WARN("Unknown sound backend '%s'.", conf.sound_backend);
      return -1;
   }

   /* Start the subsystem. */
   if (music_sys_init())
      return -1;

   /* Load the music. */
   if (music_find() < 0)
      return -1;

   /* Start up Lua. */
   if (music_luaInit() < 0)
      return -1;

   /* Set the volume. */
   if ((conf.music > 1.) || (conf.music < 0.))
      WARN("Music has invalid value, clamping to [0:1].");
   music_volume(conf.music);

   /* Create the lock. */
   music_lock = SDL_CreateMutex();

   return 0;
}