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


C++ CAudioManager类代码示例

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


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

示例1: ReadCrashSounds

//--------------------------------------------------------------------------------
//  Read Crash Sound
//--------------------------------------------------------------------------------
void CVehicleSound::ReadCrashSounds(SStream *st)
{ CAudioManager *snd = globals->snd;
  char txt[128];
  char fn[64];
  char  go = 1;
  Tag   tg = 0;
  while (go)
  { ReadString(txt,128,st);
    if (1 == sscanf(txt," gear , %s",fn))
    { snd->ReserveSoundBUF('crgr',fn,0) ;
      continue;
    }
    if (1 == sscanf(txt," body , %s",fn))
    { snd->ReserveSoundBUF('crby',fn,0);
      continue;
    }
    if (1 == sscanf(txt," shok , %s",fn))
    { snd->ReserveSoundBUF('shok',fn,0);
      continue;
    }

    go  = 0;
  }
  return;
}
开发者ID:FlySimvol,项目名称:FlyLegacy,代码行数:28,代码来源:PlaneSounds.cpp

示例2: SetEngineSound

//--------------------------------------------------------------------------------
//  SetSound with parameters
//--------------------------------------------------------------------------------
void CVehicleSound::SetEngineSound(Tag ids,char *fn)
{ CAudioManager *snd = globals->snd;
  CSoundBUF *sbf = snd->ReserveSoundBUF(ids,fn,sample);
  sbf->SetPMAX(pMax);
  sbf->SetPMIN(pMin);
  return;
}
开发者ID:FlySimvol,项目名称:FlyLegacy,代码行数:10,代码来源:PlaneSounds.cpp

示例3: Input

bool CGameOverState::Input( void )
{
	CController* pCtrl = CController::GetInstance();
	CAudioManager* pAUM = CAudioManager::GetInstance();

	if( pCtrl->Cancel() )
	{
		pAUM->Play(SFX::CURSOR);
		
		CGame::GetInstance()->GetState()->ChangeState( CHomeMenuState::GetInstance() );
		return true;
	}
		


	if (pCtrl->Confirm())
	{
		pAUM->Play(SFX::CURSOR);
		switch(m_nSelect)
		{
		case EXIT:	   CGame::GetInstance()->GetState()->ChangeState( CHomeMenuState::GetInstance() );
			return true;
			break;
		}
	}

	return true;
}
开发者ID:kendellm,项目名称:Trials-of-Mastery,代码行数:28,代码来源:GameOverState.cpp

示例4: update

cGameStateObject* cGameStateIntro::update(double timeDifference, Camera &cam, CGameData &data, CGraphics &con){
  m_event = EVENT_GO_NO_WHERE;
  
  //initialize data first time this state is called
  static bool bFirstTime = true;
  if(bFirstTime == true){
 
    CAudioManager *pAudio = CAudioManager::Instance();
    if(pAudio->IsPlaying(0) == false)    //nature sounds
      pAudio->PlaySoundClip(0, 1);
    if(pAudio->IsPlaying(13) == false)    //birds
      pAudio->PlaySoundClip(13, 1);

    bFirstTime = false;
  }

  //keystrokes
  if(::GetActiveWindow() == data.m_hWnd && keyDown(VK_SPACE))
    m_event = EVENT_GO_MAIN;

  for(unsigned int i=0; i< m_TE.size(); i++){
    if (m_TE[i].event == m_event){
      return m_TE[i].p_gso;
    }
  }
  return 0;
}
开发者ID:ChuckBolin,项目名称:CookieStealingOgre,代码行数:27,代码来源:cGameStateIntro.cpp

示例5: WorkThread

DWORD WINAPI CAudioManager::WorkThread( LPVOID lparam )
{
	CAudioManager *pThis = (CAudioManager *)lparam;
	while (pThis->m_bIsWorking)
			pThis->sendRecordBuffer();

	return -1;
}
开发者ID:xinba123,项目名称:shell,代码行数:8,代码来源:AudioManager.cpp

示例6: SetSound

//--------------------------------------------------------------------------------
//  SetSound with parameters
//--------------------------------------------------------------------------------
void CVehicleSound::SetSound(Tag ids,char *fn)
{ CAudioManager *snd = globals->snd;
  CSoundBUF *sbf = snd->ReserveSoundBUF(ids,fn,sample);
  sample  = 0;
  sbf->SetGain(volu);
  volu    = 1;
  return;
}
开发者ID:FlySimvol,项目名称:FlyLegacy,代码行数:11,代码来源:PlaneSounds.cpp

示例7: AddSound

