Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fmod.hpp>
- //#include <fmod_studio.hpp>
- #include <fmod_errors.h>
- void FMOD_CheckError( FMOD_RESULT result )
- {
- if ( result != FMOD_OK )
- {
- std::cout << "[FMOD]" << FMOD_ErrorString( result ) << std::endl;
- exit( EXIT_FAILURE );
- }
- }
- class FMODManager
- {
- public:
- ~FMODManager()
- {
- //m_pStudioSystem->release();
- m_pSoundSystem->release();
- }
- void Init()
- {
- void *extraDriverData = nullptr;
- //m_pStudioSystem = nullptr;
- m_pSoundSystem = nullptr;
- //FMOD_CheckError( FMOD::Studio::System::create( &m_pStudioSystem ) );
- //FMOD_CheckError( m_pStudioSystem->getLowLevelSystem( &m_pSoundSystem ) );
- //FMOD_CheckError( m_pStudioSystem->initialize( 1024, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, extraDriverData ) );
- FMOD_CheckError( FMOD::System_Create( &m_pSoundSystem ) );
- FMOD_CheckError( m_pSoundSystem->init( 1024, FMOD_INIT_NORMAL, nullptr ) );
- }
- void Update()
- {
- //FMOD_CheckError( m_pStudioSystem->update() );
- FMOD_CheckError( m_pSoundSystem->update() );
- }
- //FMOD::Studio::System *GetStudioSystem() { return m_pStudioSystem; }
- FMOD::System *GetSoundSystem() { return m_pSoundSystem; }
- private:
- //FMOD::Studio::System *m_pStudioSystem;
- FMOD::System *m_pSoundSystem;
- };
- FMODManager *mgr = nullptr;
- int main ( int argc, char *argv[] )
- {
- mgr = new FMODManager;
- mgr->Init();
- FMOD::Channel *channel = nullptr;
- FMOD::Sound *sound = nullptr;
- FMOD_CREATESOUNDEXINFO exinfo;
- memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
- exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
- FMOD_CheckError( mgr->GetSoundSystem()->createSound( "jazz_jackrabbit_2_-_carrotus.s3m", FMOD_DEFAULT | FMOD_2D, &exinfo, &sound ) );
- FMOD_CheckError( mgr->GetSoundSystem()->playSound( sound, nullptr, false, &channel ) );
- bool bDone = false;
- while ( !bDone )
- {
- bool isPlaying = false;
- FMOD_CheckError( channel->isPlaying( &isPlaying ) );
- bDone = !isPlaying;
- mgr->Update();
- }
- sound->release();
- delete mgr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment