Added tutorial 7
This commit is contained in:
parent
66a52d41dd
commit
d9d36a8ced
|
@ -1,6 +1,6 @@
|
|||
//****************************************************************
|
||||
//cAudio 2.0.0 Tutorial 6
|
||||
//Custom event handler
|
||||
//cAudio 2.0.0 Tutorial 7
|
||||
//Custom log receiver
|
||||
//****************************************************************
|
||||
|
||||
#include <iostream>
|
||||
|
@ -9,10 +9,6 @@
|
|||
//Include cAudio.h so we can work wtih cAudio
|
||||
#include "../../include/cAudio.h"
|
||||
|
||||
//Include the test handler
|
||||
#include "cTestHandler.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -51,7 +47,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
//Create a IAudio object and load a sound from a file
|
||||
cAudio::IAudioSource* mysound = manager->create("bling","../../media/cAudioTheme1.ogg",true);
|
||||
mysound->registerEventHandler(handle);
|
||||
|
||||
if(mysound)
|
||||
{
|
||||
mysound->setVolume(0.5);
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="Tutorial7_CustomLogReceiver"
|
||||
ProjectGUID="{23921DF8-FF19-4090-9240-EEE8C2A6B23F}"
|
||||
RootNamespace="Tutorial5_AudioEffects"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../bin/win32-visual"
|
||||
IntermediateDirectory="obj/$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="cAudio.lib"
|
||||
AdditionalLibraryDirectories=""..\..\lib\win32-visual""
|
||||
GenerateDebugInformation="true"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../bin/win32-visual"
|
||||
IntermediateDirectory="obj/$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="cAudio.lib"
|
||||
AdditionalLibraryDirectories=""..\..\lib\win32-visual""
|
||||
GenerateDebugInformation="true"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\cTestLogReceiver.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Headers"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\cTestLogReceiver.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,27 @@
|
|||
#include "cTestLogReceiver.h"
|
||||
#include <iostream>
|
||||
|
||||
cTestLogReceiver::cTestLogReceiver()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
cTestLogReceiver::~cTestLogReceiver()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool cTestLogReceiver::OnLogMessage(const char* sender, const char* message, cAudio::LogLevel level, float time)
|
||||
{
|
||||
//Every time we get a message it will have the following information
|
||||
//What/who sent the message
|
||||
//The message it contains
|
||||
//What log level it is
|
||||
//The time the message was logged
|
||||
//For now we will just display the word MESSAGE everytime we get a new message
|
||||
|
||||
std::cout<<"Message!\n";
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
//****************************************************************
|
||||
//cAudio 2.0.0 Tutorial 7
|
||||
//Custom log receiver
|
||||
//****************************************************************
|
||||
|
||||
//We include the interface of the log receiver
|
||||
#include "../../include/ILogReceiver.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
//Now we make our new class and inherit the ILogReceiver interface
|
||||
class cTestLogReceiver : public cAudio::ILogReceiver
|
||||
{
|
||||
public:
|
||||
//Must have the constructor and desconstructor
|
||||
cTestLogReceiver();
|
||||
~cTestLogReceiver();
|
||||
|
||||
//Only function that must be included in order for the receiver to work
|
||||
bool OnLogMessage(const char* sender, const char* message, cAudio::LogLevel level, float time);
|
||||
|
||||
};
|
|
@ -0,0 +1,90 @@
|
|||
//****************************************************************
|
||||
//cAudio 2.0.0 Tutorial 7
|
||||
//Custom log receiver
|
||||
//****************************************************************
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
//Include cAudio.h so we can work wtih cAudio
|
||||
#include "../../include/cAudio.h"
|
||||
|
||||
//Include the new log receiver
|
||||
#include "cTestLogReceiver.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
//Some fancy text
|
||||
cout << "cAudio 2.0.0 Tutorial 7: Custom log recevier. \n \n";
|
||||
|
||||
//Create an uninitialized Audio Manager
|
||||
cAudio::IAudioManager* manager = cAudio::createAudioManager(false);
|
||||
|
||||
//Now we make a new pointer to our receiver
|
||||
cTestLogReceiver *loggin = new cTestLogReceiver;
|
||||
|
||||
//Once the manager is created we grab instance of the cAudio logger
|
||||
cAudio::ILogger *log = cAudio::getLogger();
|
||||
|
||||
|
||||
//Then we pass our new receiver to it with a unique name
|
||||
log->registerLogReceiver(loggin,"Loggin");
|
||||
|
||||
if(manager)
|
||||
{
|
||||
//Allow the user to choose a playback device
|
||||
cout << "Available Playback Devices: \n";
|
||||
unsigned int deviceCount = manager->getAvailableDeviceCount();
|
||||
std::string defaultDeviceName = manager->getDefaultDeviceName();
|
||||
for(unsigned int i=0; i<deviceCount; ++i)
|
||||
{
|
||||
std::string deviceName = manager->getAvailableDeviceName(i);
|
||||
if(deviceName.compare(defaultDeviceName) == 0)
|
||||
cout << i << "): " << deviceName << " [DEFAULT] \n";
|
||||
else
|
||||
cout << i << "): " << deviceName << " \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
|
||||
manager->initialize(manager->getAvailableDeviceName(deviceSelection));
|
||||
|
||||
//Create a IAudio object and load a sound from a file
|
||||
cAudio::IAudioSource* mysound = manager->create("bling","../../media/cAudioTheme1.ogg",true);
|
||||
|
||||
if(mysound)
|
||||
{
|
||||
mysound->setVolume(0.5);
|
||||
//Set the IAudio Sound to play2d and loop
|
||||
mysound->play2d(false);
|
||||
|
||||
//Wait for the sound to finish playing
|
||||
while(mysound->isPlaying())
|
||||
cAudio::cAudioSleep(10);
|
||||
|
||||
}
|
||||
|
||||
//Delete all IAudio sounds
|
||||
manager->releaseAllSources();
|
||||
//Shutdown cAudio
|
||||
manager->shutDown();
|
||||
|
||||
cAudio::destroyAudioManager(manager);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Failed to create audio playback manager. \n";
|
||||
}
|
||||
|
||||
std::cout << "Press any key to quit \n";
|
||||
std::cin.get();
|
||||
std::cin.get();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -6,8 +6,6 @@
|
|||
#define CFILELOGERCEIVER_H_INCLUDED
|
||||
|
||||
#include "../include/ILogReceiver.h"
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
|
|
|
@ -39,6 +39,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tutorial6_CustomEventHandle
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAXLegacyPreset", "plugins\EAXLegacyPreset\EAXLegacyPreset.vcproj", "{0C1D584C-FBE8-4F9C-BBBF-22D40E2BF421}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tutorial7_CustomLogReceiver", "Examples\Tutorial7_CustomLogReceiver\Tutorial7_CustomLogReceiver.vcproj", "{23921DF8-FF19-4090-9240-EEE8C2A6B23F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -85,6 +87,10 @@ Global
|
|||
{0C1D584C-FBE8-4F9C-BBBF-22D40E2BF421}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{0C1D584C-FBE8-4F9C-BBBF-22D40E2BF421}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{0C1D584C-FBE8-4F9C-BBBF-22D40E2BF421}.Release|Win32.Build.0 = Release|Win32
|
||||
{23921DF8-FF19-4090-9240-EEE8C2A6B23F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{23921DF8-FF19-4090-9240-EEE8C2A6B23F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{23921DF8-FF19-4090-9240-EEE8C2A6B23F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{23921DF8-FF19-4090-9240-EEE8C2A6B23F}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
Loading…
Reference in New Issue