mirror of https://github.com/axmolengine/axmol.git
fixed #180 implement SimpleAudioEngine using MCI. Support Midi and wave default.
This commit is contained in:
parent
1b81908ae4
commit
dba50b2693
|
@ -0,0 +1,215 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="CocosDenshion-win32"
|
||||
ProjectGUID="{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}"
|
||||
RootNamespace="CocosDenshion-win32"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="0"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=".\Include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;COCOSDENSHIONWIN32_EXPORTS;_EXPORT_DLL_"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)\libCocosDenshion.dll"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
ImportLibrary="$(TargetDir)libCocosDenshion.lib"
|
||||
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="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=".\Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;COCOSDENSHIONWIN32_EXPORTS;_EXPORT_DLL_"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="winmm.lib"
|
||||
OutputFile="$(OutDir)\libCocosDenshion.dll"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
ImportLibrary="$(TargetDir)libCocosDenshion.lib"
|
||||
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="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Export.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\win32\MciPlayer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\SimpleAudioEngine.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\win32\MciPlayer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\win32\SimpleAudioEngine.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><VisualStudioUserFile ProjectType="Visual C++" Version="9.00" ShowAllFiles="true"></VisualStudioUserFile>
|
|
@ -97,6 +97,12 @@ public:
|
|||
void unloadEffect(int nSoundId);
|
||||
|
||||
|
||||
/*!***************************************************************************
|
||||
@brief unload all preloaded effect from internal buffer
|
||||
*****************************************************************************/
|
||||
void unloadEffectAll();
|
||||
|
||||
|
||||
/*!***************************************************************************
|
||||
@brief play the preloaded effect
|
||||
@param[in] nSoundId the sound id returned from preloadEffect
|
||||
|
|
|
@ -0,0 +1,207 @@
|
|||
#include "MciPlayer.h"
|
||||
|
||||
#define WIN_CLASS_NAME "CocosDenshionCallbackWnd"
|
||||
#define BREAK_IF(cond) if (cond) break;
|
||||
|
||||
static HINSTANCE s_hInstance;
|
||||
static MCIERROR s_mciError;
|
||||
|
||||
static LRESULT WINAPI _SoundPlayProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
MciPlayer::MciPlayer()
|
||||
: m_hWnd(NULL)
|
||||
, m_hDev(NULL)
|
||||
, m_nSoundID(0)
|
||||
, m_uTimes(0)
|
||||
, m_bPlaying(false)
|
||||
{
|
||||
if (! s_hInstance)
|
||||
{
|
||||
s_hInstance = GetModuleHandle( NULL ); // Grab An Instance For Our Window
|
||||
|
||||
WNDCLASS wc; // Windows Class Structure
|
||||
|
||||
// Redraw On Size, And Own DC For Window.
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = _SoundPlayProc; // WndProc Handles Messages
|
||||
wc.cbClsExtra = 0; // No Extra Window Data
|
||||
wc.cbWndExtra = 0; // No Extra Window Data
|
||||
wc.hInstance = s_hInstance; // Set The Instance
|
||||
wc.hIcon = 0; // Load The Default Icon
|
||||
wc.hCursor = LoadCursor( NULL, IDC_ARROW ); // Load The Arrow Pointer
|
||||
wc.hbrBackground = NULL; // No Background Required For GL
|
||||
wc.lpszMenuName = NULL; // We Don't Want A Menu
|
||||
wc.lpszClassName = WIN_CLASS_NAME; // Set The Class Name
|
||||
|
||||
if (! RegisterClass(&wc) // 注册 窗口类 失败
|
||||
&& 1410 != GetLastError()) // 并且失败的原因不是窗口类已注册
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_hWnd = CreateWindowEx(
|
||||
WS_EX_APPWINDOW, // Extended Style For The Window
|
||||
WIN_CLASS_NAME, // Class Name
|
||||
NULL, // Window Title
|
||||
WS_POPUPWINDOW,/*WS_OVERLAPPEDWINDOW*/ // Defined Window Style
|
||||
0, 0, // Window Position
|
||||
0, // Window Width
|
||||
0, // Window Height
|
||||
NULL, // No Parent Window
|
||||
NULL, // No Menu
|
||||
s_hInstance, // Instance
|
||||
NULL );
|
||||
if (m_hWnd)
|
||||
{
|
||||
SetWindowLong(m_hWnd, GWL_USERDATA, (LONG)this);
|
||||
}
|
||||
}
|
||||
|
||||
MciPlayer::~MciPlayer()
|
||||
{
|
||||
Close();
|
||||
DestroyWindow(m_hWnd);
|
||||
}
|
||||
|
||||
void MciPlayer::Open(const char* pFileName, UINT uId)
|
||||
{
|
||||
// WCHAR * pBuf = NULL;
|
||||
do
|
||||
{
|
||||
BREAK_IF(! pFileName || ! m_hWnd);
|
||||
int nLen = (int)strlen(pFileName);
|
||||
BREAK_IF(! nLen);
|
||||
// pBuf = new WCHAR[nLen + 1];
|
||||
// BREAK_IF(! pBuf);
|
||||
// MultiByteToWideChar(CP_ACP, 0, pFileName, nLen + 1, pBuf, nLen + 1);
|
||||
|
||||
Close();
|
||||
|
||||
MCI_OPEN_PARMS mciOpen = {0};
|
||||
MCIERROR mciError;
|
||||
mciOpen.lpstrDeviceType = (LPCTSTR)MCI_ALL_DEVICE_ID;
|
||||
mciOpen.lpstrElementName = pFileName;
|
||||
|
||||
mciError = mciSendCommand(0,MCI_OPEN, MCI_OPEN_ELEMENT, (DWORD)&mciOpen);
|
||||
BREAK_IF(mciError);
|
||||
|
||||
m_hDev = mciOpen.wDeviceID;
|
||||
m_nSoundID = uId;
|
||||
m_bPlaying = false;
|
||||
} while (0);
|
||||
}
|
||||
|
||||
void MciPlayer::Play(UINT uTimes /* = 1 */)
|
||||
{
|
||||
if (! m_hDev)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MCI_PLAY_PARMS mciPlay = {0};
|
||||
mciPlay.dwCallback = (DWORD_PTR)m_hWnd;
|
||||
s_mciError = mciSendCommand(m_hDev,MCI_PLAY, MCI_NOTIFY,(DWORD)&mciPlay);
|
||||
if (! s_mciError)
|
||||
{
|
||||
m_bPlaying = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MciPlayer::Close()
|
||||
{
|
||||
if (m_bPlaying)
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
if (m_hDev)
|
||||
{
|
||||
_SendGenericCommand(MCI_CLOSE);
|
||||
}
|
||||
m_hDev = 0;
|
||||
m_bPlaying = false;
|
||||
}
|
||||
|
||||
void MciPlayer::Pause()
|
||||
{
|
||||
_SendGenericCommand(MCI_PAUSE);
|
||||
}
|
||||
|
||||
void MciPlayer::Resume()
|
||||
{
|
||||
_SendGenericCommand(MCI_RESUME);
|
||||
}
|
||||
|
||||
void MciPlayer::Stop()
|
||||
{
|
||||
_SendGenericCommand(MCI_STOP);
|
||||
m_bPlaying = false;
|
||||
}
|
||||
|
||||
void MciPlayer::Rewind()
|
||||
{
|
||||
if (! m_hDev)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mciSendCommand(m_hDev, MCI_SEEK, MCI_SEEK_TO_START, 0);
|
||||
|
||||
MCI_PLAY_PARMS mciPlay = {0};
|
||||
mciPlay.dwCallback = (DWORD)m_hWnd;
|
||||
m_bPlaying = mciSendCommand(m_hDev, MCI_PLAY, MCI_NOTIFY,(DWORD)&mciPlay) ? false : true;
|
||||
}
|
||||
|
||||
bool MciPlayer::IsPlaying()
|
||||
{
|
||||
return m_bPlaying;
|
||||
}
|
||||
|
||||
UINT MciPlayer::GetSoundID()
|
||||
{
|
||||
return m_nSoundID;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// private member
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void MciPlayer::_SendGenericCommand(int nCommand)
|
||||
{
|
||||
if (! m_hDev)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mciSendCommand(m_hDev, nCommand, 0, 0);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// static function
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT WINAPI _SoundPlayProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
MciPlayer * pPlayer = NULL;
|
||||
if (MM_MCINOTIFY == Msg
|
||||
&& MCI_NOTIFY_SUCCESSFUL == wParam
|
||||
&&(pPlayer = (MciPlayer *)GetWindowLong(hWnd, GWL_USERDATA)))
|
||||
{
|
||||
if (pPlayer->m_uTimes)
|
||||
{
|
||||
--pPlayer->m_uTimes;
|
||||
}
|
||||
|
||||
if (pPlayer->m_uTimes)
|
||||
{
|
||||
mciSendCommand(lParam, MCI_SEEK, MCI_SEEK_TO_START, 0);
|
||||
|
||||
MCI_PLAY_PARMS mciPlay = {0};
|
||||
mciPlay.dwCallback = (DWORD)hWnd;
|
||||
mciSendCommand(lParam, MCI_PLAY, MCI_NOTIFY,(DWORD)&mciPlay);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPlayer->m_bPlaying = false;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProc(hWnd, Msg, wParam, lParam);
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
#ifndef _MCI_PLAYER_UPHONE_H_
|
||||
#define _MCI_PLAYER_UPHONE_H_
|
||||
|
||||
#include<windows.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
class MciPlayer
|
||||
{
|
||||
public:
|
||||
MciPlayer();
|
||||
~MciPlayer();
|
||||
|
||||
void Close();
|
||||
|
||||
/**
|
||||
@brief 播放声音文件
|
||||
@param pFileName 播放的声音文件名称,需要包含文件的路径
|
||||
@param nTimes 播放声音文件的循环次数,默认值为 1,即播放一次
|
||||
*/
|
||||
void Open(const char* pFileName, UINT uId);
|
||||
|
||||
void Play(UINT uTimes = 1);
|
||||
|
||||
/**
|
||||
@brief 暂停播放声音
|
||||
*/
|
||||
void Pause();
|
||||
|
||||
/**
|
||||
@brief 继续播放声音
|
||||
*/
|
||||
void Resume();
|
||||
|
||||
/**
|
||||
@brief 停止播放声音
|
||||
*/
|
||||
void Stop();
|
||||
|
||||
/**
|
||||
@brief 重新播放
|
||||
*/
|
||||
void Rewind();
|
||||
|
||||
/**
|
||||
@brief 获取播放器当前是否正在播放中
|
||||
*/
|
||||
bool IsPlaying();
|
||||
|
||||
/**
|
||||
@brief 获取当前播放的音效 ID
|
||||
@return 当前播放的音效ID
|
||||
*/
|
||||
UINT GetSoundID();
|
||||
|
||||
private:
|
||||
friend LRESULT WINAPI _SoundPlayProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
void _SendGenericCommand(int nCommand);
|
||||
|
||||
HWND m_hWnd;
|
||||
MCIDEVICEID m_hDev;
|
||||
UINT m_nSoundID;
|
||||
UINT m_uTimes;
|
||||
bool m_bPlaying;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,227 @@
|
|||
#include "SimpleAudioEngine.h"
|
||||
|
||||
#include <map>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MciPlayer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef map<unsigned int, MciPlayer> EffectList;
|
||||
typedef pair<unsigned int ,MciPlayer> Effect;
|
||||
|
||||
static SimpleAudioEngine s_SharedEngine;
|
||||
static EffectList s_List;
|
||||
static MciPlayer s_Music;
|
||||
static char s_szRootPath[MAX_PATH];
|
||||
static DWORD s_dwRootLen;
|
||||
static char s_szFullPath[MAX_PATH];
|
||||
|
||||
|
||||
static const char * _FullPath(const char * szPath);
|
||||
static unsigned int _Hash(const char *key);
|
||||
|
||||
#define BREAK_IF(cond) if (cond) break;
|
||||
|
||||
SimpleAudioEngine::SimpleAudioEngine()
|
||||
{
|
||||
}
|
||||
|
||||
SimpleAudioEngine::~SimpleAudioEngine()
|
||||
{
|
||||
}
|
||||
|
||||
SimpleAudioEngine* SimpleAudioEngine::getSharedEngine()
|
||||
{
|
||||
return &s_SharedEngine;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// BackgroundMusic
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)
|
||||
{
|
||||
if (! pszFilePath)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
s_Music.Open(_FullPath(pszFilePath), _Hash(pszFilePath));
|
||||
s_Music.Play((bLoop) ? -1 : 1);
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::stopBackgroundMusic()
|
||||
{
|
||||
s_Music.Stop();
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::pauseBackgroundMusic()
|
||||
{
|
||||
s_Music.Pause();
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::resumeBackgroundMusic()
|
||||
{
|
||||
s_Music.Resume();
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::rewindBackgroundMusic()
|
||||
{
|
||||
s_Music.Rewind();
|
||||
}
|
||||
|
||||
bool SimpleAudioEngine::willPlayBackgroundMusic()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SimpleAudioEngine::isBackgroundMusicPlaying()
|
||||
{
|
||||
return s_Music.IsPlaying();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// effect function
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int SimpleAudioEngine::playEffect(const char* pszFilePath)
|
||||
{
|
||||
int nRet = preloadEffect(pszFilePath);
|
||||
if (nRet)
|
||||
{
|
||||
playPreloadedEffect(nRet);
|
||||
}
|
||||
return nRet;
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::stopEffect(int nSoundId)
|
||||
{
|
||||
EffectList::iterator p = s_List.find(nSoundId);
|
||||
if (p != s_List.end())
|
||||
{
|
||||
p->second.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
int SimpleAudioEngine::preloadEffect(const char* pszFilePath)
|
||||
{
|
||||
int nRet = 0;
|
||||
do
|
||||
{
|
||||
BREAK_IF(! pszFilePath);
|
||||
|
||||
nRet = _Hash(pszFilePath);
|
||||
|
||||
BREAK_IF(s_List.end() != s_List.find(nRet));
|
||||
|
||||
s_List.insert(Effect(nRet, MciPlayer()));
|
||||
MciPlayer& player = s_List[nRet];
|
||||
player.Open(_FullPath(pszFilePath), nRet);
|
||||
|
||||
BREAK_IF(nRet == player.GetSoundID());
|
||||
|
||||
s_List.erase(nRet);
|
||||
nRet = 0;
|
||||
} while (0);
|
||||
return nRet;
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::unloadEffect(int nSoundId)
|
||||
{
|
||||
s_List.erase(nSoundId);
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::unloadEffectAll()
|
||||
{
|
||||
s_List.clear();
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::playPreloadedEffect(int nSoundId)
|
||||
{
|
||||
EffectList::iterator p = s_List.find(nSoundId);
|
||||
if (p != s_List.end())
|
||||
{
|
||||
p->second.Rewind();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// volume interface
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int SimpleAudioEngine::GetBackgroundMusicVolume()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::SetBackgroundMusicVolume(int volume)
|
||||
{
|
||||
}
|
||||
|
||||
int SimpleAudioEngine::GetEffectsVolume()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::SetEffectsVolume(int volume)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// resource function
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SimpleAudioEngine::setSoundResInfo(const T_SoundResInfo ResInfo[], int nCount)
|
||||
{
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::setResourceEntry(const void* pResEntry)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// static function
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const char * _FullPath(const char * szPath)
|
||||
{
|
||||
if (! s_szRootPath[0])
|
||||
{
|
||||
s_dwRootLen = GetModuleFileName(NULL, s_szRootPath, sizeof(s_szRootPath));
|
||||
while (--s_dwRootLen)
|
||||
{
|
||||
if ('\\' == s_szRootPath[s_dwRootLen])
|
||||
{
|
||||
s_szRootPath[s_dwRootLen + 1] = 0;
|
||||
strcpy_s(s_szFullPath, sizeof(s_szFullPath), s_szRootPath);
|
||||
++s_dwRootLen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != szPath[0] && ':' != szPath[1])
|
||||
{
|
||||
strcpy_s(s_szFullPath + s_dwRootLen, sizeof(s_szFullPath) - s_dwRootLen, szPath);
|
||||
return s_szFullPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return szPath;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int _Hash(const char *key)
|
||||
{
|
||||
unsigned int len = strlen(key);
|
||||
const char *end=key+len;
|
||||
unsigned int hash;
|
||||
|
||||
for (hash = 0; key < end; key++)
|
||||
{
|
||||
hash *= 16777619;
|
||||
hash ^= (unsigned int) (unsigned char) toupper(*key);
|
||||
}
|
||||
return (hash);
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
|
||||
// TestAudioEngine-win32.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "TestAudioEngine-win32.h"
|
||||
#include "TestAudioEngine-win32Dlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
|
||||
// CTestAudioEnginewin32App
|
||||
|
||||
BEGIN_MESSAGE_MAP(CTestAudioEnginewin32App, CWinAppEx)
|
||||
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CTestAudioEnginewin32App construction
|
||||
|
||||
CTestAudioEnginewin32App::CTestAudioEnginewin32App()
|
||||
{
|
||||
// TODO: add construction code here,
|
||||
// Place all significant initialization in InitInstance
|
||||
}
|
||||
|
||||
|
||||
// The one and only CTestAudioEnginewin32App object
|
||||
|
||||
CTestAudioEnginewin32App theApp;
|
||||
|
||||
|
||||
// CTestAudioEnginewin32App initialization
|
||||
|
||||
BOOL CTestAudioEnginewin32App::InitInstance()
|
||||
{
|
||||
CWinAppEx::InitInstance();
|
||||
|
||||
// Standard initialization
|
||||
// If you are not using these features and wish to reduce the size
|
||||
// of your final executable, you should remove from the following
|
||||
// the specific initialization routines you do not need
|
||||
// Change the registry key under which our settings are stored
|
||||
// TODO: You should modify this string to be something appropriate
|
||||
// such as the name of your company or organization
|
||||
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
|
||||
|
||||
CTestAudioEnginewin32Dlg dlg;
|
||||
m_pMainWnd = &dlg;
|
||||
INT_PTR nResponse = dlg.DoModal();
|
||||
if (nResponse == IDOK)
|
||||
{
|
||||
// TODO: Place code here to handle when the dialog is
|
||||
// dismissed with OK
|
||||
}
|
||||
else if (nResponse == IDCANCEL)
|
||||
{
|
||||
// TODO: Place code here to handle when the dialog is
|
||||
// dismissed with Cancel
|
||||
}
|
||||
|
||||
// Since the dialog has been closed, return FALSE so that we exit the
|
||||
// application, rather than start the application's message pump.
|
||||
return FALSE;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
// TestAudioEngine-win32.h : main header file for the PROJECT_NAME application
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error "include 'stdafx.h' before including this file for PCH"
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
|
||||
// CTestAudioEnginewin32App:
|
||||
// See TestAudioEngine-win32.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CTestAudioEnginewin32App : public CWinAppEx
|
||||
{
|
||||
public:
|
||||
CTestAudioEnginewin32App();
|
||||
|
||||
// Overrides
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
|
||||
// Implementation
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
extern CTestAudioEnginewin32App theApp;
|
|
@ -0,0 +1,188 @@
|
|||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
#include "targetver.h"
|
||||
#endif
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Chinese (P.R.C.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
|
||||
#pragma code_page(936)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#ifndef APSTUDIO_INVOKED\r\n"
|
||||
"#include ""targetver.h""\r\n"
|
||||
"#endif\r\n"
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_OLE_RESOURCES\r\n"
|
||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
|
||||
"\r\n"
|
||||
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
|
||||
"LANGUAGE 9, 1\r\n"
|
||||
"#pragma code_page(1252)\r\n"
|
||||
"#include ""res\\TestAudioEnginewin32.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
|
||||
"#include ""afxres.rc"" // Standard components\r\n"
|
||||
"#endif\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDR_MAINFRAME ICON "res\\TestAudioEngine-win32.ico"
|
||||
#endif // Chinese (P.R.C.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_TESTAUDIOENGINEWIN32_DIALOG DIALOGEX 0, 0, 320, 200
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_APPWINDOW
|
||||
CAPTION "TestAudioEngine-win32"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,209,179,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,263,179,50,14
|
||||
PUSHBUTTON "music",IDC_MUSIC,24,22,50,14
|
||||
PUSHBUTTON "effect 1",IDC_EFFECT1,24,49,50,14
|
||||
PUSHBUTTON "effect 2",IDC_EFFECT2,89,49,50,14
|
||||
PUSHBUTTON "stop music",IDC_MUSIC_STOP,88,23,50,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "TODO: <Company name>"
|
||||
VALUE "FileDescription", "TODO: <File description>"
|
||||
VALUE "FileVersion", "1.0.0.1"
|
||||
VALUE "InternalName", "TestAudioEngine-win32.exe"
|
||||
VALUE "LegalCopyright", "TODO: (c) <Company name>. All rights reserved."
|
||||
VALUE "OriginalFilename", "TestAudioEngine-win32.exe"
|
||||
VALUE "ProductName", "TODO: <Product name>"
|
||||
VALUE "ProductVersion", "1.0.0.1"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_TESTAUDIOENGINEWIN32_DIALOG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 313
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 193
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#define _AFX_NO_SPLITTER_RESOURCES
|
||||
#define _AFX_NO_OLE_RESOURCES
|
||||
#define _AFX_NO_TRACKER_RESOURCES
|
||||
#define _AFX_NO_PROPERTY_RESOURCES
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE 9, 1
|
||||
#pragma code_page(1252)
|
||||
#include "res\TestAudioEnginewin32.rc2" // non-Microsoft Visual C++ edited resources
|
||||
#include "afxres.rc" // Standard components
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
|
@ -0,0 +1,276 @@
|
|||
<?xml version="1.0" encoding="gb2312"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="TestAudioEngine-win32"
|
||||
ProjectGUID="{3A08EAB1-1042-4085-BACA-03A5BDD0F214}"
|
||||
RootNamespace="TestAudioEnginewin32"
|
||||
Keyword="MFCProj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="false"
|
||||
ValidateParameters="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\CocosDenshion\Include"
|
||||
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"
|
||||
AdditionalIncludeDirectories="$(IntDir)"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libCocosDenshion.lib"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""$(OutDir)""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="copy /Y $(ProjectDir)Res\*.mid $(OutDir)
copy /Y $(ProjectDir)Res\*.wav $(OutDir)
"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="2"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="false"
|
||||
ValidateParameters="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="..\CocosDenshion\Include"
|
||||
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG"
|
||||
MinimalRebuild="false"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"
|
||||
AdditionalIncludeDirectories="$(IntDir)"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libCocosDenshion.lib"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""$(OutDir)""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
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"
|
||||
CommandLine="copy /Y $(ProjectDir)Res\*.mid $(OutDir)
copy /Y $(ProjectDir)Res\*.wav $(OutDir)
"
|
||||
/>
|
||||
</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=".\stdafx.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TestAudioEngine-win32.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TestAudioEngine-win32Dlg.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\targetver.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TestAudioEngine-win32.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TestAudioEngine-win32Dlg.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}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\res\TestAudioEngine-win32.ico"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TestAudioEngine-win32.rc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\res\TestAudioEnginewin32.rc2"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
<Global
|
||||
Name="RESOURCE_FILE"
|
||||
Value="TestAudioEngine-win32.rc"
|
||||
/>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,130 @@
|
|||
|
||||
// TestAudioEngine-win32Dlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "TestAudioEngine-win32.h"
|
||||
#include "TestAudioEngine-win32Dlg.h"
|
||||
|
||||
#include "SimpleAudioEngine.h"
|
||||
|
||||
const static char kszMusic[] = "music.mid";
|
||||
const static char kszEffect1[] = "effect1.wav";
|
||||
const static char kszEffect2[] = "effect2.wav";
|
||||
|
||||
static int s_nEffect1;
|
||||
static int s_nEffect2;
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
|
||||
// CTestAudioEnginewin32Dlg dialog
|
||||
|
||||
|
||||
|
||||
|
||||
CTestAudioEnginewin32Dlg::CTestAudioEnginewin32Dlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CTestAudioEnginewin32Dlg::IDD, pParent)
|
||||
{
|
||||
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
||||
}
|
||||
|
||||
void CTestAudioEnginewin32Dlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CTestAudioEnginewin32Dlg, CDialog)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_QUERYDRAGICON()
|
||||
//}}AFX_MSG_MAP
|
||||
ON_BN_CLICKED(IDC_MUSIC, &CTestAudioEnginewin32Dlg::OnBnClickedMusic)
|
||||
ON_BN_CLICKED(IDC_MUSIC_STOP, &CTestAudioEnginewin32Dlg::OnBnClickedMusicStop)
|
||||
ON_BN_CLICKED(IDC_EFFECT1, &CTestAudioEnginewin32Dlg::OnBnClickedEffect1)
|
||||
ON_BN_CLICKED(IDC_EFFECT2, &CTestAudioEnginewin32Dlg::OnBnClickedEffect2)
|
||||
// ON_WM_CLOSE()
|
||||
ON_WM_DESTROY()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CTestAudioEnginewin32Dlg message handlers
|
||||
|
||||
BOOL CTestAudioEnginewin32Dlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// Set the icon for this dialog. The framework does this automatically
|
||||
// when the application's main window is not a dialog
|
||||
SetIcon(m_hIcon, TRUE); // Set big icon
|
||||
SetIcon(m_hIcon, FALSE); // Set small icon
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
}
|
||||
|
||||
// If you add a minimize button to your dialog, you will need the code below
|
||||
// to draw the icon. For MFC applications using the document/view model,
|
||||
// this is automatically done for you by the framework.
|
||||
|
||||
void CTestAudioEnginewin32Dlg::OnPaint()
|
||||
{
|
||||
if (IsIconic())
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
|
||||
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
|
||||
|
||||
// Center icon in client rectangle
|
||||
int cxIcon = GetSystemMetrics(SM_CXICON);
|
||||
int cyIcon = GetSystemMetrics(SM_CYICON);
|
||||
CRect rect;
|
||||
GetClientRect(&rect);
|
||||
int x = (rect.Width() - cxIcon + 1) / 2;
|
||||
int y = (rect.Height() - cyIcon + 1) / 2;
|
||||
|
||||
// Draw the icon
|
||||
dc.DrawIcon(x, y, m_hIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
CDialog::OnPaint();
|
||||
}
|
||||
}
|
||||
|
||||
// The system calls this function to obtain the cursor to display while the user drags
|
||||
// the minimized window.
|
||||
HCURSOR CTestAudioEnginewin32Dlg::OnQueryDragIcon()
|
||||
{
|
||||
return static_cast<HCURSOR>(m_hIcon);
|
||||
}
|
||||
|
||||
void CTestAudioEnginewin32Dlg::OnBnClickedMusic()
|
||||
{
|
||||
SimpleAudioEngine::getSharedEngine()->playBackgroundMusic(kszMusic, true);
|
||||
}
|
||||
|
||||
void CTestAudioEnginewin32Dlg::OnBnClickedMusicStop()
|
||||
{
|
||||
SimpleAudioEngine::getSharedEngine()->stopBackgroundMusic();
|
||||
}
|
||||
|
||||
void CTestAudioEnginewin32Dlg::OnBnClickedEffect1()
|
||||
{
|
||||
s_nEffect1 = SimpleAudioEngine::getSharedEngine()->playEffect(kszEffect1);
|
||||
}
|
||||
|
||||
void CTestAudioEnginewin32Dlg::OnBnClickedEffect2()
|
||||
{
|
||||
s_nEffect2 = SimpleAudioEngine::getSharedEngine()->playEffect(kszEffect2);
|
||||
}
|
||||
|
||||
void CTestAudioEnginewin32Dlg::OnDestroy()
|
||||
{
|
||||
CDialog::OnDestroy();
|
||||
|
||||
SimpleAudioEngine::getSharedEngine()->stopBackgroundMusic();
|
||||
SimpleAudioEngine::getSharedEngine()->unloadEffectAll();
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
// TestAudioEngine-win32Dlg.h : header file
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
// CTestAudioEnginewin32Dlg dialog
|
||||
class CTestAudioEnginewin32Dlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CTestAudioEnginewin32Dlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
enum { IDD = IDD_TESTAUDIOENGINEWIN32_DIALOG };
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
HICON m_hIcon;
|
||||
|
||||
// Generated message map functions
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnPaint();
|
||||
afx_msg HCURSOR OnQueryDragIcon();
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
afx_msg void OnBnClickedMusic();
|
||||
afx_msg void OnBnClickedMusicStop();
|
||||
afx_msg void OnBnClickedEffect1();
|
||||
afx_msg void OnBnClickedEffect2();
|
||||
// afx_msg void OnClose();
|
||||
afx_msg void OnDestroy();
|
||||
};
|
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
|
@ -0,0 +1,13 @@
|
|||
//
|
||||
// TestAudioEnginewin32.RC2 - resources Microsoft Visual C++ does not edit directly
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#error this file is not editable by Microsoft Visual C++
|
||||
#endif //APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Add manually edited resources here...
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,22 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by TestAudioEngine-win32.rc
|
||||
//
|
||||
#define IDD_TESTAUDIOENGINEWIN32_DIALOG 102
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDC_MUSIC 1000
|
||||
#define IDC_EFFECT1 1001
|
||||
#define IDC_EFFECT2 1002
|
||||
#define IDC_BUTTON4 1003
|
||||
#define IDC_MUSIC_STOP 1003
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1004
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// TestAudioEngine-win32.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently,
|
||||
// but are changed infrequently
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _SECURE_ATL
|
||||
#define _SECURE_ATL 1
|
||||
#endif
|
||||
|
||||
#ifndef VC_EXTRALEAN
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
#endif
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
|
||||
|
||||
// turns off MFC's hiding of some common and often safely ignored warning messages
|
||||
#define _AFX_ALL_WARNINGS
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _AFX_NO_OLE_SUPPORT
|
||||
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
|
||||
#endif
|
||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxcmn.h> // MFC support for Windows Common Controls
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
|
||||
#include <afxcontrolbars.h> // MFC support for ribbons and control bars
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
// The following macros define the minimum required platform. The minimum required platform
|
||||
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
|
||||
// your application. The macros work by enabling all features available on platform versions up to and
|
||||
// including the version specified.
|
||||
|
||||
// Modify the following defines if you have to target a platform prior to the ones specified below.
|
||||
// Refer to MSDN for the latest info on corresponding values for different platforms.
|
||||
#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.
|
||||
#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
|
||||
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
|
||||
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
|
||||
#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
|
||||
#endif
|
||||
|
|
@ -19,6 +19,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-win32", "test_win32\te
|
|||
{929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CocosDenshion-win32", "CocosDenshion\CocosDenshion-win32.vcproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestAudioEngine-win32", "TestAudioEngine-win32\TestAudioEngine-win32.vcproj", "{3A08EAB1-1042-4085-BACA-03A5BDD0F214}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -45,6 +52,14 @@ Global
|
|||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.Build.0 = Release|Win32
|
||||
{3A08EAB1-1042-4085-BACA-03A5BDD0F214}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{3A08EAB1-1042-4085-BACA-03A5BDD0F214}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{3A08EAB1-1042-4085-BACA-03A5BDD0F214}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{3A08EAB1-1042-4085-BACA-03A5BDD0F214}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
Loading…
Reference in New Issue