61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
#ifndef __SAMPLEWAV__
|
|
#define __SAMPLEWAV__
|
|
|
|
|
|
#include "audio/sample_interface.h"
|
|
#include "time/ntime.h"
|
|
|
|
|
|
namespace GS {
|
|
|
|
/*!
|
|
@short WAV sample.
|
|
@author Emmanuel Julien (ejulien@owloh.com)
|
|
*/
|
|
class SampleWav : public ISample
|
|
{
|
|
friend struct SampleWavFactory;
|
|
|
|
protected:
|
|
|
|
SampleFormat format;
|
|
|
|
uint sample_count;
|
|
Array <char> pcm_data;
|
|
|
|
public:
|
|
|
|
/// Return the sample count.
|
|
uint GetSampleCount() const { return sample_count; }
|
|
/// Return the PCM data.
|
|
void *GetPCMData() const { return pcm_data.c_ptr(); }
|
|
/// Return the PCM data size.
|
|
uint GetPCMDataSize() const;
|
|
|
|
/// Set PCM data, the data array content will be transfered to the sample.
|
|
void Set(Array <char> &data, uint sample_count, const SampleFormat &);
|
|
/// Allocate PCM samples for a given format.
|
|
char *AllocAs(uint sample_count, const SampleFormat &);
|
|
|
|
/// Return the sample format identifier (eg. "WAV").
|
|
virtual const char *GetFormat() { return "WAV"; }
|
|
|
|
/// Get the sample format.
|
|
virtual bool GetSampleFormat(SampleFormat &) const;
|
|
/// Get sample duration.
|
|
virtual Time GetDuration() const;
|
|
|
|
SampleWav() : sample_count(0) {}
|
|
};
|
|
|
|
} // GS
|
|
|
|
|
|
#endif // __SAMPLEWAV__
|