コード例 #1
0
cSound::cSound() {
	nSounds = 0;
	nMusics = 0;
	nEffects = 0;
	System_Create(&system);
	system->init(MAX_SOUNDS, FMOD_INIT_NORMAL, 0);
}
コード例 #2
0
ファイル: Sound.cpp プロジェクト: brentspector/Dart
//init fmod
void SoundSystem::init()
{
	
	//check version of file matches dll
	UINT version;
	int numDrivers;
	FMOD_CAPS caps;
	FMOD_SPEAKERMODE speakerMode;
	char name[256];
	FMOD_RESULT result;

	//create system
	FR(System_Create(&mSystem));
	//check version
	FR(mSystem->getVersion(&version));

	if (version < FMOD_VERSION)
	{
		OutputDebugString(L"ERROR: Version of FMOD is older than dll version.\n");
	}
	//get number of sound cards 
	FR(mSystem->getNumDrivers(&numDrivers));
	if (numDrivers == 0)
	{
		FR(mSystem->setOutput(FMOD_OUTPUTTYPE_NOSOUND));
	}
	//if at least one sound card, set speaker output to match
	else
	{
		//caps of default sound card
		FR(mSystem->getDriverCaps(0, &caps, 0, &speakerMode));
		//set speaker mode to match
		FR(mSystem->setSpeakerMode(speakerMode));
	}
	//if hardware acceleration disabled, must make software buffer larger to prevent stuttering
	if (caps & FMOD_CAPS_HARDWARE_EMULATED)
		FR(mSystem->setDSPBufferSize(1024, 10));
	//kludge for SigmaTel sound drivers
	//get name of driver
	FR(mSystem->getDriverInfo(0, name, 256, 0));
	//sigmatel sound devices crackle for some reason if format is PCM 16-bit
	//PCM floating point output solves this
	if (strstr(name, "SigmaTel"))
	{
		//won't use the normal wrapper here because we take special actions below
		result = mSystem->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0, 0, FMOD_DSP_RESAMPLER_LINEAR);
	}
	//now we can init system
	FR(mSystem->init(100, FMOD_INIT_NORMAL, 0));
	//if selected speaker mode isn't supported, switch back to safe fall back
	if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)
	{
		FR(mSystem->setSpeakerMode(FMOD_SPEAKERMODE_STEREO));
		FR(mSystem->init(100, FMOD_INIT_NORMAL, 0));
	}
}
コード例 #3
0
void SoundManager::Init( )
{
	//FMOD 초기화 
	//FMOD 함수는 모두 결과값을 리턴한다. 따라서 에러체크가 가능하다.
	r = System_Create( &m_pFmod );
	ErrorCheck( r );

	r = m_pFmod->init( MAX_SOUND_COUNT, FMOD_INIT_NORMAL, NULL );
	ErrorCheck( r );
	m_volume = 0.5f;

	for (int i = 0; i < MAX_SOUND_COUNT; i++)
	{
		m_pCh[i]->setVolume( m_volume );
	}
}
コード例 #4
0
ファイル: AudioManager.cpp プロジェクト: djkarstenv/Handmade
//------------------------------------------------------------------------------------------------------
//function that initializes all audio subsystems 
//------------------------------------------------------------------------------------------------------
bool AudioManager::Initialize()
{

	//create audio subsystem and store handle in pointer	
	System_Create(&m_audioSystem);

	//initialize audio sub system with 100 channels and normal flag
	//if initialization failed, display error message and return false
	if(m_audioSystem->init(100, FMOD_INIT_NORMAL, 0) != FMOD_OK)
	{
		std::cout << "Audio sub-system did not initialize properly." << std::endl;
		return false;
	}

	return true;

}
コード例 #5
0
audio::AudioEngineFmod::AudioEngineFmod(const std::string& audioDirectory, const int maxChannelsCount) :
	IAudioEngine(audioDirectory),
	m_maxChannelsCount(maxChannelsCount),
	m_system(nullptr),
	m_master(nullptr),
	m_currentSong(nullptr),
	m_currentSongPath(""),
	m_nextSongPath(""),
	m_fade(fade_states::FADE_NONE)
{
	// Based on tutorial: https://cuboidzone.wordpress.com/category/tutorials/
	FMOD_RESULT fmodResult = System_Create(&m_system); // Create the main system object
	CHECK_CONDITION_EXIT_ALWAYS_AUDIO(fmodResult == FMOD_OK, utility::logging::CRITICAL, "Failed to create an audio system with error code ", fmodResult, ". ", FMOD_ErrorString(fmodResult));

	auto driversCount = 0;
	fmodResult = m_system->getNumDrivers(&driversCount);
	CHECK_CONDITION_EXIT_ALWAYS_AUDIO(fmodResult == FMOD_OK && driversCount != 0, utility::logging::CRITICAL, "Failed to create an audio system. Drivers count = ", driversCount);

	unsigned int version;
	fmodResult = m_system->getVersion(&version);
	CHECK_CONDITION_EXIT_ALWAYS_AUDIO(fmodResult == FMOD_OK && version >= FMOD_VERSION, utility::logging::ERR,
		"Failed to create an audio system. FMOD lib version ", version, " doesn't match header version ", FMOD_VERSION);

	fmodResult = m_system->init(m_maxChannelsCount, FMOD_INIT_NORMAL, nullptr); // initialize FMOD
	CHECK_CONDITION_EXIT_ALWAYS_AUDIO(fmodResult == FMOD_OK, utility::logging::CRITICAL, "Initializing audio system has ended with error code ", fmodResult, ". ", FMOD_ErrorString(fmodResult));

	// Creating channels groups for each category
	m_system->getMasterChannelGroup(&m_master);
	for (auto i = 0; i < categories::COUNT; ++i)
	{
		m_system->createChannelGroup(nullptr /* name of the channel group */, &m_groups[i]);
		m_master->addGroup(m_groups[i]);
	}

	// Set up modes for each category
	m_modes[categories::SOUND_EFFECT] = FMOD_DEFAULT;
	m_modes[categories::SOUND_EFFECT_3D] = FMOD_3D;
	m_modes[categories::SONG] = FMOD_DEFAULT | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL;

	NOTICE_LOG_AUDIO("Audio engine created.");
}
コード例 #6
0
  void SoundSystem::Initialize(IConfiguration* configuration)
  {
    m_configuration = configuration;
    m_configuration->SetDefault(ConfigSections::Sound, ConfigItems::Sound::SFXVolume, 99);
    m_configuration->SetDefault(ConfigSections::Sound, ConfigItems::Sound::MusicVolume, 99);

    FMOD_RESULT result;
    m_fmodSystem = 0;

    result = System_Create(&m_fmodSystem);

    if (result != FMOD_OK)
    {
      // failed to create FMOD System
    }

    unsigned int version = 0;

    result = m_fmodSystem->getVersion(&version);

    if (version <FMOD_VERSION)
    {
      // wrong FMOD version
    }

    int driverCount = 0;
    result = m_fmodSystem->getNumDrivers(&driverCount);


    if (driverCount <1)
    {
      result = m_fmodSystem->setOutput(FMOD_OUTPUTTYPE_NOSOUND);
    }
    else
    {
      FMOD_CAPS driverCaps;
      FMOD_SPEAKERMODE speakerMode;

      result = m_fmodSystem->getDriverCaps(0, &driverCaps, 0, 0, &speakerMode);

      if (result != FMOD_OK)
      {
        // could not get driver caps
      }

      if (driverCaps & FMOD_CAPS_HARDWARE_EMULATED)
      {
        char name[ 256 ];
        result = m_fmodSystem->getDriverInfo(0, name, 256, 0);

        if (result != FMOD_OK)
        {
          // could not get driver info
        }

        if (strstr(name, "SigmaTel"))
        {
          result = m_fmodSystem->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0, 0, FMOD_DSP_RESAMPLER_LINEAR);

          if (result != FMOD_OK)
          {
            // count not set Sigmatel software format
          }
        }
      }
    }

    result = m_fmodSystem->init(100, FMOD_INIT_NORMAL, 0);

    if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)
    {
      result = m_fmodSystem->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);

      if (result != FMOD_OK)
      {
        // could not set speaker mode
      }

      result = m_fmodSystem->init(100, FMOD_INIT_NORMAL, 0);

      if (result != FMOD_OK)
      {
        // could not init FMOD with standard stereo setup
      }
    }

    result = m_fmodSystem->setFileSystem(&SoundSystem::FMOD_FileOpen, &SoundSystem::FMOD_FileClose, &SoundSystem::FMOD_FileRead, &SoundSystem::FMOD_FileSeek, 0);

    if (result != FMOD_OK)
    {
      // error binding IO functions
    }

    m_eventSystem->Initialize(m_fmodSystem);
    m_serviceManager->RegisterService(this);
  }
