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

C++ Mix_QuerySpec函数代码示例

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

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



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

示例1: defined

/**\brief Audio system shutdown.
 */
bool Audio::Shutdown( void ){
	/* This is the cleaning up part */
	this->HaltAll();


#if defined(SDL_MIXER_MAJOR_VERSION) && (SDL_MIXER_MAJOR_VERSION>1) \
	&& (SDL_MIXER_MINOR_VERSON>2) && (SDL_MIXER_PATCHLEVEL>=10)
	// Free every library loaded
	const SDL_version *mix_version=Mix_Linked_Version();
	if( (mix_version->major>=1) && (mix_version->minor>=2) && (mix_version->patch>=10) ){
		while(Mix_Init(0))
			Mix_Quit();
	}
#endif // SDL_Mixer version requirements

	// Query number of times audio device was opened (should be 1)
	int freq, chan, ntimes;
	Uint16 format;
	if ( (ntimes = Mix_QuerySpec( &freq, &format, &chan )) != 1 )
		LogMsg(WARN,"Audio was initialized multiple times.");

	// Close as many times as opened.
	for ( int i = 0; i < ntimes; i++ )
		Mix_CloseAudio();
	return true;
}
开发者ID:digital-phoenix,项目名称:Epiar,代码行数:28,代码来源:audio.cpp


示例2: Audio

AudioSDLMixer::AudioSDLMixer(AudioConfig &sc)
  : Audio(sc), audio_open(0), music(NULL), oldPlaying(false)
{
  if ( SDL_InitSubSystem(SDL_INIT_AUDIO) < 0 ) 
    throw std::runtime_error(std::string("Couldn't initialize SDL: ")+SDL_GetError());
    
  /* Open the audio device */
  int audio_rate = m_sc.srate;
  Uint16 audio_format=AUDIO_S8;
  if (m_sc.sbits==16)
    audio_format=AUDIO_S16;
  int audio_channels=1;
  if (m_sc.stereo) audio_channels=2;
  int audio_buffers = m_sc.sbuffers;

  if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
    throw std::runtime_error(std::string("Couldn't open audio: ")+SDL_GetError());
  } else {
    Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
    /*    printf("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", audio_rate,
	   (audio_format&0xFF),
	   (audio_channels > 1) ? "stereo" : "mono", 
	   audio_buffers ); */
  }
  audio_open = 1;
  
  /* Set the external music player, if any */
  // TODO: perhaps we should not use this for security reasons
  Mix_SetMusicCMD(getenv("MUSIC_CMD"));
}
开发者ID:BackupTheBerlios,项目名称:egachine,代码行数:30,代码来源:audiosdlmixer.cpp


示例3: sound_mix_load

/**
 * @brief Loads a sound into the sound_list.
 *
 *    @param filename Name fo the file to load.
 *    @return The SDL_Mixer of the loaded chunk.
 *
 * @sa sound_makeList
 */
int sound_mix_load( alSound *s, const char *filename )
{
   SDL_RWops *rw;
   int freq, bytes, channels;
   Uint16 format;

   /* get the file data buffer from packfile */
   rw = ndata_rwops( filename );

   /* bind to buffer */
   s->u.mix.buf = Mix_LoadWAV_RW(rw,1);
   if (s->u.mix.buf == NULL) {
      DEBUG("Unable to load sound '%s': %s", filename, Mix_GetError());
      return -1;
   }

   /* Get spec. */
   Mix_QuerySpec( &freq, &format, &channels );
   switch (format) {
      case AUDIO_U8:
      case AUDIO_S8:
         bytes = 1;
         break;
      default:
         bytes = 2;
         break;
   }

   /* Set length. */
   s->length = (double)s->u.mix.buf->alen / (double)(freq*bytes*channels);

   return 0;
}
开发者ID:Arakash,项目名称:naev,代码行数:41,代码来源:sound_sdlmix.c


示例4: print_MixerVersion

/**
 * @brief Prints the current and compiled SDL_Mixer versions.
 */
