/////////////////////////////////////////////////////////////////////////////
// Name: wave.cpp
// Purpose: wxWave class implementation: optional
-// Author: AUTHOR
+// Author: David Webster
// Modified by:
-// Created: ??/??/98
+// Created: 10/17/99
// RCS-ID: $Id$
-// Copyright: (c) AUTHOR
-// Licence: wxWindows licence
+// Copyright: (c) David Webster
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
-#pragma implementation "wave.h"
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
#endif
-#include "wx/object.h"
-#include "wx/string.h"
-#include "wx/stubs/wave.h"
+#include "wx/file.h"
+#include "wx/os2/wave.h"
+#define INCL_32 /* force 32 bit compile */
+#define INCL_GPIBITMAPS
+#define INCL_DOSFILEMGR
+#define INCL_WIN
+#define INCL_GPI
+#define INCL_PM
+#include <os2.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <os2medef.h>
+#include <mmioos2.h>
wxWave::wxWave()
: m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
}
wxWave::wxWave(const wxString& sFileName, bool isResource)
- : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
+ : m_waveData(NULL), m_waveLength(0), m_isResource(isResource)
{
- Create(sFileName, 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()
{
- Free();
+ Free();
}
bool wxWave::Create(const wxString& fileName, bool isResource)
{
- Free();
+ Free();
- // TODO
+ if (isResource)
+ {
+ m_isResource = TRUE;
+// TODO:
+/*
+ HRSRC hresInfo;
+#ifdef _UNICODE
+ hresInfo = ::FindResourceW((HMODULE) wxhInstance, fileName, wxT("WAVE"));
+#else
+ hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, wxT("WAVE"));
+#endif
+ if (!hresInfo)
+ return FALSE;
+ HGLOBAL waveData = ::LoadResource((HMODULE) wxhInstance, hresInfo);
+
+ if (waveData)
+ {
+ m_waveData= (wxByte*)::LockResource(waveData);
+ m_waveLength = (int) ::SizeofResource((HMODULE) wxhInstance, hresInfo);
+ }
+
+ return (m_waveData ? TRUE : FALSE);
+*/
return FALSE;
+ }
+ else
+ {
+ m_isResource = FALSE;
+
+ wxFile fileWave;
+ if (!fileWave.Open(fileName, wxFile::read))
+ return FALSE;
+
+ m_waveLength = (int) fileWave.Length();
+// TODO:
+/*
+ m_waveData = (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
+ if (!m_waveData)
+ return FALSE;
+
+ fileWave.Read(m_waveData, m_waveLength);
+*/
+ return TRUE;
+ }
}
-bool wxWave::Play(bool async, bool looped) const
+bool wxWave::Create(int size, const wxByte* data)
{
- if (!IsOk())
- return FALSE;
+ Free();
+ m_isResource = FALSE;
+ m_waveLength=size;
+ m_waveData = NULL; // (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
+ if (!m_waveData)
+ return FALSE;
- // TODO
- return FALSE;
+ for (int i=0; i<size; i++) m_waveData[i] = data[i];
+ return TRUE;
}
-bool wxWave::Free()
+bool wxWave::Play(bool async, bool looped) const
{
- // TODO
+ if (!IsOk())
+ return FALSE;
+// TODO:
+/*
+ return ( ::PlaySound((LPCTSTR)m_waveData, NULL, SND_MEMORY |
+ SND_NODEFAULT | (async ? SND_ASYNC : SND_SYNC) | (looped ? (SND_LOOP | SND_ASYNC) : 0)) != 0 );
+*/
return FALSE;
}
+bool wxWave::Free()
+{
+ if (m_waveData)
+ {
+// HGLOBAL waveData = ::GlobalHandle(m_waveData);
+
+// TODO:
+/*
+ if (waveData)
+ {
+ if (m_isResource)
+ ::FreeResource(waveData);
+ else
+ {
+ ::GlobalUnlock(waveData);
+ ::GlobalFree(waveData);
+ }
+
+ m_waveData = NULL;
+ m_waveLength = 0;
+ return TRUE;
+ }
+*/
+ }
+ return FALSE;
+}