Would something with this sort of API be helpful?
- Code:
//----------------------------------------------------------------------
class GAPISOUND_API IGapiSound
//----------------------------------------------------------------------
{
public:
virtual ULONG AddRef() = 0;
virtual ULONG Release() = 0;
virtual HRESULT CreateSoundBuffer( IGapiSoundBuffer** ppSoundBuffer ) = 0;
virtual HRESULT DuplicateSoundBuffer( IGapiSoundBuffer* pGsbOriginal, IGapiSoundBuffer** ppGsbDuplicate ) = 0;
virtual HRESULT Activate( BOOL fActive ) = 0;
virtual HRESULT Rebuffer() = 0;
};
//----------------------------------------------------------------------
class GAPISOUND_API IGapiSoundBuffer
//----------------------------------------------------------------------
{
public:
virtual ULONG AddRef() = 0;
virtual ULONG Release() = 0;
// Information
virtual HRESULT GetFormat( WAVEFORMATEX* pwfxFormat, DWORD dwSize, LPDWORD lpdwSizeWritten ) = 0;
virtual HRESULT GetStatus( DWORD* pdwStatus ) = 0;
virtual HRESULT SetFormat( WAVEFORMATEX* pwfxFormat ) = 0; // NOTE: Applies to primary sound buffer
// Play management
virtual HRESULT GetCurrentPosition( DWORD* pdwCurrentPlayCursor ) = 0;
virtual HRESULT Play( DWORD dwReserved1, DWORD dwReserved2, DWORD dwFlags ) = 0;
virtual HRESULT SetCurrentPosition( DWORD dwNewPosition ) = 0;
virtual HRESULT Stop() = 0;
// Data management
virtual HRESULT LoadWaveResource( HMODULE hModule, LPCTSTR lpName, LPCTSTR lpType ) = 0;
virtual HRESULT LoadWaveFile( LPCTSTR szFileName ) = 0;
// Sound management
virtual HRESULT GetPan( LONG* plPan ) = 0;
virtual HRESULT GetVolume( LONG* plVolume ) = 0;
virtual HRESULT SetPan( LONG lPan ) = 0;
virtual HRESULT SetVolume( LONG lVolume ) = 0;
};
I've been cobbling this together by poking at various sources and examples. The DLL (GapiSound.DLL) is by no means complete (stereo and looping are the two big missing E_NOTIMPL features on the TODO list), and presumably full of bugs, but it's functional on WinXP and (last I checked) PPC2000.
I liked Johan's approach of basing the GapiDraw API on DirectDraw, so I stole the name format and hence "GapiSound" is mostly equivalent to DirectSound.
I have only about 2 hours per week to poke at it; if anyone feels like taking it over and hosting the source somewhere (e.g. sourceforge) I'd be happy to offload it.
I'd also love for someone to do a far better job than I'm doing on making Gapi3D:
- Code:
//----------------------------------------------------------------------
class IGapi3DDevice
//----------------------------------------------------------------------
{
public:
virtual ULONG AddRef() = 0;
virtual ULONG Release() = 0;
virtual HRESULT SetTexture( TextureMap* pTexture ) = 0;
virtual HRESULT DrawTLPrimitive( DWORD dwPrimitiveType, G3DTLVERTEX* ptlVertices, DWORD dwVertexCount, DWORD dwFlags ) = 0;
virtual HRESULT DrawIndexedTLPrimitive( DWORD dwPrimitiveType, G3DTLVERTEX* ptlVertices, DWORD dwVertexCount, LPDWORD pdwIndices, DWORD dwIndexCount, DWORD dwFlags ) = 0;
};
Again, the 2 hours a week is keeping it from being a very efficient development process.