static void print_MixerVersion (void)
{
   int frequency;
   Uint16 format;
   int channels;
   SDL_version compiled;
   const SDL_version *linked;
   char device[PATH_MAX];

   /* Query stuff. */
   Mix_QuerySpec(&frequency, &format, &channels);
   MIX_VERSION(&compiled);
   linked = Mix_Linked_Version();
   SDL_AudioDriverName(device, PATH_MAX);

   /* Version itself. */
   DEBUG("SDL_Mixer Started: %d Hz %s", frequency,
         (channels == 2) ? "Stereo" : "Mono" );
   /* Check if major/minor version differ. */
   if ((linked->major*100 + linked->minor) > compiled.major*100 + compiled.minor)
      WARN("SDL_Mixer is newer than compiled version");
   if ((linked->major*100 + linked->minor) < compiled.major*100 + compiled.minor)
      WARN("SDL_Mixer is older than compiled version.");
   /* Print other debug info. */
   DEBUG("Renderer: %s",device);
   DEBUG("Version: %d.%d.%d [compiled: %d.%d.%d]", 
         compiled.major, compiled.minor, compiled.patch,
         linked->major, linked->minor, linked->patch);
   DEBUG();
}
开发者ID:Arakash,项目名称:naev,代码行数:33,代码来源:sound_sdlmix.c


示例5: initSound

void initSound() {
  int audio_rate;
  Uint16 audio_format;
  int audio_channels;
  int audio_buffers;

  if ( SDL_InitSubSystem(SDL_INIT_AUDIO) < 0 ) {
    fprintf(stderr, "Unable to initialize SDL_AUDIO: %s\n", SDL_GetError());
    return;
  }

  audio_rate = 44100;
  audio_format = AUDIO_S16;
  audio_channels = 1;
  audio_buffers = 4096;
  
  if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
    fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
    return;
  } else {
    Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
  }

  useAudio = 1;
  loadSounds();
}
开发者ID:kazuya-watanabe,项目名称:rrootage,代码行数:26,代码来源:soundmanager.c


示例6: SDLIsInitialized

static dboolean SDLIsInitialized(void)
{
    int         freq, channels;
    Uint16      format;

    return (!!Mix_QuerySpec(&freq, &format, &channels));
}
开发者ID:mdgunn,项目名称:doomretro,代码行数:7,代码来源:i_music.c


示例7: LogMsg

/**\brief Audio system initialization.
 */
bool Audio::Initialize( void ) {
	if( initialized ) {
		return false;
	}

	if(OPTION(bool, "options/sound/disable-audio")) {
		LogMsg(INFO, "Not initializing audio as it is disabled.");
		return true; // audio is disabled
	}

	if(SDL_Init(SDL_INIT_AUDIO) < 0) {
		LogMsg(ERR, "SDL could not initialize audio: %s", SDL_GetError());
		return false;
	}

	if(Mix_OpenAudio(this->audio_rate, this->audio_format, this->audio_channels, this->audio_buffers)) {
		LogMsg(ERR, "Audio initialization failed!: %s", Mix_GetError());
		return false;
	}

	Mix_QuerySpec(&this->audio_rate, &this->audio_format, &this->audio_channels);

	LogMsg(DEBUG, "SDL_mixer gave us rate %d, format %d, channels %d", this->audio_rate, this->audio_format, this->audio_channels);

	// Load MOD and OGG libraries
	Mix_Init( MIX_INIT_MOD | MIX_INIT_OGG );

	// Allocate channels
	Mix_AllocateChannels( this->max_chan);

	assert( this->max_chan == static_cast<unsigned int>(this->GetTotalChannels()) );

	return true;
}
开发者ID:cthielen,项目名称:epiar,代码行数:36,代码来源:audio.cpp


示例8: Mix_HaltChannel

/**\brief Audio system shutdown.
 */
bool Audio::Shutdown( void ) {
	if(OPTION(bool, "options/sound/disable-audio")) {
		return true; // audio is disabled
	}

	/* Halt all currently playing sounds */
	Mix_HaltChannel( -1 );

	// Free every library loaded
	while(Mix_Init(0)) {
		Mix_Quit();
	}

	// Query number of times audio device was opened (should be 1)
	int freq, chan, ntimes;
	Uint16 format;
	ntimes = Mix_QuerySpec( &freq, &format, &chan );

	LogMsg(DEBUG, "Audio Query: %d Frequencies, Format: %d, Channels: %s.", freq, format, (chan==2?"Stereo":"Mono"));

	if(ntimes != 1 ) {
		LogMsg(WARN, "Audio was initialized %d times.", ntimes);
	}

	// Close only if open
	if( ntimes ) {
		Mix_CloseAudio();
	}

	return true;
}
开发者ID:cthielen,项目名称:epiar,代码行数:33,代码来源:audio.cpp


示例9: start_sound_engine

