当前位置: 首页>>代码示例>>C++>>正文


C++ Mix_FadeInMusic函数代码示例

本文整理汇总了C++中Mix_FadeInMusic函数的典型用法代码示例。如果您正苦于以下问题:C++ Mix_FadeInMusic函数的具体用法?C++ Mix_FadeInMusic怎么用?C++ Mix_FadeInMusic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Mix_FadeInMusic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BGM_Stop

void SdlAudio::BGM_Play(std::string const& file, int volume, int /* pitch */, int fadein) {
	if (file.empty() || file == "(OFF)")
	{
		BGM_Stop();
		return;
	}

	std::string const path = FileFinder::FindMusic(file);
	if (path.empty()) {
		//HACK: Polish RTP translation replaced (OFF) reserved string with (Brak)
		if (file != "(Brak)")
			Output::Warning("Music not found: %s", file.c_str());
		BGM_Stop();
		return;
	}

	SDL_RWops *rw = SDL_RWFromFile(path.c_str(), "rb");
#if SDL_MIXER_MAJOR_VERSION>1
	bgm.reset(Mix_LoadMUS_RW(rw, 1), &Mix_FreeMusic);
#else
	bgm.reset(Mix_LoadMUS_RW(rw), &Mix_FreeMusic);
#endif
	if (!bgm) {
		Output::Warning("Couldn't load %s BGM.\n%s\n", file.c_str(), Mix_GetError());
		return;
	}
#if SDL_MAJOR_VERSION>1
	// SDL2_mixer produces noise when playing wav.
	// Workaround: Use Mix_LoadWAV
	// https://bugzilla.libsdl.org/show_bug.cgi?id=2094
	if (bgs_playing) {
		BGS_Stop();
	}
	if (Mix_GetMusicType(bgm.get()) == MUS_WAV) {
		BGM_Stop();
		BGS_Play(file, volume, 0, fadein);
		return;
	}
#endif

	BGM_Volume(volume);
	if (!me_stopped_bgm &&
#ifdef _WIN32
	    (Mix_GetMusicType(bgm.get()) == MUS_MID && WindowsUtils::GetWindowsVersion() >= 6
	     ? Mix_PlayMusic(bgm.get(), -1) : Mix_FadeInMusic(bgm.get(), -1, fadein))
#else
	     Mix_FadeInMusic(bgm.get(), -1, fadein)
#endif
	     == -1) {
		Output::Warning("Couldn't play %s BGM.\n%s\n", file.c_str(), Mix_GetError());
		return;
	}
}
开发者ID:MarianoGnu,项目名称:Player,代码行数:53,代码来源:sdl_audio.cpp

示例2: Mix_LoadMUS

//BackGroundMusic, volume = between [0 - 128], 64 = neutral
void SoundBank::PlayBGM(SoundBgmType type, int volume) {
	Mix_Music* tempMusic = Mix_LoadMUS(bgmPathList.at(type));
	if (!Mix_PlayingMusic()) { //there is no music playing yet
		Mix_FadeInMusic(Mix_LoadMUS(bgmPathList.at(type)), -1, 1000);
		Mix_VolumeMusic(volume);
	}
	else if(!Mix_PausedMusic()) { //there is already music playing
		Mix_FadeOutMusic(1000);
		Mix_FadeInMusic(Mix_LoadMUS(bgmPathList.at(type)), -1, 1000);
		Mix_VolumeMusic(volume);
	}
}
开发者ID:mjowned,项目名称:GameDev,代码行数:13,代码来源:SoundBank.cpp

示例3: OS_playMusic

void OS_playMusic(int id)
{
	if(!OS_sound_On)
		return;

	if (id == OS_music_theme)
		Mix_FadeInMusic(music_theme, -1, 0);

	if (id == OS_music_success)
		Mix_FadeInMusic(music_success, 0, 0);

	if (id == OS_music_failure)
		Mix_FadeInMusic(music_failure, 0, 0);

}
开发者ID:a-sf-mirror,项目名称:phlipple,代码行数:15,代码来源:osinterface_sdl.c

示例4: BOOST_ASSERT

void SoundProcessor::playMusic(boost::shared_ptr<const Music> play_music, const bool loop)
{

#ifdef _FMOD_SOUND
	BOOST_ASSERT(soundEngine);

	if(musicChannel) {
		musicChannel->stop();
	}
	soundEngine->playSound(FMOD_CHANNEL_FREE, play_music->getData(), 0, &musicChannel);

#elif _SDL_MIXER_SOUND

	bool success = false;

	// music currently playing?
	if(currentMusic != NULL)
	{
		// new music?
		if(play_music != NULL) {
			if(loop) {
				nextMusic = currentMusic;
			} else {
				nextMusic = NULL;
			}
			// transition between both music plays
			Mix_HookMusicFinished(::transitionMusic);
			success = (Mix_FadeOutMusic(MUSIC_TRANSITION_DURATION/2) == 1);
		} else 
			// empty music => Stop music, just fade out
		{
			success = (Mix_FadeOutMusic(MUSIC_TRANSITION_DURATION) == 1);
		}
	} else 
		// no music was playing
	{
		if(play_music != NULL)
		{
			currentMusic = play_music->getData();
			if(loop) {
				nextMusic = currentMusic;
			} else {
				nextMusic = NULL;
			}

			Mix_HookMusicFinished(::transitionMusic);
			success = (Mix_FadeInMusic(currentMusic, -1, MUSIC_TRANSITION_DURATION) == 0);
		} else {
			// no music played, no music to play
			success = true;
		}
	}

	if(!success) {
		std::ostringstream os;
		os << "ERROR (SoundProcessor::playMusic()): " << Mix_GetError() << "[" << play_music->getFileName() << "]";
		toErrorLog(os.str());
	}
#endif
}
开发者ID:LodePublishing,项目名称:GUI,代码行数:60,代码来源:soundprocessor.cpp

示例5: musicInit

void musicInit(void)
{
    fprintf(stderr, "(Music) Initializing audio...");
    if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1)
    {
        fprintf(stderr, "\tFailed.\n"
                "(Music) Error initializing audio: %s\n", Mix_GetError());
        return;
    }
    fprintf(stderr, "\tSuccess!\n(Music) Loading music...");
    bgm = Mix_LoadMUS("bgm.mp3");
    if (!bgm)
    {
        fprintf(stderr, "\tLoad failed, proceeding without music.\n"
                "(Music) Error was: %s\n", Mix_GetError());
        return;
    }
    fprintf(stderr, "\tSuccess!\nStarting music...");
    if (Mix_FadeInMusic(bgm, -1, 500) < 0)
    {
        fprintf(stderr, "\tError Mix_FadeInMusic: %s\n", Mix_GetError());
        return;
    }
    fprintf(stderr, "\tSuccess!\n");

}
开发者ID:hk0i,项目名称:annoi,代码行数:26,代码来源:main.c

示例6: snd_play_mus

int snd_play_mus(char *fname, int ms, int loop)
{
	if (!sound_on)
		return 0;
	if (snd_playing_mus()) {
		if (next_mus) {
			free(next_mus);
		}
		next_mus = strdup(fname);
		next_fadein = ms;
		next_loop = loop;
		if (!timer_id)
			timer_id = SDL_AddTimer(200, callback, NULL);
		return 1;
	}
	if (mus)
		snd_free_mus(mus);

	mus = snd_load_mus(fname);
	if (!mus)
		return -1;
	if (loop >= 0)
		Mix_HookMusicFinished(game_music_finished);
	else
		Mix_HookMusicFinished(NULL);
	if (ms)
		Mix_FadeInMusic(mus->mus, loop, ms);
	else
		Mix_PlayMusic(mus->mus, loop);
	snd_volume_mus(snd_volume_mus(-1)); /* SDL hack? */
	return 0;
}
开发者ID:wimh,项目名称:instead,代码行数:32,代码来源:sound.c

示例7: I_PlaySong

void I_PlaySong(int handle, int looping)
{
  printf("Playing song %d (%d loops)\n", handle, looping);
  if ( music[handle] ) {
    Mix_FadeInMusic(music[handle], looping ? -1 : 0, 500);
  }
}
开发者ID:hexameron,项目名称:DOOM,代码行数:7,代码来源:l_sound_sdl.c

示例8: Mix_FadeInMusic

int BEE::Sound::fade_in(int ticks) {
	if (!is_loaded) {
		if (!has_play_failed) {
			game->messenger_send({"engine", "sound"}, BEE_MESSAGE_WARNING, "Failed to fade in sound \"" + name + "\" because it is not loaded");
			has_play_failed = true;
		}
		return 1;
	}

	if (is_music) {
		Mix_FadeInMusic(music, 1, ticks);
	} else {
		int c = Mix_FadeInChannel(-1, chunk, 0, ticks);
		if (c >= 0) {
			current_channels.remove(c);
			current_channels.push_back(c);
		} else {
			game->messenger_send({"engine", "sound"}, BEE_MESSAGE_WARNING, "Failed to play sound \"" + name + "\": " + Mix_GetError());
			return 1;
		}

		set_pan_internal(c);
		effect_set(c, sound_effects);
	}

	is_playing = true;
	is_looping = false;

	return 0;
}
开发者ID:piluke,项目名称:BasicEventEngine,代码行数:30,代码来源:sound.cpp

