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

C++ Mix_VolumeChunk函数代码示例

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

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



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

示例1: Load

void SoundMix::PlaySoundWithVolume( int sound, int volume )
{

	if (Config::GetSound()!=1)
	{
		return;
	}

	wave = Load( sound );

	if ( !wave )
	{
		return;
	}

	if ( wave )
	{
		Mix_VolumeChunk( wave, volume );
		if ( Mix_PlayChannel( -1, wave, 0 ) == -1 )
		{
			printf( "Mix_PlayChannel: %s\n", Mix_GetError() );
			// may be critical error, or maybe just no channels were free.
			// you could allocated another channel in that case...
			Mix_FreeChunk( wave );
			wave = NULL;
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:iris-svn,代码行数:28,代码来源:SoundMixer.cpp


示例2: set_sound_volume

/*! 
  Change volume for a sound associated with the specified sound context
  \pre     sound_context != NULL
  \arg \c  sound_context the sound context
       \i  volume is a value 0-128 
  \return  true if volume was set; false otherwise
  \author  ehall
  \date    Created:  2000-09-13
  \date    Modified: 2000-09-13
*/
bool_t set_sound_volume( char *sound_context, int volume )
{
    int i;
    sound_context_data_t *data;

    if ( ! get_hash_entry( sound_contexts_, sound_context, 
			   (hash_entry_t*) &data ) ) {
	return False;
    }
    data->volume = volume;

    i = (int) (((double)data->num_sounds)*rand()/(RAND_MAX+1.0));
    for ( i=0; i<data->num_sounds; i++ ) {
	if ( data->chunks[i] == NULL ) {
	    bool_t found;
	    found = get_sound_data( data->sound_names[i], &(data->chunks[i]) );
	    check_assertion( found, "sound name not found" );
	    check_assertion( data->chunks[i]!=NULL, "sound chunk not set" );
	}

	Mix_VolumeChunk( data->chunks[i], data->volume );

    }
    return True;
}
开发者ID:LeifAndersen,项目名称:TuxRider,代码行数:35,代码来源:audio.c


示例3: PlaySound

extern void PlaySound(char * file, unsigned char volume, int channel, int times)
{
	Mix_Chunk* soundeff = SoundEffects.find(file)->second;
	Mix_PlayChannel(channel, soundeff, times - 1);

	Mix_VolumeChunk(soundeff, volume);
}
开发者ID:UltimaOmega,项目名称:TouhouEngine-CPP---Github,代码行数:7,代码来源:sounds.cpp


示例4: Mix_FreeChunk

void THSoundEffects::setSoundArchive(THSoundArchive *pArchive)
{
    for(size_t i = 0; i < m_iSoundCount; ++i)
    {
        Mix_FreeChunk(m_ppSounds[i]);
    }
    delete[] m_ppSounds;
    m_ppSounds = NULL;
    m_iSoundCount = 0;

    if(pArchive == NULL)
        return;

    m_ppSounds = new Mix_Chunk*[pArchive->getSoundCount()];
    for(; m_iSoundCount < pArchive->getSoundCount(); ++m_iSoundCount)
    {
        m_ppSounds[m_iSoundCount] = NULL;
        SDL_RWops *pRwop = pArchive->loadSound(m_iSoundCount);
        if(pRwop)
        {
            m_ppSounds[m_iSoundCount] = Mix_LoadWAV_RW(pRwop, 1);
            if(m_ppSounds[m_iSoundCount])
                Mix_VolumeChunk(m_ppSounds[m_iSoundCount], MIX_MAX_VOLUME);
        }
    }
}
开发者ID:MarkL1961,项目名称:CorsixTH,代码行数:26,代码来源:th_sound.cpp


示例5: play_sound

static void *
play_sound(const char *filename, int loop, double volume)
{
    struct player_sound *sound;
    unsigned long hash;
    int sdl_volume = (int)(volume * MIX_MAX_VOLUME);

    hash = crc32(0, (void *)filename, strlen(filename));
    hash %= sizeof(sounds) / sizeof(sounds[0]);
    for (sound = sounds[hash]; sound != NULL; sound = sound->next) {
        if (strcmp(filename, sound->filename) == 0)
            break;
    }

    if (sound == NULL) {
        fprintf(stderr, "play_sound: %s not loaded?\n", filename);
        return NULL;
    }

    if (sound->chunk != NULL) {
        Mix_VolumeChunk(sound->chunk, sdl_volume);
        sound->chunk_channel = Mix_PlayChannel(-1, sound->chunk, loop ? -1 : 0);
    } else if (sound->music != NULL) {
        Mix_HaltMusic();
        active_music = sound->music;
        Mix_VolumeMusic(sdl_volume);
        Mix_PlayMusic(sound->music, loop ? -1 : 1);
    }
    return sound;
}
开发者ID:crowriot,项目名称:apkenv,代码行数:30,代码来源:worldofgoo.c


示例6: Mix_FreeChunk

void sound_player::populate_from(sound_archive *pArchive)
{
    for(size_t i = 0; i < sound_count; ++i)
    {
        Mix_FreeChunk(sounds[i]);
    }
    delete[] sounds;
    sounds = nullptr;
    sound_count = 0;

    if(pArchive == nullptr)
        return;

    sounds = new Mix_Chunk*[pArchive->get_number_of_sounds()];
    for(; sound_count < pArchive->get_number_of_sounds(); ++sound_count)
    {
        sounds[sound_count] = nullptr;
        SDL_RWops *pRwop = pArchive->load_sound(sound_count);
        if(pRwop)
        {
            sounds[sound_count] = Mix_LoadWAV_RW(pRwop, 1);
            if(sounds[sound_count])
                Mix_VolumeChunk(sounds[sound_count], MIX_MAX_VOLUME);
        }
    }
}
开发者ID:TheCycoONE,项目名称:CorsixTH,代码行数:26,代码来源:th_sound.cpp


示例7: sdlplayer_fx

int sdlplayer_fx(char *filename, int volume)
{
  Mix_Chunk *sample;

  g_warning("sdlplayer %s\n", filename);

  sample=Mix_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1);
  if(!sample) {
    return(cleanExit("Mix_LoadWAV_RW"));
    // handle error
  }

  Mix_VolumeChunk(sample, MIX_MAX_VOLUME);

  if((_channel_fx = Mix_PlayChannel(-1, sample, 0))==-1) {
    return(cleanExit("Mix_LoadChannel(0x%p,1)", _channel_fx));
  }

  while( Mix_Playing( _channel_fx ) )
    {
      SDL_Delay(50);
    }

  // free the sample
  // Mix_Chunk *sample;
  Mix_FreeChunk(sample);
  _channel_fx = -1;

  g_warning("sdlplayer complete playing of %s\n", filename);

  return(0);
}
开发者ID:GNOME,项目名称:gcompris,代码行数:32,代码来源:sdlplayer.c


示例8: noegnud_sound_play

void noegnud_sound_play(const char *filename,float volume) {
    noegnud_tcollection *soundcollection;
    noegnud_sound_tsound *sound;
    int internal_volume;

    if (!noegnud_sound_initialised) return;

    soundcollection=noegnud_sound_load(filename);
    if (soundcollection) {
	if (volume<0) volume=0;
	if (volume>1) volume=1;

	sound=(noegnud_sound_tsound *)soundcollection->data;
	internal_volume=volume*MIX_MAX_VOLUME;
	if (sound->chunk) {
#ifdef NOEGNUDDEBUG
	    printf("[SOUND] noegnud_sound_play: playing chunk \"%s\" (%2.3f)\n",filename,volume);
#endif
	    Mix_VolumeChunk(sound->chunk,internal_volume);
	    Mix_PlayChannel(-1,sound->chunk,0);
	} else if (sound->music) {
#ifdef NOEGNUDDEBUG
	    printf("[SOUND] noegnud_sound_play: playing music \"%s\" (%2.3f)\n",filename,volume);
#endif
	    Mix_VolumeMusic(internal_volume);
	    Mix_PlayMusic(sound->music,0);
	} else {
	    printf("[SOUND] WARNING: noegnud_sound_play: unknown file format/could not load \"%s\"\n",filename);
	}
    } else {
	printf("[SOUND] noegnud_sound_play: could not load/play \"%s\"\n",filename);
    }
}
开发者ID:chasonr,项目名称:noegnud-0.8.5,代码行数:33,代码来源:noegnud_sound.c


示例9: Mix_LoadWAV

void PGE_Sounds::SND_PlaySnd(QString sndFile)
{
    if(current!=sndFile)
    {
        #ifdef USE_QMEDIAPLAYER
        if(mp3Play) { mp3Play->stop(); delete mp3Play; mp3Play=NULL; }
        #elif USE_SDL_MIXER
        if(sound) { Mix_FreeChunk(sound); sound=NULL; }
        sound = Mix_LoadWAV(sndFile.toUtf8().data() );
        if(!sound)
            qDebug() << QString("Mix_LoadWAV: %1").arg(SDL_GetError());
        else
            Mix_VolumeChunk(sound, MIX_MAX_VOLUME);
        #endif
        current = sndFile;
    }

    #ifdef USE_QMEDIAPLAYER
    qDebug() << QString("Play Sound (QMediaPlayer)");
    if(!mp3Play)
    {
        qDebug() << QString("QMediaPlayer is null");
    }
    else
        mp3Play->play();
    #elif USE_SDL_MIXER

    LogDebug(QString("Play Sound (SDL2_mixer)"));
    if(Mix_PlayChannel( -1, sound, 0 )==-1)
    {
        qDebug() << QString("Mix_PlayChannel: %1").arg(SDL_GetError());
    }

#endif
}
开发者ID:zigurana,项目名称:PGE-Project,代码行数:35,代码来源:sdl_music_player.cpp


示例10: Mix_VolumeChunk

void TempFigure::setFigure(int x, int y, Surface& image, SDL_Surface* screen,
      int levelWidth, int levelHeight) {
   Figure::setFigure(x, y, image, screen, GRAVITY_DISABLED, levelWidth,
         levelHeight, false, 5, 1, 1, 1);
   scratch.setChunk("sounds/scratch.wav");
   Mix_VolumeChunk(scratch.getMix_Chunk(), 128);
   marker = ACTIVE;
}
开发者ID:allesrebel,项目名称:SDLGameEngine,代码行数:8,代码来源:TempFigure.cpp


示例11: sound_playfx

//------------------------------
// Sound functions
//------------------------------
void sound_playfx(Mix_Chunk* snd)
{
    if(sound_enabled == true)
    {
        Mix_VolumeChunk(snd, sound_volfx*10);
        Mix_PlayChannel( -1, snd, 0 );
    }
}
开发者ID:dorkster,项目名称:espada,代码行数:11,代码来源:main.c


示例12: Mix_VolumeChunk

	void SoundSystem::SetAllSoundEffectVolumes(int volume)
	{
		if (volume > 128) { volume = 128; } else if (volume < 0) { volume = 0; }

		for (auto& it : m_SoundEffect) {
			Mix_VolumeChunk(it.second.get(), volume);
		}
	}
开发者ID:reworks,项目名称:ECSREngine,代码行数:8,代码来源:SoundSystem.cpp


示例13: Mix_VolumeChunk

 void platform_support::play_sound(unsigned idx, unsigned vol)
 {
    if (idx >= max_images || !m_specific->m_sounds[idx])
    {
       return;
    }
    Mix_VolumeChunk(m_specific->m_sounds[idx], vol);
    Mix_PlayChannel( -1, m_specific->m_sounds[idx], 0 );
 }
开发者ID:przemekr,项目名称:my_slide,代码行数:9,代码来源:agg_platform_support.cpp


示例14: set_strings_volume

void set_strings_volume(void)
{
	int i;
	for(i=0;i<128;i++)
	{
		Mix_VolumeChunk(strings_note_chunk[i],(int)(MIX_MAX_VOLUME*strings_volume));
	}
	
}
开发者ID:VWarlock,项目名称:my_demos,代码行数:9,代码来源:sound.c


示例15: Mix_VolumeChunk

void CSoundEffect::SetVolume(const u32 a_Volume)
{
    if (a_Volume >= 0 && a_Volume <= MIX_MAX_VOLUME)
    {
        m_Volume = a_Volume;
        if (m_Chunk != nullptr)
            Mix_VolumeChunk(m_Chunk, m_Volume);
    }
}
开发者ID:roig,项目名称:Endavant,代码行数:9,代码来源:CSoundEffect.cpp


示例16: mrb_sdl2_mixer_chunk_volume

static mrb_value
mrb_sdl2_mixer_chunk_volume(mrb_state *mrb, mrb_value self)
{
  Mix_Chunk *c;
  mrb_int volume;
  mrb_get_args(mrb, "i", &volume);
  c = mrb_sdl2_chunk_get_ptr(mrb, self);
  return mrb_fixnum_value(Mix_VolumeChunk(c, volume));
}
开发者ID:Moon4u,项目名称:mruby-sdl2-mixer,代码行数:9,代码来源:sdl2-mixer.c


示例17: playSound

void playSound(char *name)
{
	int i;
	Mix_Chunk *chunk = NULL;

	if (game.audio == FALSE || game.sfxDefaultVolume == 0)
	{
		return;
	}

	for (i=0;i<soundIndex;i++)
	{
		if (strcmpignorecase(sound[i].name, name) == 0)
		{
			chunk = sound[i].effect;

			if (chunk == NULL)
			{
				return;
			}

			break;
		}
	}

	if (chunk == NULL)
	{
		if (soundIndex == MAX_SOUNDS)
		{
			showErrorAndExit("Ran out of space for sounds");
		}

		chunk = loadSound(name);

		sound[soundIndex].effect = chunk;

		STRNCPY(sound[soundIndex].name, name, sizeof(sound[soundIndex].name));

		soundIndex++;

		if (chunk == NULL)
		{
			return;
		}
	}

	Mix_VolumeChunk(chunk, game.sfxDefaultVolume * VOLUME_STEPS);

	#if DEV == 1
	if (game.gameType == REPLAYING)
	{
		printf("%f %s\n", (float)game.frames / 60, name);
	}
	#endif

	playSoundChunk(chunk, -1, 0);
}
开发者ID:LibreGames,项目名称:edgar,代码行数:57,代码来源:audio.c


示例18: set_piano_volume

void set_piano_volume(void)
{
	int i;
	for(i=0;i<128;i++)
	{
		Mix_VolumeChunk(piano_note_chunk[i],(int)(MIX_MAX_VOLUME*piano_volume));
	}
	
}
开发者ID:VWarlock,项目名称:my_demos,代码行数:9,代码来源:sound.c


示例19: while

void	Sounds::Mute_Sounds()
{
	unsigned int	i;

	i = 0;
	while (i != this->sounds.size())
	{
		Mix_VolumeChunk(this->sounds[i], 0);
	}
}
开发者ID:antoinechene,项目名称:FPS-openGL,代码行数:10,代码来源:Sounds_mix.cpp


示例20: Mix_VolumeChunk

void TMASound::play(bool loop,int volume,int pan)
{
    if (psound!=NULL)
    {
        if (volume>128) volume=128;
        Mix_VolumeChunk(psound,volume);
        ii_voice = Mix_PlayChannel(-1,psound,(loop)?(-1):0);
        //if (pan!=127) voice_set_pan(ii_voice,pan);
    }        
}
开发者ID:dmitrysmagin,项目名称:profadeluxe,代码行数:10,代码来源:tmasound.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ MlmeAllocateMemory函数代码示例发布时间:2022-05-30
下一篇:
C++ Mix_SetError函数代码示例发布时间: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