• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Mix_FadeInMusic函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: mrb_sdl2_mixer_music_fade_in_pos

static mrb_value
mrb_sdl2_mixer_music_fade_in_pos(mrb_state *mrb, mrb_value self)
{
  Mix_Music *c;
  mrb_int loops, ms, pos;
  mrb_get_args(mrb, "iii", &loops, &ms, &pos);
  c = mrb_sdl2_music_get_ptr(mrb, self);
  return mrb_fixnum_value(Mix_FadeInMusic(c, loops, ms));
}
开发者ID:Moon4u,项目名称:mruby-sdl2-mixer,代码行数:9,代码来源:sdl2-mixer.c


示例17: StopMusic

void CSoundPlayer::PlayMusic(int aLooping)
{
	if (!iInitialized)
		return;

	StopMusic();
	Mix_FadeInMusic(iMusic,aLooping, KFadeInTime );
	SetMusicVolume(iMusicVolume);
}
开发者ID:emlai,项目名称:tapankaikki,代码行数:9,代码来源:CSoundPlayer.cpp


示例18: 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/positive.ogg",gameinfo->datafolder);
  data->snd_positive=Mix_LoadWAV(buffer);
  Mix_VolumeChunk(data->snd_positive,(int)(round(128.0*gameinfo->volume)));
	sprintf(buffer,"%ssounds/negative.ogg",gameinfo->datafolder);
  data->snd_negative=Mix_LoadWAV(buffer);
  Mix_VolumeChunk(data->snd_negative,(int)(round(128.0*gameinfo->volume)));
	sprintf(buffer,"%ssounds/Radio Martini.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);

  //Objekte laden  
  sprintf(buffer,"%stextures/reflexruebe.png",gameinfo->datafolder);
  data->texture=ZWloadtexturefromfileA(buffer,0,gameinfo->texquali);
  sprintf(buffer,"%smodels/ruebe.3dm",gameinfo->datafolder);
  ZWload3dm(&(data->ruebe),buffer,data->texture);
  ZWcreatedrawlist(&(data->ruebe),gameinfo->lightquali);
	sprintf(buffer,"%smodels/schild.3dm",gameinfo->datafolder);
  ZWload3dm(&(data->schild),buffer,data->texture);
  ZWcreatedrawlist(&(data->schild),0);

  //Licht!
  ZWenablelight(0);
  ZWsetlightambient(0,0.0,0.0,0.0);
  ZWsetlightdiffuse(0,1.0,1.0,1.0);
  ZWsetlightposition(0,0.0,0.0,2.0);
  ZWsetmaterial(lnone);
	
	for (a=0;a<gameinfo->playernum;a++)
	{
	  data->points[a]=0;
		data->blocked[a]=0;
	}
  
  //Spiel ansich vorbereiten
  data->step=0;
  data->fade=1;
  data->countdown=3000;
	data->schildposition=100.0;  
	data->gamestep=0;
	data->the_button=rand()%4;
}
开发者ID:theZiz,项目名称:OpenParty,代码行数:56,代码来源:reflexruebe.c


示例19: sound_playmus

void sound_playmus()
{
    if(sound_enabled == true)
    {
        if(Mix_FadeInMusic(music, -1, sound_fadetime) == -1)
            return;
        else
            Mix_VolumeMusic(sound_volmus*10);
    }
}
开发者ID:dorkster,项目名称:espada,代码行数:10,代码来源:main.c


示例20: rate

void AudioEngine::play_music(std::string file_location) {
    if(currently_playing.compare(file_location) != 0) { //only change the song if it's not already playing!
        //Initialise audio variables
        int audio_rate;      //output sampling rate (in Hz)
        Uint16 audio_format; //output sample format.
        int audio_channels;  //the number of channels for the output.
        int audio_buffers;   //the chunk size of the output, larger is better for slower machines but means the sound will be delayed more.
        int audio_volume;    //the volume at which you wish to play the music
        int looping;         //wether the music should loop or not


        // Initialize variables
        audio_rate =  MIX_DEFAULT_FREQUENCY; //22050
        audio_format = AUDIO_S16;            //Signed 16-bit samples, in little-endian byte order
        audio_channels = 2;                  //1 = mono, 2 = stereo
        audio_buffers = 4096;                //good value for slower machines and doesn't have too much delay (shouldn't matter too much for music vs sound effects anyway
        audio_volume = get_music_volume();
        looping = -1;                        //loop through the music forever

        //Initialise the audio API, returns -1 on errors so check it initialises correctly
        if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
            LOG(ERROR) << "Couldn't open audio: " << SDL_GetError(); //LOG why Audio couldn't be initialised
            audio_open = false;
            return;
        }
        //Query the auddio device for it's settings.
        Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);

        // Set the music volume
        set_music_volume(audio_volume);
    
        const char* c_file_location = file_location.c_str(); //Convert the file_location to a c string for the SDL API
        music = Mix_LoadMUS(c_file_location); //Load in the music

        if (music == nullptr ) {
            LOG(ERROR) << "Couldn't load " << c_file_location << ": " << SDL_GetError(); //print why music couldn't be loaded to the screen
            Mix_CloseAudio(); //close down the audio system
            audio_open = false;
            return;
        }

        //while(!Mix_FadeOutMusic(1000) && Mix_PlayingMusic()) {
        //	wait for any fades to complete
        //	SDL_Delay(100);
        //} //TODO: implement some sort of music (and screen!) fade

        //Start playing the music.
        if(Mix_FadeInMusic(music, looping, 2000) == -1) {
            LOG(ERROR) << "Mix_FadeInMusic: " << Mix_GetError();
            // well, there's no music, but most games don't break without music...
        }
        currently_playing = file_location;
    }
    return;
}
开发者ID:ALEXLCC,项目名称:pyland,代码行数:55,代码来源:audio_engine.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Mix_FadeOutChannel函数代码示例发布时间:2022-05-30
下一篇:
C++ Mix_AllocateChannels函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap