#include <MP3FileSource.h>
Inherits Marsyas::AbsSoundFileSource.
Public Member Functions | |
| void | getHeader (std::string filename) |
| void | myProcess (realvec &in, realvec &out) |
Private Member Functions | |
| void | closeFile () |
| void | fillStream (long offset=0) |
| mrs_natural | getLinear16 (realvec &slice) |
| void | myUpdate (MarControlPtr sender) |
This class reads an mp3 file using the mad mp3 decoder library. Some of this code was inspired from Bertrand Petit's madlld example. The code to resize the buffers was borrowed from Marsyas AudioSource.
Definition at line 54 of file MP3FileSource.h.
| void closeFile | ( | ) | [private] |
Function: closeFile()
Description: Close the file if its open, release memory, and release mad structs.
Definition at line 842 of file MP3FileSource.cpp.
Referenced by MP3FileSource::getHeader().
| void fillStream | ( | long | offset = 0 |
) | [private] |
Function: fillstream()
Description: Fill the mad stream with a chunk of audio. This function was inspired from IzSounds maddecoder implementation.
Definition at line 777 of file MP3FileSource.cpp.
Referenced by MP3FileSource::getHeader(), MP3FileSource::getLinear16(), and MP3FileSource::myProcess().
| void getHeader | ( | std::string | filename | ) | [virtual] |
Function: getHeader Description: Opens the MP3 file and collects all the necessary information to update the MarSystem.
Implements AbsSoundFileSource.
Definition at line 263 of file MP3FileSource.cpp.
References MP3FileSource::closeFile(), MP3FileSource::fillStream(), and realvec::setval().
| mrs_natural getLinear16 | ( | realvec & | slice | ) | [private] |
Function: getLinear16
Description: This function does all the work. It is called by process, and its job is to fill an output vector of the correct size to push through the system. The MAD decoder can only retrieve buffer sizes of 1152, so therefore we have to balance and maintain a reservoir. Thus, we only get more samples from MAD when the reservoir is below a threshold. (As in AudioSource, etc).
Definition at line 525 of file MP3FileSource.cpp.
References MP3FileSource::fillStream().
Referenced by MP3FileSource::myProcess().
Function: process Description: Fills an output vector with samples. In this case, getLinear16 does all the work.
Implements AbsSoundFileSource.
Definition at line 665 of file MP3FileSource.cpp.
References MP3FileSource::fillStream(), and MP3FileSource::getLinear16().
| void myUpdate | ( | MarControlPtr | sender | ) | [private, virtual] |
Function: update
Description: Performs the usual MarSystem update jobs. Additionally, it can update the position of the index in the file if the user seeks forward or backward. Note that this is currently going to be slow as we have to refill the mad buffer each time somebody seeks in the file.
Reimplemented from MarSystem.
Definition at line 463 of file MP3FileSource.cpp.
References realvec::stretch().
1.5.6