00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef AUDIO_MODULE_H
00029 #define AUDIO_MODULE_H
00030
00031 #include "FsfNode.h"
00032 #include "FsfCell.h"
00033
00034 #include "FsfTypeNode.h"
00035
00036
00037 #include "FsfCharBuffer.h"
00038
00039 #include <iostream>
00040
00041
00042 namespace audio{
00043
00046
00049
00051 void registerFactories();
00052
00054
00055 const unsigned int FORMAT_FLOAT64=0;
00056 const unsigned int FORMAT_FLOAT32=1;
00057 const unsigned int FORMAT_SINT32=2;
00058 const unsigned int FORMAT_SINT24=3;
00059 const unsigned int FORMAT_SINT16=4;
00060 const unsigned int FORMAT_SINT8=5;
00062
00063 const int SAMPLE_SIZE[6] = { 8,4,4,4,2,1 };
00064
00067 class CAudioBuffer : public fsf::CCharBuffer {
00068 private:
00069 unsigned int m_nNbChannels;
00070 unsigned int m_nFormat;
00071 unsigned int m_nNbFrames;
00072
00073 public:
00075
00076
00077 CAudioBuffer()
00078 : CCharBuffer(), m_nNbFrames(0), m_nNbChannels(0), m_nFormat(FORMAT_FLOAT64) {}
00080 CAudioBuffer(fsf::CNode *pParent, fsf::Time tTime=0)
00081 : CCharBuffer(pParent,tTime), m_nNbFrames(0), m_nNbChannels(0), m_nFormat(FORMAT_FLOAT64) {}
00083 CAudioBuffer(const std::string &strName, fsf::CNode *pParent=NULL, fsf::Time tTime=0)
00084 : CCharBuffer(strName,pParent,tTime), m_nNbFrames(0), m_nNbChannels(0), m_nFormat(FORMAT_FLOAT64) {}
00085
00087 CAudioBuffer(unsigned int nNbChannels, unsigned int nFormat, unsigned int nNbFrames, long nBufferSize=-1, fsf::CNode *pParent=NULL, fsf::Time tTime=0);
00089 CAudioBuffer(const std::string &strName, unsigned int nNbChannels, unsigned int nFormat, unsigned int nNbFrames, long nBufferSize=-1, fsf::CNode *pParent=NULL, fsf::Time tTime=0);
00090
00092 CAudioBuffer(const CAudioBuffer& rhs);
00094 virtual CNode *clone() const { return new CAudioBuffer(*this); }
00096
00097
00099
00100
00101 CAudioBuffer& operator=(const CAudioBuffer& rhs);
00103
00105
00106
00107 virtual void getTypeID(std::string &str) const { str.assign("AUDIO_BUFFER"); }
00109 unsigned int getNbChannels() const { return m_nNbChannels; }
00111 unsigned int getFormat() const { return m_nFormat; }
00113 unsigned int getNbFrames() const { return m_nNbFrames; }
00115 };
00116
00117
00120 class CAudioTrack : public CAudioBuffer {
00121 private:
00122
00123 long m_nRecordIndex;
00124 long m_nPlayIndex;
00125
00126 public:
00128
00130 CAudioTrack()
00131 : CAudioBuffer(), m_nRecordIndex(0), m_nPlayIndex(0) {}
00133 CAudioTrack(fsf::CNode *pParent, fsf::Time tTime=0)
00134 : CAudioBuffer(pParent,tTime), m_nRecordIndex(0), m_nPlayIndex(0) {}
00136 CAudioTrack(const std::string &strName, fsf::CNode *pParent=NULL, fsf::Time tTime=0)
00137 : CAudioBuffer(strName,pParent,tTime), m_nRecordIndex(0), m_nPlayIndex(0) {}
00138
00140 CAudioTrack(unsigned int nNbChannels, unsigned int nFormat, unsigned int nNbFrames, fsf::CNode *pParent=NULL, fsf::Time tTime=0);
00142 CAudioTrack(const std::string &strName, unsigned int nNbChannels, unsigned int nFormat, unsigned int nNbFrames, fsf::CNode *pParent=NULL, fsf::Time tTime=0);
00143
00145 CAudioTrack(const CAudioTrack& rhs);
00146
00148 virtual CNode *clone() const { return new CAudioTrack(*this); }
00150
00151
00153
00154
00155 CAudioTrack& operator=(const CAudioTrack& rhs);
00156
00158 void recordBuffer(CAudioBuffer *pBuffer);
00160 CAudioBuffer* playBuffer(unsigned int nBufferFrames);
00162
00164
00165
00166 virtual void getTypeID(std::string &str) const { str.assign("AUDIO_TRACK"); }
00167
00169 long getRecordIndex() const { return m_nRecordIndex; }
00171 long getPlayIndex() const { return m_nPlayIndex; }
00173
00174 };
00175
00178 class CRecord : public fsf::CCell {
00179 public:
00181 CRecord();
00183 virtual void getTypeID(std::string &str) const { str.assign("AUDIO_RECORD"); }
00185 virtual void process(fsf::CPassiveHandle *pPassiveHandle, fsf::CActiveHandle *pActiveHandle, fsf::CActivePulse *pActivePulse);
00186 };
00187
00188
00191 class CPlay : public fsf::CCell {
00192 public:
00194 CPlay();
00196 virtual void getTypeID(std::string &str) const { str.assign("AUDIO_PLAY"); }
00198 virtual void process(fsf::CPassiveHandle *pPassiveHandle, fsf::CActiveHandle *pActiveHandle, fsf::CActivePulse *pActivePulse);
00199 };
00200
00201 }
00202
00203 #endif // AUDIO_MODULE_H