コード例 #7
0
//
// Initialize FMOD system
//
void Audio::initialize() {
    result = System_Create(&sys);
    sys->init(32, FMOD_INIT_NORMAL, NULL);
    sys->getMasterChannelGroup(&channelGroup);
}
コード例 #8
0
ファイル: Audio.cpp プロジェクト: PanosK92/Directus3D
	Audio::Audio(Context* context) : ISubsystem(context)
	{
		m_system_fmod		= nullptr;
		m_max_channels		= 32;
		m_distance_entity	= 1.0f;
		m_listener			= nullptr;
		m_profiler			= m_context->GetSubsystem<Profiler>().get();

		// Create FMOD instance
		m_result_fmod = System_Create(&m_system_fmod);
		if (m_result_fmod != FMOD_OK)
		{
			LogErrorFmod(m_result_fmod);
			return;
		}

		// Check FMOD version
		unsigned int version;
		m_result_fmod = m_system_fmod->getVersion(&version);
		if (m_result_fmod != FMOD_OK)
		{
			LogErrorFmod(m_result_fmod);
			return;
		}

		if (version < FMOD_VERSION)
		{
			LogErrorFmod(m_result_fmod);
			return;
		}

		// Make sure there is a sound card devices on the machine
		auto driver_count = 0;
		m_result_fmod = m_system_fmod->getNumDrivers(&driver_count);
		if (m_result_fmod != FMOD_OK)
		{
			LogErrorFmod(m_result_fmod);
			return;
		}

		// Initialize FMOD
		m_result_fmod = m_system_fmod->init(m_max_channels, FMOD_INIT_NORMAL, nullptr);
		if (m_result_fmod != FMOD_OK)
		{
			LogErrorFmod(m_result_fmod);
			return;
		}

		// Set 3D settings
		m_result_fmod = m_system_fmod->set3DSettings(1.0, m_distance_entity, 0.0f);
		if (m_result_fmod != FMOD_OK)
		{
			LogErrorFmod(m_result_fmod);
			return;
		}

		m_initialized = true;

		// Get version
		stringstream ss;
		ss << hex << version;
		const auto major	= ss.str().erase(1, 4);
		const auto minor	= ss.str().erase(0, 1).erase(2, 2);
		const auto rev		= ss.str().erase(0, 3);
		Settings::Get().m_versionFMOD = major + "." + minor + "." + rev;

		// Subscribe to events
		SUBSCRIBE_TO_EVENT(Event_World_Unload, [this](Variant) { m_listener = nullptr; });
	}
