本文整理汇总了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;
}
}
示例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);
}
}
示例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);
}
示例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
}
示例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");
}
示例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;
}
示例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);
}
}
示例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;
}
示例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());
}
}
示例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);
}
示例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());
}
示例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;
}
示例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);
}
示例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;
}
示例15: Mix_FadeInMusic
void Music::Play()
{
if ( !buffer )
return;
Mix_FadeInMusic( buffer, (isLoop ? -1 : 1), 100 );
Music::currentlyPlaying = this;
}