Compare commits
5 Commits
27c1e05baf
...
a5db74568f
Author | SHA1 | Date |
---|---|---|
ottona | a5db74568f | |
Raynaldo Rivera | ce5d03905a | |
areay | 0933438816 | |
Raynaldo Rivera | e6f18eb1b7 | |
Ben Rosser | cf32f714b1 |
|
@ -0,0 +1,2 @@
|
|||
*.lib filter=lfs diff=lfs merge=lfs -text
|
||||
*.dll filter=lfs diff=lfs merge=lfs -text
|
|
@ -29,3 +29,8 @@ MACRO_DISPLAY_FEATURE_LOG()
|
|||
include_directories(
|
||||
${OPENAL_INCLUDE_DIR}
|
||||
)
|
||||
if(WIN32)
|
||||
include_directories(
|
||||
"${OPENAL_INCLUDE_DIR}/../"
|
||||
)
|
||||
endif()
|
|
@ -137,4 +137,5 @@ if(CAUDIO_BUILD_SAMPLES)
|
|||
add_subdirectory(Examples/Tutorial5_AudioEffects)
|
||||
add_subdirectory(Examples/Tutorial6_CustomEventHandler)
|
||||
add_subdirectory(Examples/Tutorial7_CustomLogReceiver)
|
||||
add_subdirectory(Examples/Tutorial8_CustomManagerEventHandler)
|
||||
endif()
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,56 @@
|
|||
#-------------------------------------------------------------------
|
||||
# This file is part of the CMake build system for CAUDIO
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
############################################################
|
||||
# Tutorial8_CustomManagerEventHandler Player
|
||||
############################################################
|
||||
|
||||
PROJECT(Tutorial8_CustomManagerEventHandler)
|
||||
|
||||
set (SOURCE_FILES
|
||||
include/cTestManager.h
|
||||
src/cTestManager.cpp
|
||||
src/main.cpp
|
||||
)
|
||||
|
||||
if(CAUDIO_IOS_BUILD)
|
||||
# TODO add ios appdelegate
|
||||
endif()
|
||||
|
||||
|
||||
include_directories (include ${CAUDIO_INCLUDE_DIR} )
|
||||
add_executable(Tutorial8_CustomManagerEventHandler ${SOURCE_FILES})
|
||||
|
||||
target_link_libraries(Tutorial8_CustomManagerEventHandler cAudio)
|
||||
add_dependencies(Tutorial8_CustomManagerEventHandler cAudio)
|
||||
|
||||
if(CAUDIO_IOS_BUILD)
|
||||
set_source_files_properties(src/main.cpp PROPERTIES COMPILE_FLAGS "-x objective-c++")
|
||||
endif()
|
||||
|
||||
if(${CAUDIO_STATIC})
|
||||
ADD_DEFINITIONS(-DCAUDIO_STATIC_LIB=1)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
# append _d for debug builds
|
||||
set_property(TARGET Tutorial8_CustomManagerEventHandler APPEND PROPERTY DEBUG_POSTFIX "_d")
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
# On OS X, create .app bundle
|
||||
set_property(TARGET Tutorial8_CustomManagerEventHandler PROPERTY MACOSX_BUNDLE TRUE)
|
||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.YOUR_COMPANY.\${PRODUCT_NAME:rfc1034identifier}")
|
||||
set_property(TARGET Tutorial8_CustomManagerEventHandler PROPERTY MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/../Info.plist)
|
||||
|
||||
if(CAUDIO_IOS_BUILD)
|
||||
set_target_properties(Tutorial8_CustomManagerEventHandler PROPERTIES XCODE_ATTRIBUTE_GCC_THUMB_SUPPORT "NO")
|
||||
set_target_properties(Tutorial8_CustomManagerEventHandler PROPERTIES XCODE_ATTRIBUTE_GCC_UNROLL_LOOPS "YES")
|
||||
set_target_properties(Tutorial8_CustomManagerEventHandler PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")
|
||||
endif()
|
||||
|
||||
endif ()
|
||||
|
||||
install_all_targets(Tutorial8_CustomManagerEventHandler)
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
//****************************************************************
|
||||
//cAudio 2.3.0 Tutorial 8
|
||||
//Custom Manager Event Handler
|
||||
//****************************************************************
|
||||
|
||||
|
||||
///Include the ISourceHandler.h so we can inherit the interface
|
||||
#include "IManagerEventHandler.h"
|
||||
//Include cAudio.h so we can work with cAudio
|
||||
#include "cAudio.h"
|
||||
|
||||
class cTestManager : public cAudio::IManagerEventHandler
|
||||
{
|
||||
//In order for this handler to work it must have each of the following functions
|
||||
public:
|
||||
cTestManager();
|
||||
~cTestManager();
|
||||
|
||||
//functions required to inherit from cAudio::IManagerEventHandler
|
||||
void onInit() {};
|
||||
void onUpdate();
|
||||
void onRelease() {};
|
||||
void onSourceCreate() {};
|
||||
void onDecoderRegister() {};
|
||||
void onDataSourceRegister() {};
|
||||
|
||||
private:
|
||||
cAudio::IAudioManager* audioMgr;
|
||||
cAudio::IAudioSource* mysound;
|
||||
bool mysoundFading;
|
||||
clock_t fadeClockLastVal;
|
||||
float fadeAccumulator;
|
||||
|
||||
};
|
|
@ -0,0 +1,99 @@
|
|||
//****************************************************************
|
||||
//cAudio 2.3.0 Tutorial 8
|
||||
//Custom Manager Event Handler
|
||||
//****************************************************************
|
||||
|
||||
#include "cTestManager.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void cTestManager::onUpdate()
|
||||
{
|
||||
//We comment this out because this will be constantly
|
||||
//called as the thread is updated
|
||||
//std::cout << "Custom Threaded Manager Event Handler : update called\n";
|
||||
|
||||
clock_t t = clock();
|
||||
if (mysoundFading)
|
||||
fadeAccumulator -= (t - fadeClockLastVal);
|
||||
else
|
||||
fadeAccumulator += (t - fadeClockLastVal);
|
||||
fadeClockLastVal = t;
|
||||
float newVolume = float(fadeAccumulator) / CLOCKS_PER_SEC * 4.f;
|
||||
mysound->setVolume(newVolume);
|
||||
if (newVolume < 0.01f && mysoundFading)
|
||||
{
|
||||
std::cout <<"fading in...\n";
|
||||
mysoundFading = false;
|
||||
}
|
||||
if (newVolume > 0.99f && !mysoundFading)
|
||||
{
|
||||
std::cout <<"fading out...\n";
|
||||
mysoundFading = true;
|
||||
}
|
||||
//std::cout <<"current volume is :" << newVolume << "\n";
|
||||
}
|
||||
|
||||
cTestManager::~cTestManager()
|
||||
{
|
||||
audioMgr->shutDown();
|
||||
cAudio::destroyAudioManager(audioMgr);
|
||||
}
|
||||
|
||||
cTestManager::cTestManager()
|
||||
{
|
||||
//Create an uninitialized Audio Manager
|
||||
audioMgr = cAudio::createAudioManager(false);
|
||||
mysoundFading = false;
|
||||
|
||||
if(audioMgr)
|
||||
{
|
||||
//Allow the user to choose a playback device
|
||||
cout << "\nAvailable Playback Devices: \n";
|
||||
cAudio::IAudioDeviceList* pDeviceList = cAudio::createAudioDeviceList();
|
||||
unsigned int deviceCount = pDeviceList->getDeviceCount();
|
||||
cAudio::cAudioString defaultDeviceName = pDeviceList->getDefaultDeviceName();
|
||||
for(unsigned int i=0; i<deviceCount; ++i)
|
||||
{
|
||||
cAudio::cAudioString deviceName = pDeviceList->getDeviceName(i);
|
||||
if(deviceName.compare(defaultDeviceName) == 0)
|
||||
cout << i << "): " << deviceName.c_str() << " [DEFAULT] \n";
|
||||
else
|
||||
cout << i << "): " << deviceName.c_str() << " \n";
|
||||
}
|
||||
cout << std::endl;
|
||||
cout << "Choose a device by number: ";
|
||||
unsigned int deviceSelection = 0;
|
||||
cin >> deviceSelection;
|
||||
cout << std::endl;
|
||||
|
||||
//Initialize the manager with the user settings
|
||||
audioMgr->initialize(pDeviceList->getDeviceName(deviceSelection).c_str());
|
||||
CAUDIO_DELETE pDeviceList;
|
||||
pDeviceList = 0;
|
||||
|
||||
//register for callbacks
|
||||
audioMgr->registerEventHandler(this);
|
||||
|
||||
//Create a IAudio object and load a sound from a file
|
||||
mysound = audioMgr->create("song", "../Media/cAudioTheme1.ogg",true);
|
||||
|
||||
if(mysound)
|
||||
{
|
||||
mysound->setVolume(0.0);
|
||||
//Set the IAudio Sound to play2d and loop
|
||||
mysound->play2d(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Failed to load audio source file. \n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Failed to create audio playback manager. \n";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
//****************************************************************
|
||||
//cAudio 2.3.0 Tutorial 8
|
||||
//Custom Manager Event Handler
|
||||
//****************************************************************
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
//Include the custom handler
|
||||
#include "cTestManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
//Some fancy text
|
||||
cout << "cAudio 2.3.0 Tutorial 8: Custom Manager Event Handler. \n \n";
|
||||
|
||||
//Create our background audio thread then forget about it.
|
||||
// onUpdate() callbacks will be triggered and handled without this
|
||||
// main thread's knowledge
|
||||
cTestManager *manager = new cTestManager();
|
||||
|
||||
std::cout << "Press any key to quit \n";
|
||||
std::cin.get();
|
||||
std::cin.get();
|
||||
|
||||
delete(manager);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -25,4 +25,7 @@ if(${CAUDIO_STATIC})
|
|||
ADD_DEFINITIONS(-DCAUDIO_STATIC_LIB)
|
||||
endif()
|
||||
|
||||
install_all_targets(EAXLegacyPreset)
|
||||
set_property(TARGET EAXLegacyPreset PROPERTY VERSION "2.3.0")
|
||||
set_property(TARGET EAXLegacyPreset PROPERTY SOVERSION 2 )
|
||||
|
||||
install_all_targets(EAXLegacyPreset)
|
||||
|
|
|
@ -25,4 +25,7 @@ if(${CAUDIO_STATIC})
|
|||
ADD_DEFINITIONS(-DCAUDIO_STATIC_LIB)
|
||||
endif()
|
||||
|
||||
install_all_targets(cAp_mp3Decoder)
|
||||
set_property(TARGET cAp_mp3Decoder PROPERTY VERSION "2.3.0")
|
||||
set_property(TARGET cAp_mp3Decoder PROPERTY SOVERSION 2 )
|
||||
|
||||
install_all_targets(cAp_mp3Decoder)
|
||||
|
|
|
@ -15,6 +15,9 @@ set(CAUDIO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/i
|
|||
include(cAudio_src_files.cmake)
|
||||
add_library(cAudio ${CAUDIO_LIB_TYPE} ${file_root})
|
||||
|
||||
set(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIRS}/..) #dats gross but it helps finding the headers ;)
|
||||
message(STATUS "openal include dirs:" ${OPENAL_INCLUDE_DIRS})
|
||||
|
||||
if(CAUDIO_ENABLE_OGG)
|
||||
include_directories (include Headers ${CMAKE_BINARY_DIR}/include ${OPENAL_INCLUDE_DIRS} ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
|
||||
target_link_libraries(cAudio ${VORBIS_LIBRARIES} ${OGG_LIBRARIES} ${OPENAL_LIBRARIES})
|
||||
|
@ -26,8 +29,8 @@ else()
|
|||
target_link_libraries(cAudio ${OPENAL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY VERSION "2.3.0")
|
||||
set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY SOVERSION 2 )
|
||||
set_property(TARGET cAudio PROPERTY VERSION "2.3.0")
|
||||
set_property(TARGET cAudio PROPERTY SOVERSION 2 )
|
||||
|
||||
if (APPLE AND CAUDIO_IOS_BUILD)
|
||||
set_target_properties(cAudio PROPERTIES XCODE_ATTRIBUTE_GCC_THUMB_SUPPORT "NO")
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace cAudio
|
||||
{
|
||||
|
||||
#if defined(UNICODE) || defined(_UNICODE)
|
||||
#if defined(CAUDIO_USE_UNICODE)
|
||||
# define _CTEXT(x) L ## x
|
||||
# define cstrcmp wcscmp
|
||||
# define cAudioChar wchar_t
|
||||
|
@ -35,15 +35,15 @@ namespace cAudio
|
|||
#if CAUDIO_REROUTE_STRING_ALLOCATIONS == 1
|
||||
typedef std::basic_string< cAudioChar, std::char_traits<cAudioChar>, cSTLAllocator<cAudioChar> > cAudioString;
|
||||
#else
|
||||
# if defined(UNICODE) || defined(_UNICODE)
|
||||
# if defined(CAUDIO_USE_UNICODE)
|
||||
typedef std::basic_string<cAudioChar> cAudioString;
|
||||
# else
|
||||
typedef std::string cAudioString;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(CAUDIO_PLATFORM_WIN)
|
||||
// Conversion is only required if using wide characters in cAudioString
|
||||
#if defined(CAUDIO_PLATFORM_WIN) && (defined(CAUDIO_USE_UNICODE))
|
||||
static const char* toUTF8(const cAudioString& str)
|
||||
{
|
||||
static int id = 0;
|
||||
|
|
|
@ -138,6 +138,7 @@ namespace cAudio
|
|||
}
|
||||
managedAudioSourcesDelBuffer.clear();
|
||||
}
|
||||
signalEvent(ON_UPDATE);
|
||||
}
|
||||
|
||||
void cAudioManager::run()
|
||||
|
|
Loading…
Reference in New Issue