CUGL 1.3
Cornell University Game Library
CUMP3Decoder.h
1 //
2 // CUMP3Decoder.h
3 // Cornell University Game Library (CUGL)
4 //
5 // This is class for decoding MP3 files. It is based on Jung woo-jae's
6 // MPEG/WAVE Sound library. This 1997 library has no known license (though
7 // several people have extended it with LGPL additions), but is passed around
8 // on the internet as if it were attribution-only. We are using only Jung
9 // woo-jae's classes (updated for C++11 compatibility), so we assume that this
10 // exempts us from a LGPL license. In addition, at the time of this writing,
11 // all MP3 patents have recently expired, allowing us to use this license
12 // library free.
13 //
14 // CUGL MIT License:
15 // This software is provided 'as-is', without any express or implied
16 // warranty. In no event will the authors be held liable for any damages
17 // arising from the use of this software.
18 //
19 // Permission is granted to anyone to use this software for any purpose,
20 // including commercial applications, and to alter it and redistribute it
21 // freely, subject to the following restrictions:
22 //
23 // 1. The origin of this software must not be misrepresented; you must not
24 // claim that you wrote the original software. If you use this software
25 // in a product, an acknowledgment in the product documentation would be
26 // appreciated but is not required.
27 //
28 // 2. Altered source versions must be plainly marked as such, and must not
29 // be misrepresented as being the original software.
30 //
31 // 3. This notice may not be removed or altered from any source distribution.
32 //
33 // Author: Walker White
34 // Version: 8/20/18
35 //
36 #ifndef __CU_MP3_DECODER_H__
37 #define __CU_MP3_DECODER_H__
38 #include "CUAudioDecoder.h"
39 #include <codecs/mpg/mpegsound.h>
40 
41 namespace cugl {
42  namespace audio {
58 class MP3Decoder : public AudioDecoder {
59 protected:
61  Soundinputstream _loader;
62 
64  Mpegtoraw* _decoder;
65 
67  Sint16* _chunker;
68 
70  bool _booted;
71 
72 public:
73 #pragma mark Constructors
74 
80  MP3Decoder();
81 
85  ~MP3Decoder();
86 
96  bool init(const char* file) override {
97  return init(std::string(file));
98  }
99 
109  bool init(const std::string& file) override;
110 
117  void dispose() override;
118 
119 
120 #pragma mark Static Constructors
121 
131  static std::shared_ptr<AudioDecoder> alloc(const char* file) {
132  return alloc(std::string(file));
133  }
134 
145  static std::shared_ptr<AudioDecoder> alloc(const std::string& file);
146 
147 
148 #pragma mark Decoding
149 
162  Sint32 pagein(float* buffer) override;
163 
173  void setPage(Uint64 page) override;
174 
175 };
176  }
177 }
178 
179 #endif /* __CU_MP3_DECODER_H__ */
cugl::audio::MP3Decoder::setPage
void setPage(Uint64 page) override
cugl::audio::MP3Decoder::_decoder
Mpegtoraw * _decoder
Definition: CUMP3Decoder.h:64
cugl::audio::MP3Decoder::~MP3Decoder
~MP3Decoder()
cugl::audio::MP3Decoder::alloc
static std::shared_ptr< AudioDecoder > alloc(const char *file)
Definition: CUMP3Decoder.h:131
cugl::audio::AudioDecoder
Definition: CUAudioDecoder.h:55
cugl::audio::MP3Decoder::_loader
Soundinputstream _loader
Definition: CUMP3Decoder.h:61
cugl::audio::MP3Decoder
Definition: CUMP3Decoder.h:58
cugl::audio::MP3Decoder::_chunker
Sint16 * _chunker
Definition: CUMP3Decoder.h:67
cugl::audio::MP3Decoder::pagein
Sint32 pagein(float *buffer) override
cugl::audio::MP3Decoder::_booted
bool _booted
Definition: CUMP3Decoder.h:70
cugl::audio::MP3Decoder::init
bool init(const char *file) override
Definition: CUMP3Decoder.h:96
cugl::audio::MP3Decoder::dispose
void dispose() override
cugl::audio::MP3Decoder::MP3Decoder
MP3Decoder()