59 lines
1.8 KiB
C++
59 lines
1.8 KiB
C++
#include <sample/purewave.hpp>
|
|
#include <common/assert.hpp>
|
|
#include <sample/wave.hpp>
|
|
|
|
PureWave::~PureWave()
|
|
{
|
|
destroy();
|
|
}
|
|
|
|
PureWave::PureWave(void)
|
|
: mhProcessInstance(processInstance()), mClassNameString("PLAYBACKSAMPLEDOUTPUT")
|
|
{
|
|
UINT numOutputDevices;
|
|
UINT numInputDevices;
|
|
registerClass();
|
|
createWindow();
|
|
numOutputDevices=::waveOutGetNumDevs();
|
|
numInputDevices=::waveInGetNumDevs();
|
|
for(short deviceIndex=0;deviceIndex<numOutputDevices;deviceIndex++)
|
|
mWaveOutDeviceBlock.insert(&WaveOutDevice(deviceIndex,*this));
|
|
for(deviceIndex=0;deviceIndex<numInputDevices;deviceIndex++)
|
|
mWaveInDeviceBlock.insert(&WaveInDevice(deviceIndex,*this));
|
|
}
|
|
|
|
void PureWave::registerClass(void)const
|
|
{
|
|
WNDCLASS wndClass;
|
|
|
|
if(::GetClassInfo(mhProcessInstance,(LPSTR)mClassNameString,(WNDCLASS FAR*)&wndClass))return;
|
|
wndClass.style =CS_HREDRAW|CS_VREDRAW;
|
|
wndClass.lpfnWndProc =(WNDPROC)Window::WndProc;
|
|
wndClass.cbClsExtra =0;
|
|
wndClass.cbWndExtra =sizeof(PureWave*);
|
|
wndClass.hInstance =mhProcessInstance;
|
|
wndClass.hIcon =::LoadIcon(NULL,IDI_APPLICATION);
|
|
wndClass.hCursor =::LoadCursor(NULL,IDC_ARROW);
|
|
wndClass.hbrBackground =(HBRUSH)::GetStockObject(WHITE_BRUSH);
|
|
wndClass.lpszMenuName =0;
|
|
wndClass.lpszClassName =(LPSTR)mClassNameString;
|
|
::RegisterClass(&wndClass);
|
|
assert(0!=::GetClassInfo(mhProcessInstance,(LPSTR)mClassNameString,(WNDCLASS FAR*)&wndClass));
|
|
}
|
|
|
|
void PureWave::createWindow(void)
|
|
{
|
|
assert(0!=::CreateWindow((LPSTR)mClassNameString,(LPSTR)mClassNameString,
|
|
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
|
|
NULL,NULL,mhProcessInstance,(LPSTR)this));
|
|
show(SW_HIDE);
|
|
update();
|
|
}
|
|
|
|
WORD PureWave::play(WaveForm &someWaveForm,DeviceHandler::PlayMode playMode)
|
|
{
|
|
if(!mWaveOutDeviceBlock.size())return FALSE;
|
|
return (mWaveOutDeviceBlock[0]).play(someWaveForm,playMode);
|
|
}
|
|
|