00001 #ifndef __INSTANTIO_SAMPLE_H
00002 #define __INSTANTIO_SAMPLE_H
00003
00004 #ifdef _MSC_VER
00005 # pragma once
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "InstantIODef.h"
00027 #include "TypeName.h"
00028
00029
00030 namespace InstantIO
00031 {
00032
00033
00039 class INSTANTIO_DLLMAPPING Sample
00040 {
00041 public:
00042
00044 Sample();
00045
00047 ~Sample();
00048
00056 void setParameters(unsigned int samplerate, unsigned char bits, unsigned char channels, unsigned long numFrames);
00057
00062 inline unsigned int getSamplerate() const { return samplerate_; }
00063
00068 inline unsigned char getBits() const { return bits_; }
00069
00074 inline unsigned char getChannels() const { return channels_; }
00075
00080 inline unsigned long getNumFrames() const { return numFrames_; }
00081
00086 inline unsigned int getBytesPerFrame() const
00087 { return ((bits_ + 7) >> 3) * channels_; }
00088
00094 inline const char *getBuffer() const { return buffer_; }
00095
00101 inline char *getBuffer() { return buffer_; }
00102
00108 inline unsigned long getBufferSize() const
00109 { return getBytesPerFrame() * numFrames_; }
00110
00111 private:
00112
00114 Sample(const Sample &);
00115
00117 const Sample &operator=(const Sample &);
00118
00120 char *buffer_;
00121
00123 unsigned long bufferSize_;
00124
00126 unsigned int samplerate_;
00127
00129 unsigned char bits_;
00130
00132 unsigned char channels_;
00133
00135 unsigned long numFrames_;
00136 };
00137
00138
00139 template <class T> class SmartPtr;
00140
00141
00143 typedef SmartPtr<Sample> SamplePtr;
00144
00145
00152 template <>
00153 class INSTANTIO_DLLMAPPING TypeName<SamplePtr>
00154 {
00155 public:
00156
00161 static const char *getName();
00162
00163 private:
00164
00166 TypeName();
00167
00169 TypeName(const TypeName &);
00170
00172 const TypeName &operator=(const TypeName &);
00173 };
00174
00175
00176 }
00177
00178
00179 #endif // __INSTANTIO_SAMPLE_H