void CAkFilePackageLUT::_MakeLower( AkOSChar *in_pString ) {
  size_t uStrlen = AKPLATFORM::OsStrLen( in_pString );
  const AkOSChar CaseDiff = AKTEXT('a') - AKTEXT('A');
  for ( size_t i = 0; i < uStrlen; ++i ) {
    if ( in_pString[i] >= AKTEXT('A') && in_pString[i] <= AKTEXT('Z') ) {
      in_pString[i] += CaseDiff;
    }
  }
}
void CAkFilePackageLUT::RemoveFileExtension( AkOSChar *in_pstring ) {
  int i = (int)AKPLATFORM::OsStrLen(in_pstring) - 1;

  while (i >= 0) {
    if (in_pstring[i] == AKTEXT('.')) {
      in_pstring[i] = AKTEXT('\0');
      return;
    }

    i--;
  }
}
void SceneLocalization::onRelease()
{
    // Reset the language to English(US), in case it was changed
    AK::StreamMgr::SetCurrentLanguage(AKTEXT("English(US)"));

    // Unregister the "Human" game object
    AK::SoundEngine::UnregisterGameObj(GAME_OBJECT_HUMAN);

    // Unload the sound bank
    AK::SoundEngine::UnloadBank("Human.bnk", NULL);
}
Example #4
0
void CAkFilePackageLUT::RemoveFileExtension( AkOSChar* in_pstring )
{
	while( *in_pstring != 0 )
	{
		if( *in_pstring == AKTEXT('.') )
		{
			*in_pstring = 0;
			return;
		}
		++in_pstring;
	}
}
void SceneLocalization::menuCloseCallback(Ref* pSender)
{
    // Reset the language to English(US), in case it was changed
    AK::StreamMgr::SetCurrentLanguage(AKTEXT("English(US)"));

    // Unregister the "Human" game object
    AK::SoundEngine::UnregisterGameObj(GAME_OBJECT_HUMAN);

    // Unload the sound bank
    AK::SoundEngine::UnloadBank("Human.bnk", NULL);

    auto director = Director::getInstance();
    director->replaceScene(SceneDialogueMenu::createScene());
    this->removeAllChildren();
}
bool Wwise::InitWwise(	AkMemSettings&          in_memSettings,
			AkStreamMgrSettings&    in_stmSettings,
			AkDeviceSettings&       in_deviceSettings,
			AkInitSettings&         in_initSettings,
			AkPlatformInitSettings& in_platformInitSettings,
			AkMusicSettings&        in_musicInit,
			AkOSChar*               in_szErrorBuffer,
			unsigned int            in_unErrorBufferCharCount)
{
    //
    // Create and initialize an instance of the default memory manager. Note
    // that you can override the default memory manager with your own. Refer
    // to the SDK documentation for more information.
    //

    AKRESULT res = AK::MemoryMgr::Init(&in_memSettings);
    if (res != AK_Success)
    {
	__AK_OSCHAR_SNPRINTF(in_szErrorBuffer, in_unErrorBufferCharCount, AKTEXT("AK::MemoryMgr::Init() returned AKRESULT %d"), res);
	LOGAKW(in_szErrorBuffer);
	return false;
    }

    //
    // Create and initialize an instance of the default streaming manager. Note
    // that you can override the default streaming manager with your own. Refer
    // to the SDK documentation for more information.
    //

    // Customize the Stream Manager settings here.

    if (!AK::StreamMgr::Create(in_stmSettings))
    {
	AKPLATFORM::SafeStrCpy(in_szErrorBuffer, AKTEXT("AK::StreamMgr::Create() failed"), in_unErrorBufferCharCount);
	LOGAKW(in_szErrorBuffer);
	return false;
    }

    //
    // Create a streaming device with blocking low-level I/O handshaking.
    // Note that you can override the default low-level I/O module with your own. Refer
    // to the SDK documentation for more information.
    //

    // CAkFilePackageLowLevelIOBlocking::Init() creates a streaming device
    // in the Stream Manager, and registers itself as the File Location Resolver.
    res = m_pLowLevelIO->Init(in_deviceSettings);
    if (res != AK_Success)
    {
	__AK_OSCHAR_SNPRINTF(in_szErrorBuffer, in_unErrorBufferCharCount, AKTEXT("m_lowLevelIO.Init() returned AKRESULT %d"), res);
	LOGAKW(in_szErrorBuffer);
	return false;
    }

    //
    // Create the Sound Engine
    // Using default initialization parameters
    //

    res = AK::SoundEngine::Init(&in_initSettings, &in_platformInitSettings);
    if (res != AK_Success)
    {
	__AK_OSCHAR_SNPRINTF(in_szErrorBuffer, in_unErrorBufferCharCount, AKTEXT("AK::SoundEngine::Init() returned AKRESULT %d"), res);
	LOGAKW(in_szErrorBuffer);
	return false;
    }

    //
    // Initialize the music engine
    // Using default initialization parameters
    //

    res = AK::MusicEngine::Init(&in_musicInit);
    if (res != AK_Success)
    {
	__AK_OSCHAR_SNPRINTF(in_szErrorBuffer, in_unErrorBufferCharCount, AKTEXT("AK::MusicEngine::Init() returned AKRESULT %d"), res);
	LOGAKW(in_szErrorBuffer);
	return false;
    }

#if defined(NDK_DEBUG) || defined(AK_DEBUG) || defined(_DEBUG)
    //
    // Initialize communications (not in release build!)
    //
    if (GetCommunicationEnabled()) {
	AkCommSettings commSettings;
	AK::Comm::GetDefaultInitSettings(commSettings);
	res = AK::Comm::Init(commSettings);
	if (res != AK_Success)
	{
	    __AK_OSCHAR_SNPRINTF(in_szErrorBuffer, in_unErrorBufferCharCount, AKTEXT("AK::Comm::Init() returned AKRESULT %d. Communication between the Wwise authoring application and the game will not be possible."), res);
	    LOGAKW(in_szErrorBuffer);
	}
    }
#endif

#ifdef AK_PLUGINS
    //
    // Register plugins
    /// Note: This a convenience method for rapid prototyping.
    /// To reduce executable code size register/link only the plug-ins required by your game
    res = AK::SoundEngine::RegisterAllPlugins();
    if (res != AK_Success)
    {
	__AK_OSCHAR_SNPRINTF(in_szErrorBuffer, in_unErrorBufferCharCount, AKTEXT("AK::SoundEngine::RegisterAllPlugins() returned AKRESULT %d."), res);
    }
#endif
    
    return true;
}
bool Wwise::Init(   AkMemSettings&          in_memSettings,
		    AkStreamMgrSettings&    in_stmSettings,
		    AkDeviceSettings&       in_deviceSettings,
		    AkInitSettings&         in_initSettings,
		    AkPlatformInitSettings& in_platformInitSettings,
		    AkMusicSettings&        in_musicInit,
		    AkOSChar*               in_soundBankPath,
		    AkOSChar*               in_szErrorBuffer,
		    unsigned int            in_unErrorBufferCharCount)
{
    bool bSuccess;
    AKRESULT hr;
    
#if  defined(AK_IOS)
    // Allow other applications to play sounds while the integration demo executes.
    in_platformInitSettings.audioSession.eCategory = AkAudioSessionCategoryPlayAndRecord;
    //	platformInitSettings.audioSession.eCategory = AkAudioSessionCategorySoloAmbient;
    //	platformInitSettings.audioSession.eCategory = AkAudioSessionCategoryAmbient;
    
    if (in_platformInitSettings.audioSession.eCategory == AkAudioSessionCategoryPlayAndRecord)
    {
        g_bEnableMicDemo = true;
        in_platformInitSettings.audioSession.eCategoryOptions = GetAudioSessionCategoryOptionBitMask(true, false, true, true);
    }
    else
    {
        g_bEnableMicDemo = false;
        in_platformInitSettings.audioSession.eCategoryOptions = GetAudioSessionCategoryOptionBitMask(true, true, false, false);
    }
    
    // Optimization.
    in_platformInitSettings.uSampleRate = AUDIO_SAMPLE_RATE;
    g_uSamplesPerFrame = in_initSettings.uNumSamplesPerFrame;
    
    in_platformInitSettings.audioCallbacks.inputCallback = SoundInput::AudioInputCallback;
    in_platformInitSettings.audioCallbacks.inputCallbackCookie = (void*)&SoundInput::Instance();
    
    in_platformInitSettings.audioCallbacks.interruptionCallback = DemoInterruptCallback;
#endif
    
    // Initialize Wwise
    bSuccess = InitWwise(in_memSettings, in_stmSettings, in_deviceSettings, in_initSettings, in_platformInitSettings, in_musicInit, in_szErrorBuffer, in_unErrorBufferCharCount);
    if (!bSuccess) {
	goto cleanup;
    }

    // Set the path to the SoundBank Files.
    hr = m_pLowLevelIO->SetBasePath(in_soundBankPath);

    // Set global language. Low-level I/O devices can use this string to find language-specific assets.
    if (AK::StreamMgr::SetCurrentLanguage(AKTEXT("English(US)")) != AK_Success)
    {
	goto cleanup;
    }

    AkBankID bankID;
    if (AK::SoundEngine::LoadBank("Init.bnk", AK_DEFAULT_POOL_ID, bankID) != AK_Success)
    {
	//SetLoadFileErrorMessage("Init.bnk");
	LOGAK("<Wwise::Init> Cannot load Init.bnk! error");
#ifdef 	COCOS_INTEGRATION
	cocos2d::MessageBox("Cannot load Init.bnk!", "Error");
#endif
	return false;
    }

    return true;

cleanup:
    Term();
    return false;
}
#pragma comment( lib, "AkExpanderFX.lib")
#pragma comment( lib, "Msacm32.lib") // Microsoft ACM Library
#endif

