CUGL 1.3
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
CUOGGDecoder.h
1 //
2 // CUOGGDecoder.h
3 // Cornell University Game Library (CUGL)
4 //
5 // This is class for decoding OGG Vorbis files. It only supports Vorbis
6 // encodings. It does not support Flac data encoded in an Ogg file container.
7 //
8 // Ogg Vorbis supports up to 8 channels (7.1 stereo), though SDL is limited to
9 // 6 channels (5.1 stereo). The channel layout for Ogg data is nonstandard
10 // (e.g. channels > 3 are not stereo compatible), so this decoder standardizes
11 // the channel layout to agree with FLAC and other data encodings.
12 //
13 // This code is built atop the 1.3.2 release of the Ogg reference library
14 // making it compatible with our license.
15 //
16 // CUGL MIT License:
17 //
18 // This software is provided 'as-is', without any express or implied
19 // warranty. In no event will the authors be held liable for any damages
20 // arising from the use of this software.
21 //
22 // Permission is granted to anyone to use this software for any purpose,
23 // including commercial applications, and to alter it and redistribute it
24 // freely, subject to the following restrictions:
25 //
26 // 1. The origin of this software must not be misrepresented; you must not
27 // claim that you wrote the original software. If you use this software
28 // in a product, an acknowledgment in the product documentation would be
29 // appreciated but is not required.
30 //
31 // 2. Altered source versions must be plainly marked as such, and must not
32 // be misrepresented as being the original software.
33 //
34 // 3. This notice may not be removed or altered from any source distribution.
35 //
36 // Authors: Sam Lantinga, Walker White
37 // Version: 6/29/17
38 //
39 #ifndef __CU_OGG_DECODER_H__
40 #define __CU_OGG_DECODER_H__
41 #include "CUAudioDecoder.h"
42 #include <SDL/SDL.h>
43 #include <codecs/vorbis/vorbisfile.h>
44 
45 namespace cugl {
46  namespace audio {
66 class OGGDecoder : public AudioDecoder {
67 protected:
69  SDL_RWops* _source;
71  OggVorbis_File _oggfile;
74 
75 public:
76 #pragma mark Constructors
77 
83  OGGDecoder();
84 
88  ~OGGDecoder();
89 
99  bool init(const char* file) override {
100  return init(std::string(file));
101  }
102 
112  bool init(const std::string& file) override;
113 
120  void dispose() override;
121 
122 
123 #pragma mark Static Constructors
124 
134  static std::shared_ptr<AudioDecoder> alloc(const char* file) {
135  return alloc(std::string(file));
136  }
137 
148  static std::shared_ptr<AudioDecoder> alloc(const std::string& file);
149 
150 
151 #pragma mark Decoding
152 
165  Sint32 pagein(float* buffer) override;
166 
176  void setPage(Uint64 page) override;
177 
178 };
179  }
180 }
181 
182 #endif /* __CU_OGG_DECODER_H__ */
cugl::audio::OGGDecoder::pagein
Sint32 pagein(float *buffer) override
cugl::audio::OGGDecoder::init
bool init(const char *file) override
Definition: CUOGGDecoder.h:99
cugl::audio::OGGDecoder::~OGGDecoder
~OGGDecoder()
cugl::audio::OGGDecoder::dispose
void dispose() override
cugl::audio::OGGDecoder::OGGDecoder
OGGDecoder()
cugl::audio::OGGDecoder
Definition: CUOGGDecoder.h:66
cugl::audio::AudioDecoder
Definition: CUAudioDecoder.h:55
cugl::audio::OGGDecoder::_bitstream
int _bitstream
Definition: CUOGGDecoder.h:73
cugl::audio::OGGDecoder::setPage
void setPage(Uint64 page) override
cugl::audio::OGGDecoder::alloc
static std::shared_ptr< AudioDecoder > alloc(const char *file)
Definition: CUOGGDecoder.h:134
cugl::audio::OGGDecoder::_source
SDL_RWops * _source
Definition: CUOGGDecoder.h:69
cugl::audio::OGGDecoder::_oggfile
OggVorbis_File _oggfile
Definition: CUOGGDecoder.h:71