Otclient  14/8/2020
soundfile.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef SOUNDFILE_H
24 #define SOUNDFILE_H
25 
26 #include "declarations.h"
28 
30 {
31 public:
32  SoundFile(const FileStreamPtr& fileStream);
33  virtual ~SoundFile() { }
34  static SoundFilePtr loadSoundFile(const std::string& filename);
35 
36  virtual int read(void *buffer, int bufferSize) { return -1; }
37  virtual void reset() { }
38  bool eof() { return m_file->eof(); }
39 
40  ALenum getSampleFormat();
41 
42  int getChannels() { return m_channels; }
43  int getRate() { return m_rate; }
44  int getBps() { return m_bps; }
45  int getSize() { return m_size; }
46  std::string getName() { return m_file ? m_file->name() : std::string(); }
47 
48 protected:
51  int m_rate;
52  int m_bps;
53  int m_size;
54 };
55 
56 #endif
SoundFile::getChannels
int getChannels()
Definition: soundfile.h:42
SoundFile::m_channels
int m_channels
Definition: soundfile.h:50
SoundFile::m_bps
int m_bps
Definition: soundfile.h:52
SoundFile::m_file
FileStreamPtr m_file
Definition: soundfile.h:49
SoundFile::eof
bool eof()
Definition: soundfile.h:38
SoundFile::getName
std::string getName()
Definition: soundfile.h:46
SoundFile::m_rate
int m_rate
Definition: soundfile.h:51
SoundFile::getBps
int getBps()
Definition: soundfile.h:44
SoundFile::getSize
int getSize()
Definition: soundfile.h:45
SoundFile::getSampleFormat
ALenum getSampleFormat()
Definition: soundfile.cpp:57
SoundFile::m_size
int m_size
Definition: soundfile.h:53
SoundFile::getRate
int getRate()
Definition: soundfile.h:43
SoundFile::reset
virtual void reset()
Definition: soundfile.h:37
SoundFile::~SoundFile
virtual ~SoundFile()
Definition: soundfile.h:33
FileStream::eof
bool eof()
Definition: filestream.cpp:175
declarations.h
FileStream::name
std::string name()
Definition: filestream.h:51
filestream.h
SoundFile::SoundFile
SoundFile(const FileStreamPtr &fileStream)
Definition: soundfile.cpp:27
stdext::shared_object_ptr< FileStream >
SoundFile::loadSoundFile
static SoundFilePtr loadSoundFile(const std::string &filename)
Definition: soundfile.cpp:32
SoundFile::read
virtual int read(void *buffer, int bufferSize)
Definition: soundfile.h:36
SoundFile
Definition: soundfile.h:29
stdext::shared_object
Definition: shared_object.h:41