static bool start_sound_engine()
{
  /* This is where we open up our audio device.  Mix_OpenAudio takes
     as its parameters the audio format we'd /like/ to have. */
  if(Mix_OpenAudio(info.rate, info.format, info.channels, info.buffers))
  {
    GB.Error("Unable to open audio");
    return TRUE;
  }

	if (pipe(_ch_pipe))
	{
		GB.Error("Unable to initialize channel pipe");
		return TRUE;
	}
	
  Mix_QuerySpec(&info.rate, &info.format, &info.channels);
	//fprintf(stderr, "Mix_QuerySpec: %d %d %d\n", info.rate, info.format, info.channels);

  channel_count = Mix_AllocateChannels(-1);

  Mix_ChannelFinished(channel_finished);

	return FALSE;
}
开发者ID:ramonelalto,项目名称:gambas,代码行数:25,代码来源:sound.c


示例10: Mix_QuerySpec

void SoundManager::ShutdownMix()
{
  // for each Mix_OpenAudio call, there must be corresponding Mix_CloseAudio call
  int numOpen = Mix_QuerySpec(nullptr, nullptr, nullptr);
  for (int i = 0; i < numOpen; ++i)
    Mix_CloseAudio();
}
开发者ID:Valtis,项目名称:Peliprojekti-2013,代码行数:7,代码来源:SoundManager.cpp


示例11: defined

/**\brief Audio system shutdown.
 */
bool Audio::Shutdown( void ){
	/* This is the cleaning up part */
	this->HaltAll();


#if defined(SDL_MIXER_MAJOR_VERSION) && (SDL_MIXER_MAJOR_VERSION>1) \
	&& (SDL_MIXER_MINOR_VERSON>2) && (SDL_MIXER_PATCHLEVEL>=10)
	// Free every library loaded
	const SDL_version *mix_version=Mix_Linked_Version();
	if( (mix_version->major>=1) && (mix_version->minor>=2) && (mix_version->patch>=10) ){
		while(Mix_Init(0))
			Mix_Quit();
	}
#endif // SDL_Mixer version requirements

	// Query number of times audio device was opened (should be 1)
	int freq, chan, ntimes;
	Uint16 format;
	ntimes = Mix_QuerySpec( &freq, &format, &chan );

	LogMsg(INFO,"Audio Query: %d Frequencies, Format: %d, Channels: %s.", freq, format, (chan==2?"Stereo":"Mono"));

	if(ntimes != 1 ) {
		LogMsg(WARN,"Audio was initialized %d times.", ntimes);
	}

	// Close only if open
	if( ntimes ) {
		Mix_CloseAudio();
	}

	return true;
}
开发者ID:DuMuT6p,项目名称:Epiar,代码行数:35,代码来源:audio.cpp


示例12: S_Init

/*
 * S_Init
 */
void S_Init(void) {
	int freq, channels;
	unsigned short format;

	memset(&s_env, 0, sizeof(s_env));

	if (Cvar_GetValue("s_disable")) {
		Com_Warn("Sound disabled.\n");
		return;
	}

	Com_Print("Sound initialization...\n");

	s_rate = Cvar_Get("s_rate", "44100", CVAR_ARCHIVE | CVAR_S_DEVICE,
			"Sound sampling rate in Hz.");
	s_reverse = Cvar_Get("s_reverse", "0", CVAR_ARCHIVE,
			"Reverse left and right channels.");
	s_volume = Cvar_Get("s_volume", "1.0", CVAR_ARCHIVE,
			"Global sound volume level.");

	Cmd_AddCommand("s_restart", S_Restart_f, "Restart the sound subsystem");
	Cmd_AddCommand("s_play", S_Play_f, NULL);
	Cmd_AddCommand("s_stop", S_Stop_f, NULL);
	Cmd_AddCommand("s_list", S_List_f, NULL);

	if (SDL_WasInit(SDL_INIT_EVERYTHING) == 0) {
		if (SDL_Init(SDL_INIT_AUDIO) < 0) {
			Com_Warn("S_Init: %s.\n", SDL_GetError());
			return;
		}
	} else if (SDL_WasInit(SDL_INIT_AUDIO) == 0) {
		if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
			Com_Warn("S_Init: %s.\n", SDL_GetError());
			return;
		}
	}

	if (Mix_OpenAudio(s_rate->integer, MIX_DEFAULT_FORMAT, 2, 1024) == -1) {
		Com_Warn("S_Init: %s\n", Mix_GetError());
		return;
	}

	if (Mix_QuerySpec(&freq, &format, &channels) == 0) {
		Com_Warn("S_Init: %s\n", Mix_GetError());
		return;
	}

	if (Mix_AllocateChannels(MAX_CHANNELS) != MAX_CHANNELS) {
		Com_Warn("S_Init: %s\n", Mix_GetError());
		return;
	}

	Mix_ChannelFinished(S_FreeChannel);

	Com_Print("Sound initialized %dKHz %d channels.\n", freq, channels);

	s_env.initialized = true;

	S_InitMusic();
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:63,代码来源:s_main.c


