Guest User

Untitled

a guest
May 24th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <fmod.hpp>
  3. //#include <fmod_studio.hpp>
  4. #include <fmod_errors.h>
  5.  
  6. void FMOD_CheckError( FMOD_RESULT result )
  7. {
  8. if ( result != FMOD_OK )
  9. {
  10. std::cout << "[FMOD]" << FMOD_ErrorString( result ) << std::endl;
  11. exit( EXIT_FAILURE );
  12. }
  13. }
  14.  
  15. class FMODManager
  16. {
  17. public:
  18. ~FMODManager()
  19. {
  20. //m_pStudioSystem->release();
  21. m_pSoundSystem->release();
  22. }
  23. void Init()
  24. {
  25. void *extraDriverData = nullptr;
  26. //m_pStudioSystem = nullptr;
  27. m_pSoundSystem = nullptr;
  28.  
  29. //FMOD_CheckError( FMOD::Studio::System::create( &m_pStudioSystem ) );
  30. //FMOD_CheckError( m_pStudioSystem->getLowLevelSystem( &m_pSoundSystem ) );
  31. //FMOD_CheckError( m_pStudioSystem->initialize( 1024, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, extraDriverData ) );
  32. FMOD_CheckError( FMOD::System_Create( &m_pSoundSystem ) );
  33. FMOD_CheckError( m_pSoundSystem->init( 1024, FMOD_INIT_NORMAL, nullptr ) );
  34. }
  35.  
  36. void Update()
  37. {
  38. //FMOD_CheckError( m_pStudioSystem->update() );
  39. FMOD_CheckError( m_pSoundSystem->update() );
  40. }
  41. //FMOD::Studio::System *GetStudioSystem() { return m_pStudioSystem; }
  42. FMOD::System *GetSoundSystem() { return m_pSoundSystem; }
  43.  
  44. private:
  45. //FMOD::Studio::System *m_pStudioSystem;
  46. FMOD::System *m_pSoundSystem;
  47. };
  48.  
  49. FMODManager *mgr = nullptr;
  50.  
  51. int main ( int argc, char *argv[] )
  52. {
  53. mgr = new FMODManager;
  54. mgr->Init();
  55.  
  56. FMOD::Channel *channel = nullptr;
  57. FMOD::Sound *sound = nullptr;
  58. FMOD_CREATESOUNDEXINFO exinfo;
  59. memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
  60. exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
  61.  
  62. FMOD_CheckError( mgr->GetSoundSystem()->createSound( "jazz_jackrabbit_2_-_carrotus.s3m", FMOD_DEFAULT | FMOD_2D, &exinfo, &sound ) );
  63. FMOD_CheckError( mgr->GetSoundSystem()->playSound( sound, nullptr, false, &channel ) );
  64.  
  65. bool bDone = false;
  66.  
  67. while ( !bDone )
  68. {
  69. bool isPlaying = false;
  70.  
  71. FMOD_CheckError( channel->isPlaying( &isPlaying ) );
  72.  
  73. bDone = !isPlaying;
  74.  
  75. mgr->Update();
  76. }
  77.  
  78. sound->release();
  79. delete mgr;
  80.  
  81. return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment