2017-08-19 20:46:57 +00:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "../Utilities/stb_vorbis.h"
|
|
|
|
#include "../Utilities/blip_buf.h"
|
2017-09-30 18:07:07 +00:00
|
|
|
#include "VirtualFile.h"
|
2017-08-19 20:46:57 +00:00
|
|
|
|
|
|
|
class OggReader
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
const int SamplesToRead = 100;
|
|
|
|
|
|
|
|
stb_vorbis* _vorbis;
|
|
|
|
int16_t* _oggBuffer;
|
|
|
|
int16_t* _outputBuffer;
|
|
|
|
|
|
|
|
bool _loop;
|
|
|
|
bool _done;
|
|
|
|
|
|
|
|
blip_t* _blipLeft;
|
|
|
|
blip_t* _blipRight;
|
|
|
|
|
|
|
|
int _sampleRate;
|
|
|
|
int _oggSampleRate;
|
|
|
|
|
|
|
|
vector<uint8_t> _fileData;
|
|
|
|
|
|
|
|
bool LoadSamples();
|
|
|
|
|
|
|
|
public:
|
|
|
|
OggReader();
|
|
|
|
~OggReader();
|
|
|
|
|
2017-08-20 23:03:16 +00:00
|
|
|
bool Init(string filename, bool loop, uint32_t sampleRate, uint32_t startOffset = 0);
|
2017-08-19 20:46:57 +00:00
|
|
|
bool IsPlaybackOver();
|
|
|
|
void SetSampleRate(int sampleRate);
|
|
|
|
void SetLoopFlag(bool loop);
|
2018-07-14 02:19:26 +00:00
|
|
|
void ApplySamples(int16_t* buffer, size_t sampleCount, uint8_t volume, double masterVolume);
|
2017-08-20 23:03:16 +00:00
|
|
|
uint32_t GetOffset();
|
2017-08-19 20:46:57 +00:00
|
|
|
};
|