static const AkUInt32 kMaxNumPools = 20;
static const AkUInt32 kDefaultPoolSize = 2 * 1024 * 1024;
static const AkUInt32 kLEngineDefaultPoolSize = 1 * 1024 * 1024;

#ifdef AK_WIN
  #ifdef _DEBUG
    #define MY_SOUND_BANK_PATH L"../../WwiseProject/GeneratedSoundBanks/Windows/"  // Please change this path to yours
#else
    #define MY_SOUND_BANK_PATH L"Wwise/"
  #endif
#elif defined AK_ANDROID
  const AkOSChar MY_SOUND_BANK_PATH[] = AKTEXT("GeneratedSoundBanks/Android/");
#elif defined AK_APPLE
  #include "TargetConditionals.h"
  #if TARGET_OS_IPHONE
    // iOS
    #define MY_SOUND_BANK_PATH g_szBasePath //"iOS/"
  #else
    // MacOS
    #define MY_SOUND_BANK_PATH "Mac/"
  #endif
#else
  #error undefied platform
#endif

#ifdef AK_IOS
AkAudioSessionCategoryOptions GetAudioSessionCategoryOptionBitMask(bool in_bMixWithOthers, bool in_bDuckOthers, bool in_bAllowBluetooth, bool in_bDefaultToSpeaker)