///////////////////////////////////////////////////////////////////////////// // Name: wave.cpp // Purpose: wxWave // Author: Marcel Rasche // Modified by: // Created: 25/10/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ #pragma implementation "wave.h" #endif #include "wx/setup.h" #if wxUSE_WAVE // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #if defined(__BORLANDC__) #pragma hdrstop #endif #include #include #include #include #include #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "wx/file.h" #include "wx/wave.h" //----------------------------------------------------------------- // wxWave //----------------------------------------------------------------- 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(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(); } bool wxWave::Create(const wxString& fileName, bool isResource) { Free(); if (isResource) { // todo return (m_waveData ? TRUE : FALSE); } else { m_isResource = FALSE; wxFile fileWave; if (!fileWave.Open(fileName, wxFile::read)) { return FALSE; } m_waveLength = (int) fileWave.Length(); m_waveData = new wxByte[m_waveLength]; if (!m_waveData) { return FALSE; } fileWave.Read(m_waveData, m_waveLength); return TRUE; } } bool wxWave::Create(int size, const wxByte* data) { Free(); m_isResource = FALSE; m_waveLength=size; m_waveData = new wxByte[size]; if (!m_waveData) { return FALSE; } for (int i=0; i 65536) return FALSE; if ( ioctl(dev,SNDCTL_DSP_SAMPLESIZE,&iDataBits) < 0 ) return FALSE; if ( ioctl(dev,SNDCTL_DSP_STEREO,&iChannel) < 0 ) return FALSE; if ( ioctl(dev,SNDCTL_DSP_SPEED,&ulSamplingRate) < 0 ) return FALSE; return TRUE; } #endif