示例9: SDL_UnlockMutex

void  PGE_MusPlayer::MUS_playMusicFadeIn(int ms)
{
    if(!isLoaded) return;
	if(play_mus)
    {
		if(Mix_PausedMusic()==0)
		{
			// Reset music sample count
			if (SDL_LockMutex(sampleCountMutex) == 0)
			{
				musSCount = 0;
				SDL_UnlockMutex(sampleCountMutex);
			}

			if(Mix_FadingMusic()!=MIX_FADING_IN)
				if(Mix_FadeInMusic(play_mus, -1, ms)==-1)
				{
                    PGE_MsgBox::warn(std::string(std::string("Mix_FadeInMusic:")+std::string(Mix_GetError())).c_str());
				}
		}
		else
			Mix_ResumeMusic();

    }
    else
    {
        PGE_MsgBox::warn(std::string(std::string("Play nothing:")+std::string(Mix_GetError())).c_str());
    }
}
开发者ID:tcvicio,项目名称:PGE-Project,代码行数:29,代码来源:SdlMusPlayer.cpp

示例10: Mix_FadeInMusic

bool SDLMusic::play(const int loops, const int fadeIn)
{
    if (fadeIn > 0)
        return Mix_FadeInMusic(mMusic, loops, fadeIn);
    else
        return Mix_PlayMusic(mMusic, loops);
}
开发者ID:koo5,项目名称:manaplus,代码行数:7,代码来源:sdlmusic.cpp

示例11: music_mix_play

/**
 * @brief Plays the loaded music.
 */
void music_mix_play (void)
{
   if (music_music == NULL) return;

   if (Mix_FadeInMusic( music_music, 0, MUSIC_FADEIN_DELAY ) < 0)
      WARN("SDL_Mixer: %s", Mix_GetError());
}
开发者ID:Crockadavin,项目名称:naev,代码行数:10,代码来源:music_sdlmix.c

示例12: op_init_game

EXPORT void op_init_game(pdata data,pgameinfo gameinfo)
{
    //Text initialisieren
    data->text.texture=gameinfo->texttexture;
    int a;
    for (a=0; a<256; a++)
        data->text.breite[a]=gameinfo->textwidth[a];

    //Gameinforeferenzpointer speicher:
    data->gameinfo=gameinfo;

    char buffer[1024];

    //Ton vorbereiten
    sprintf(buffer,"%ssounds/Vegas Glitz.ogg",gameinfo->datafolder);
    data->backgroundmusic = Mix_LoadMUS(buffer);
    data->old_music_volume=Mix_VolumeMusic((int)(trunc(96.0*gameinfo->volume)));
    Mix_FadeInMusic(data->backgroundmusic,-1,500);


    //Spiel ansich vorbereiten
    data->step=0;
    data->fade=1;
    data->countdown=3000;
}
开发者ID:theZiz,项目名称:OpenParty,代码行数:25,代码来源:skeleton.c

示例13: Mix_VolumeMusic

///////////////////////////////////////////////////////////
// ME finish callback
///////////////////////////////////////////////////////////
void Audio::ME_finish() {
	Mix_VolumeMusic(Audio::bgm_volume);
	Mix_FadeInMusic(Audio::bgm, -1, 1000);
	Audio::bgm_playing = true;
	Audio::me_playing = false;
	Mix_HookMusicFinished(NULL);
}
开发者ID:cstrahan,项目名称:argss,代码行数:10,代码来源:audio_sdl.cpp

示例14: load_files

int load_files()
{
    background = IMG_Load ( "background.jpg" );

    font = TTF_OpenFont( "CALIFI.ttf", 30 );

    if( background == NULL )
    {
        return false;
    }

    if( font == NULL )
    {
        return false;
    }

    music = Mix_LoadMUS( "music.mp3" );

    if( music == NULL )
    {
        return false;
    }

    if(Mix_FadeInMusic(music,0,2000)==-1)
    {
        printf("Mix_FadeInMusic: %s\n", Mix_GetError());
    }

    return true;
}
开发者ID:ext09,项目名称:holdem_poker_evs-107,代码行数:30,代码来源:main.c

示例15: Mix_FadeInMusic

	void Music::Play()
	{
		if ( !buffer )
			return;

		Mix_FadeInMusic( buffer, (isLoop ? -1 : 1), 100 );
		Music::currentlyPlaying = this;
	}
开发者ID:RoestVrijStaal,项目名称:warehousepanic,代码行数:8,代码来源:Music.cpp


注:本文中的Mix_FadeInMusic函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。