コード例 #9
0
ファイル: Soccer_Modeling.cpp プロジェクト: JumSSang/Kinect
void Kinect::InitMesh(int number)
{

	System_Create(&m_pSystem);
	m_pSystem->init(3, FMOD_INIT_NORMAL, 0);
	m_pSystem->createSound("Data/Soccer/엉뚱.mp3", FMOD_LOOP_NORMAL, 0, &m_pSound[0]);
	m_pSystem->createSound("Data/Soccer/클릭음3.wav", FMOD_HARDWARE, 0, &m_pSound[2]);
	m_pSystem->createSound("Data/Soccer/타격음1.wav", FMOD_HARDWARE, 0, &m_pSound[1]);
	m_pSystem->createSound("Data/Soccer/크라잉 넛-03-오 필승 코리아.mp3", FMOD_HARDWARE, 0, &m_pSound[3]);
	m_football.InitMesh("Data/Soccer/FootBall.x");
	
	fireball.LoadFile(g_pDevice, { 0, 0, 0 }, { 0, 0, 0 }, "Data/Soccer/Fireball.png");
	//m_football.m_pMeshMaterials->Ambient = D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.3f);
	//m_football.m_pMeshMaterials ->Diffuse = D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.3f);
	////m_football.m_pMeshMaterials ->Specular = D3DXCOLOR(0.5f, 0.5f, 0.5f, 0.0f);
	//m_football.m_pMeshMaterials ->Power = 8.0f;
	m_ballCall_img.LoadFile(g_pDevice, { 0, 0, 0 }, { 0, 0, 0 }, "Data/Soccer/ball.png");
	m_main_img.LoadFile(g_pDevice, { 0, 0, 0 }, { 0, 0, 0 }, "Data/Soccer/background.png");
	m_StartButton_img.LoadFile(g_pDevice, { 0, 200, 0 }, { 0, 0, 0 }, "Data/Soccer/start.png");
	m_SettingButton_img.LoadFile(g_pDevice, { 0, 300, 0 }, { 0, 0, 0 }, "Data/Soccer/setting.png");
	m_EndButton_img.LoadFile(g_pDevice, { 0, 400, 0 }, { 0, 0, 0 }, "Data/Soccer/endingbutton.png");
	m_autioButton.LoadFile(g_pDevice, { 1000, 100, 0 }, { 0, 0, 0 }, "Data/Soccer/Audio.png");

	ButtonRECT[0].left = 0;
	ButtonRECT[0].right = 410;
	ButtonRECT[0].top = 0;
	ButtonRECT[0].bottom = 94;


	ButtonRECT[1].left = 410;
	ButtonRECT[1].right = 820;
	ButtonRECT[1].top = 0;
	ButtonRECT[1].bottom = 94;


	m_StartButton_img.rect = ButtonRECT[0];
	m_SettingButton_img.rect = ButtonRECT[0];
	m_EndButton_img.rect = ButtonRECT[0];
	m_autioButton.rect = ButtonRECT[0];
	fireRect[0].left = 0;
	fireRect[0].right = 192;
	fireRect[0].top = 0;
	fireRect[0].bottom = 192;
	int tempnum = 192;

	for (int i = 1; i < 5; i++)
	{
		fireRect[i].left = tempnum;
		tempnum += 192;
		fireRect[i].top = 0;
		fireRect[i].bottom = 192;
		fireRect[i].right = tempnum;
		
	}
	enemy.InitMesh("Data/Soccer/football.x");
	m_goalpost.InitMesh("Data/Soccer/GoalPost2.X");
	m_teaspot.InitMesh("Data/Soccer/teapot.X");
	stadium.InitMesh("Data/Soccer/Stadium.X");
	m_player = new CSkinnedMesh[2];
	m_player[0].LoadMesh(g_pDevice, CUtility::GetTheCurrentDirectory() + "/Data/Soccer/ironman2.X");//모델링위치
	
	D3DXCreateBox(g_pDevice, 1, 1, 0, &m_pBox, NULL);
	D3DXCreateSphere(g_pDevice, 1, 1, 1, &m_pSphere, NULL);
	VertexPNT* v = 0;
	/*m_football.m_pMesh->LockVertexBuffer(0, (void**)&v);

	D3DXComputeBoundingBox(&v[0].pos, m_football.m_pMesh->GetNumVertices(),
		sizeof(VertexPNT), &m_football.mBoundingBox.minPt, &m_football.mBoundingBox.maxPt);

	m_football.m_pMesh->UnlockVertexBuffer();*/

	//float width = m_football.mBoundingBox.maxPt.x - m_football.mBoundingBox.minPt.x;
	//float height = m_football.mBoundingBox.maxPt.y - m_football.mBoundingBox.minPt.y;
	//float depth = m_football.mBoundingBox.maxPt.z - m_football.mBoundingBox.minPt.z;
	
	//m_player2 = new CSkinnedMesh[2];
	//m_player2[0].LoadMesh(g_pDevice,CUtility::GetTheCurrentDirectory() + "/Data/Soccer/ironman.X");//모델링위치
	
	

}