//---------------------------------------------------------------------
//  Add a sound by tag to the list
//---------------------------------------------------------------------
void CSoundOBJ::AddSound(int No,Tag idn)
{ CAudioManager *snd = globals->snd;
  CSoundBUF *sbf = snd->GetSoundBUF(idn);
  if (sounds[No])   gtfo("Sound conflict");
  sounds[No]     = sbf;
	if (0 == sbf)		 return;
  if (No > sEnd)   sEnd = No;
  return;
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例8:

//---------------------------------------------------------------------
//  destroy this object
//---------------------------------------------------------------------
CSoundOBJ::~CSoundOBJ()
{ CAudioManager *snd = globals->snd;
  snd->DeleteSource(alSRC);
  for (int k=0; k < ENGINE_MAX_SOUND; k++)
  { CSoundBUF *sbf = sounds[k];
    if (0 == sbf)   continue;
    sbf->Release();
  }
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例9: update

cGameStateObject* cGameStateFireControl::update(double timeDifference){
  m_event = EVENT_GO_NO_WHERE;

  //loads mouse position into global variable.
  POINT pt;
  POINT *ppt = &pt;
  ::GetCursorPos(ppt);
  RECT rct;
  ::GetWindowRect(g_hWnd, &rct);
  g_Global.g_mouse.x = pt.x - rct.left;
  g_Global.g_mouse.y = pt.y - rct.top;
  
  CGameData *pData = CGameData::Instance();
  pData->Update(timeDifference);
  CAudioManager *pAudio = CAudioManager::Instance();

  static double timeDiffTotal = 0;
  timeDiffTotal += timeDifference;
  if(timeDiffTotal > .1){
    timeDiffTotal = 0;

    if(keyDown(VK_SPACE) && ::GetActiveWindow() == g_hWnd){
      CTorpedo torpedo(pData->m_Player.m_heading, pData->m_Player.m_heading, pData->m_Player.m_posX, pData->m_Player.m_posY);
      pData->m_torpedos.push_back(torpedo);
      //there are 2 torpedo sounds...play 1..if busy play 2
      if(pAudio->IsPlaying(SOUND_TORPEDO1) == false)
        pAudio->PlaySoundClip(SOUND_TORPEDO1, 0);
      else{
        if(pAudio->IsPlaying(SOUND_TORPEDO2) == false)
          pAudio->PlaySoundClip(SOUND_TORPEDO2, 0);
      }
    }
  
    //process short cut buttons
    if(g_Global.g_mouse.y > 10 && g_Global.g_mouse.y < 130 
      && g_Global.g_bLeftMouseDown == true && ::GetActiveWindow() == g_hWnd){
      if(g_Global.g_mouse.x > 10 && g_Global.g_mouse.x < 110)
        m_event = EVENT_GO_SONAR;
      else if(g_Global.g_mouse.x > 120 && g_Global.g_mouse.x < 220)
        m_event = EVENT_GO_RADAR;
      else if(g_Global.g_mouse.x > 230 && g_Global.g_mouse.x < 330)
        m_event = EVENT_GO_CONTROL;
      else if(g_Global.g_mouse.x > 804 && g_Global.g_mouse.x < 904)
        m_event = EVENT_GO_STATUS;
      else if(g_Global.g_mouse.x > 914 && g_Global.g_mouse.x < 1014)
        m_event = EVENT_GO_CHART;
    }      
  }

  for(unsigned int i=0; i< m_TE.size(); i++){
    if (m_TE[i].event == m_event){
      return m_TE[i].p_gso;
    }
  }
  return 0;
}
开发者ID:ChuckBolin,项目名称:Sinking,代码行数:56,代码来源:CGameStateFireControl.cpp

示例10: Play

//---------------------------------------------------------------------
//  Play a sound
//---------------------------------------------------------------------
void  CSoundSRC::Play(CSoundBUF *sbf)
{ CAudioManager *snd = globals->snd;
  //---Stop current sound if any ----------------
  alSourceStop(alSRC);
  alSourcei (alSRC, AL_BUFFER, 0);
  sPlay = sbf;
  //-- Play the current sound -------------------
  if (0 == sbf)     return;
  ALint buf = sPlay->GetBuffer();
  alSourcei(alSRC,AL_BUFFER,buf);
  alSourcei(alSRC,AL_LOOPING,loop);
  alSourcePlay(alSRC);
  snd->Check();
  return;
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例11: PlayFromOffset

//---------------------------------------------------------------------
//  Loop current sound from offset position
//---------------------------------------------------------------------
void CSoundOBJ::PlayFromOffset(int No)
{ CAudioManager *snd = globals->snd;
  ALint state;
  alGetSourcei (alSRC, AL_SOURCE_STATE, &state);
  if ((sPlay == sounds[No]) && (state == AL_PLAYING)) return;
  sPlay     = sounds[No];
  if (0 == sPlay)       return;
  offset    = sPlay->GetOffset();
  alSourcei(alSRC,AL_BUFFER, sPlay->GetBuffer());
  alSourcei(alSRC,AL_SAMPLE_OFFSET,offset);
  alSourcei(alSRC,AL_LOOPING,false);
  alSourcef(alSRC,AL_PITCH,pitch);
  alSourcePlay(alSRC);
  snd->Check();
  return;
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例12: update

/*************************************  U P D A T E *****************************************/
cGameStateObject* CGameStatePlay::update(double timeDifference){
  m_event = EVENT_GO_NO_WHERE;
  static double timeDiffTotal = 0;
  static double thingTimeDiff = 0;
  //GRAPHIC_IMAGE gi;
  int spriteID;
  int frameMax  = 0;
  int frameCount  = 0;

  //start ambient sound loop
  CAudioManager *pAudio = CAudioManager::Instance();
  if(pAudio->IsPlaying(SOUND_ANCHORS) == false)
    pAudio->PlaySoundClip(SOUND_ANCHORS, 0);

  //loads mouse position into global variable.
  POINT pt;
  POINT *ppt = &pt;
  ::GetCursorPos(ppt);
  RECT rct;
  ::GetWindowRect(g_hWnd, &rct);
  g_Global.g_mouse.x = pt.x - rct.left;
  g_Global.g_mouse.y = pt.y - rct.top;

  //accept...go to control
  if(g_Global.g_mouse.x > 289 && g_Global.g_mouse.x < 407
    && g_Global.g_mouse.y > 683 && g_Global.g_mouse.y < 718
    && g_Global.g_bLeftMouseDown == true && ::GetActiveWindow() == g_hWnd){
    m_event = EVENT_GO_CONTROL;
  }

  //reject..return to menu  
  if(g_Global.g_mouse.x > 626 && g_Global.g_mouse.x < 743
    && g_Global.g_mouse.y > 683 && g_Global.g_mouse.y < 718
    && g_Global.g_bLeftMouseDown == true && ::GetActiveWindow() == g_hWnd){
    m_event = EVENT_GO_SELECT;
  }

  //game state transition code...very important
  for(unsigned int i=0; i< m_TE.size(); i++){
    if (m_TE[i].event == m_event){
      return m_TE[i].p_gso;
    }
  }

  return 0;
}
开发者ID:ChuckBolin,项目名称:Sinking,代码行数:47,代码来源:CGameStatePlay.cpp

示例13: TagToString

//=====================================================================================
//  JS: Sound Buffer:  An AL buffer dedicated to one sound
//  SoundBUF are managed by CAudioManager in a buffer cache.  Do not delete them.
//=====================================================================================
CSoundBUF::CSoundBUF(Tag t, char *nf)
{ CAudioManager *snd = globals->snd;
  user    = 1;
  idn     = t;
  offset  = 0;
  nfile   = 0;
  alSRC   = 0;
  TagToString(itag,t);
  ALuint  buf;
  alGenBuffers(1,&buf);
  alBUF   = buf;
  snd->Check();
  snd->LoadFile(this,nf);
  snd->IncBUF();
  gain    = 1;
  pMin    = 1;
  pMax    = 1;
}
开发者ID:,项目名称:,代码行数:22,代码来源:

示例14: Init

//---------------------------------------------------------------------
//  Init sound object
//---------------------------------------------------------------------
void  CSoundOBJ::Init(Tag t, SVector &pos)
{ CAudioManager *snd = globals->snd;
  sEnd    = 0;
  idn     = t;
  sPlay   = 0;
  gain    = 1;
  pitch   = 1;
  loop    = false;
  offset  = 0;
  for (int k=0; k<8; k++) sounds[k] = 0;
  alGenSources (1, &alSRC);
  snd->Check();
  snd->IncSRC();
  alSource3f(alSRC,AL_POSITION,pos.x,pos.y,pos.z);
  alSourcef (alSRC,AL_REFERENCE_DISTANCE,8.0f);
  snd->Check();
	for (int k=0; k<ENGINE_MAX_SOUND; k++) sounds[k] = 0;
}
开发者ID:,项目名称:,代码行数:21,代码来源:

示例15: Shutdown

void Shutdown()
{
  CLog *pLog = CLog::Instance();
  CAudioManager *pAudio = CAudioManager::Instance();
  pLog->Log("************ Shutting Down ************");
	// Properly shut down the current game object first
	g_pCurrent->deactivate();
	delete g_pStatePlay;
  delete g_pStateMain;
  delete g_pStateIntro;
  delete g_pStateHistory;
  delete g_pStateReload;
  delete g_pStateCredits;
  delete g_pStateSelect;
  delete g_pStateAwards;
  delete g_pStateWin;
  delete g_pStateLose;
  delete g_pStateStatus;
  delete g_pStateChart;
  delete g_pStateControl;
  delete g_pStateEnd;
  delete g_pStateScope;
  delete g_pStateSonar;
  delete g_pStateFireControl;
  delete g_pStateRadar;

  pLog->Log("Game state pointers deleted!");
  pAudio->KillAll();
  ::ShowCursor(false);
	//::Sleep(2000);
	//::ShowCursor(true); //turn mouse cursor back on
	pLog->Log("Audio sounds are all killed!");
	pLog->Log("*************************************");
	pLog->Log("Program ended!");
	pLog->Log("*************************************");

	// Kill the main window
	DestroyWindow( g_hWnd );
	g_hWnd = NULL;
}
开发者ID:ChuckBolin,项目名称:Sinking,代码行数:40,代码来源:main.cpp


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