示例13: Mix_OpenAudio

bool AudioDevice::init(Log* _debugLog) {

    debugLog = _debugLog;

    if (debugLog != NULL) {
        debugLog->printf("Initializing audio system with default settings\n");
    }

    int audioRate           = MIX_DEFAULT_FREQUENCY;
    uint16 audioFormat      = MIX_DEFAULT_FORMAT;
    int audioChannels       = 2; // stereo

    bool ret = Mix_OpenAudio(audioRate, audioFormat, audioChannels, 4096) >= 0;

    if (debugLog != NULL) {
        if (ret) {
            debugLog->println("Audio initalization      Ok");
        } else {
            debugLog->println("Audio initalization      FAIL");
            debugLog->printf("Couldn't open audio: %s\n", SDL_GetError());
        }
    }

    if (ret) {
        Mix_QuerySpec(&audioRate, &audioFormat, &audioChannels);
    }

    return ret;
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:29,代码来源:AudioDevice.cpp


示例14: close_sound

void close_sound() 
{
	int numtimesopened, frequency, channels;
	Uint16 format;

	if (mix_ok) {
		stop_bell();
		stop_UI_sound();
		stop_sound();
		sound_cache.clear();
		stop_music();
		mix_ok = false;

		numtimesopened = Mix_QuerySpec(&frequency, &format, &channels);
		if(numtimesopened == 0) {
			ERR_AUDIO << "Error closing audio device: " << Mix_GetError() << "\n";
		}
		while (numtimesopened) {
			Mix_CloseAudio();
			--numtimesopened;
		}
	}
	if (SDL_WasInit(SDL_INIT_AUDIO) != 0) {
		SDL_QuitSubSystem(SDL_INIT_AUDIO);
	}

	LOG_AUDIO << "Audio device released.\n";
}
开发者ID:suxinde2009,项目名称:Rose,代码行数:28,代码来源:sound.cpp


示例15: SDLIsInitialized

static int SDLIsInitialized(void)
{
    int freq, channels;
    Uint16 format;

    return Mix_QuerySpec(&freq, &format, &channels);
}
开发者ID:Clever-Boy,项目名称:chocolate-doom,代码行数:7,代码来源:opl_sdl.c


示例16: CleanupT4KCommon

void CleanupT4KCommon(void)
{
    int frequency, channels, n_timesopened;
    Uint16 format;

    // Close the audio mixer. We have to do this at least as many times
    // as it was opened.
    n_timesopened = Mix_QuerySpec(&frequency, &format, &channels);
    while (n_timesopened)
    {
	Mix_CloseAudio();
	n_timesopened--;
    }
    
    T4K_UnloadMenus();
    // Unload SDL_Pango or SDL_ttf:
    T4K_Cleanup_SDL_Text();
    
#ifdef HAVE_LIBSDL_NET
    /* Quit networking if appropriate: */
    SDLNet_Quit();
#endif

    // Finally, quit SDL
    SDL_Quit();
}
开发者ID:Nalin-x-Linux,项目名称:t4kcommon-1,代码行数:26,代码来源:t4k_main.c


示例17: snd_hz

int snd_hz(void)
{
	int freq = 0;
	if (sound_on)
		Mix_QuerySpec(&freq, NULL, NULL);
	return freq;
}
开发者ID:wimh,项目名称:instead,代码行数:7,代码来源:sound.c


示例18: Snd_Init

void Snd_Init()
{
	printf( "Initializing Sound\n" );

	//return;

	/* Initialize variables */
	audio_rate = MIX_DEFAULT_FREQUENCY;
	audio_format = MIX_DEFAULT_FORMAT;
	audio_channels = 2;

	/* Open Device */
	if( Mix_OpenAudio( audio_rate, audio_format, audio_channels, 4096 ) < 0 )
	{
		printf( "ERROR: Couldn't open audio device\n" );
	}
	else
	{
		printf( "Trying to query audio device\n" );
		Mix_QuerySpec( &audio_rate, &audio_format, &audio_channels );
		printf( "Successfully opened audio device\n" );
		printf("Opened audio at %d Hz %d bit %s\n", audio_rate, (audio_format&0xFF), (audio_channels > 1) ? "stereo" : "mono");
	}

	audioOpen = True;
	soundcount = 0;

	bPlaySounds = True;

	nullsound.soundid = -1;
}
开发者ID:tonymagro,项目名称:stroids3d,代码行数:31,代码来源:sdl_sound.c


示例19: LogMsg

/**\brief Audio system initialization.
 */
bool Audio::Initialize( void ){
	if ( this -> initstatus )
		return false;				// Already initialized

	if(SDL_Init(SDL_INIT_AUDIO) < 0) {
		LogMsg(CRITICAL,"SDL could not initialize audio: %s", SDL_GetError());
	}

	if(Mix_OpenAudio(this->audio_rate,
				this->audio_format,
				this->audio_channels,
				this->audio_buffers)){
		LogMsg(CRITICAL,"Audio initialization failed!: %s", Mix_GetError());
		return false;
	}

	Mix_QuerySpec(&this->audio_rate, &this->audio_format, &this->audio_channels);
	LogMsg(INFO,"SDL_mixer gave us rate %d, format %d, channels %d", this->audio_rate, this->audio_format, this->audio_channels);

#if defined(SDL_MIXER_MAJOR_VERSION) && (SDL_MIXER_MAJOR_VERSION>1) \
	&& (SDL_MIXER_MINOR_VERSON>2) && (SDL_MIXER_PATCHLEVEL>=10)
	// Load MOD and OGG libraries (If SDL_mixer version supports it)
	const SDL_version *mix_version=Mix_Linked_Version();
	if( (mix_version->major >= 1) && (mix_version->minor >= 2) && (mix_version->patch >= 10) ){
		LogMsg(INFO,"This SDL_mixer version supports dynamic library loading.");
		Mix_Init( MIX_INIT_MOD | MIX_INIT_OGG );
	}
#endif // SDL_MIXER version requirements

	// Allocate channels
	Mix_AllocateChannels( this->max_chan);
	assert( this->max_chan == static_cast<unsigned int>(this->GetTotalChannels()) );

	return true;
}
开发者ID:DuMuT6p,项目名称:Epiar,代码行数:37,代码来源:audio.cpp


示例20: SDLSoundChannel

   SDLSoundChannel(const ByteArray &inBytes, const SoundTransform &inTransform)
   {
      Mix_QuerySpec(&mFrequency, &mFormat, &mChannels);
      if (mFrequency!=44100)
         ELOG("Warning - Frequency mismatch %d",mFrequency);
      if (mFormat!=32784)
         ELOG("Warning - Format mismatch    %d",mFormat);
      if (mChannels!=2)
         ELOG("Warning - channe mismatch    %d",mChannels);


      mChunk = 0;
      mDynamicBuffer = new short[BUF_SIZE * STEREO_SAMPLES];
      memset(mDynamicBuffer,0,BUF_SIZE*sizeof(short));
      mSound = 0;
      mChannel = -1;
      mDynamicChunk.allocated = 0;
      mDynamicChunk.abuf = (Uint8 *)mDynamicBuffer;
      mDynamicChunk.alen = BUF_SIZE * sizeof(short) * STEREO_SAMPLES; // bytes
      mDynamicChunk.volume = MIX_MAX_VOLUME;
	  #ifndef WEBOS
	   mDynamicChunk.length_ticks = 0;
	  #endif
      mDynamicFillPos = 0;
      mDynamicStartPos = 0;
      mDynamicDataDue = 0;

      // Allocate myself a channel
      for(int i=0;i<sMaxChannels;i++)
         if (!sUsedChannel[i])
         {
            IncRef();
            sDoneChannel[i] = false;
            sUsedChannel[i] = true;
            mChannel = i;
            break;
         }

      if (mChannel>=0)
      {
         FillBuffer(inBytes);
         // Just once ...
         if (mDynamicFillPos<1024)
         {
            mDynamicDone = true;
            mDynamicChunk.alen = mDynamicFillPos * sizeof(short) * STEREO_SAMPLES;
            Mix_PlayChannel( mChannel , &mDynamicChunk,  0 );
         }
         else
         {
            mDynamicDone = false;
            // TODO: Lock?
            Mix_PlayChannel( mChannel , &mDynamicChunk,  -1 );
            mDynamicStartPos = sSoundPos;
         }

         Mix_Volume( mChannel, inTransform.volume*MIX_MAX_VOLUME );
      }
   }
开发者ID:aaulia,项目名称:NME,代码行数:59,代码来源:SDLSound.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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