// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <windows.h>
#include <windowsx.h>
-#ifndef __GNUWIN32__
-#include <mmsystem.h>
-#endif
-
-#ifdef __GNUWIN32__
-#include "wx/msw/gnuwin32/extra.h"
+#ifdef __GNUWIN32_OLD__
+ #include "wx/msw/gnuwin32/extra.h"
+#else
+ #include <mmsystem.h>
#endif
wxWave::wxWave()
- : m_waveLength(0), m_isResource(FALSE), m_waveData(NULL)
+ : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
{
}
wxWave::wxWave(const wxString& sFileName, bool isResource)
- : m_waveLength(0), m_isResource(isResource), m_waveData(NULL)
+ : m_waveData(NULL), m_waveLength(0), m_isResource(isResource)
{
Create(sFileName, isResource);
}
+wxWave::wxWave(int size, const wxByte* data)
+ : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
+{
+ Create(size, data);
+}
wxWave::~wxWave()
{
m_isResource = TRUE;
HRSRC hresInfo;
-#ifdef __WIN32__
- hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, "WAVE");
+#if defined(__WIN32__) && !defined(__TWIN32__)
+#ifdef _UNICODE
+ hresInfo = ::FindResourceW((HMODULE) wxhInstance, fileName, wxT("WAVE"));
#else
- hresInfo = ::FindResource((HMODULE) wxhInstance, fileName, "WAVE");
+ hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, wxT("WAVE"));
+#endif
+#else
+ hresInfo = ::FindResource((HMODULE) wxhInstance, fileName, wxT("WAVE"));
#endif
if (!hresInfo)
return FALSE;
if (waveData)
{
- m_waveData= (byte*)::LockResource(waveData);
+ m_waveData= (wxByte*)::LockResource(waveData);
m_waveLength = (int) ::SizeofResource((HMODULE) wxhInstance, hresInfo);
}
m_waveLength = (int) fileWave.Length();
- m_waveData = (byte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
+ m_waveData = (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
if (!m_waveData)
return FALSE;
}
}
+bool wxWave::Create(int size, const wxByte* data)
+{
+ Free();
+ m_isResource = FALSE;
+ m_waveLength=size;
+ m_waveData = (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
+ if (!m_waveData)
+ return FALSE;
+
+ for (int i=0; i<size; i++) m_waveData[i] = data[i];
+ return TRUE;
+}
+
bool wxWave::Play(bool async, bool looped) const
{
if (!IsOk())
return FALSE;
#ifdef __WIN32__
- return ( ::PlaySound((LPCSTR)m_waveData, NULL, SND_MEMORY |
+ return ( ::PlaySound((LPCTSTR)m_waveData, NULL, SND_MEMORY |
SND_NODEFAULT | (async ? SND_ASYNC : SND_SYNC) | (looped ? (SND_LOOP | SND_ASYNC) : 0)) != 0 );
#else
return ( ::sndPlaySound((LPCSTR)m_waveData, SND_MEMORY |