⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cbuf.h

📁 一个语音信号端点检测的程序
💻 H
字号:
/* * Circular buffer class definition * * Bruce T. Lowerre, Public domain, 1995, 1997 * * $Log: cbuf.h,v $ * Revision 1.5  1997/08/06 19:35:04  lowerre * removed sampling rate from classes * * Revision 1.4  1997/07/21 22:14:22  lowerre * added getreader and getwriter * * Revision 1.3  1997/06/04 18:50:26  lowerre * added eod check to available_read * * Revision 1.2  1997/06/04 18:14:24  lowerre * added eod boolean to read and peek * * Revision 1.1  1997/05/13 14:45:18  lowerre * Initial revision * * *//* * This header file defines the utterance and cbuf (circular buffer) classes. * The circular buffer is needed for live input signals where both the length * (wait) of starting silence and the length of the utterance is unknown. */#ifndef CBUF_H#define CBUF_H#include "general.h"			// general stuff/* * The circular buffer routines assume that only one module will be writing and * only one module will be reading from the buffer at any time. */class cbuf{    protected:        long	size;			// the size of the buffer        long	reader;			// next sample to read        long	writer;			// next sample to write        long	keeper;			// do not write beyond this point        long	eod;			// end of data, do not read beyond this point        BOOLEAN	overflow;		// input overflowed    public:        BOOLEAN	checkeodread		// will eod prevent reading the requested samples        (            long			// requested number of samples to read        );				// return True if eod prevents read of samples        long	available_read		// return number of elements available to read        (            BOOLEAN = False		// if True, then don't go past eod marker        );        long	available_readall ();	// return number of elements available to readall        long	available_write ();	// return number of empty elements available to write        long getreader ()		// for debugging        {            return (reader);        }        long getwriter ()		// for debuggin        {            return (writer);        }        void reset ()			// reset pointers        {            reader = writer = 0;            keeper = eod = -1;            overflow = False;        }        void setkeeper			// set the keeper pointer, defined in cbuf.cc        (            long = 0        );        void seteod			// set the end of data pointer, defined in cbuf.cc        (            long = -1			// default is to set to writer pointer        );        void advanceod			// advance the eod marker the specified number of samples        (            long = 0        );        void unseteod ()		// unset the eod pointer        {            eod = -1;        }        BOOLEAN overflowed () {return (overflow);}}; // end class cbufclass cbuf_short: public cbuf{    private:        short	*buffer;		// The actual buffer    public:        cbuf_short			// constructor defined in cbuf.cc        (            long			// size of buffer        );        ~cbuf_short () {delete []buffer;}// destructor        long read			// read samples        (            short*,			// where to put the samples            long,			// number of samples to read            BOOLEAN = False		// if True, don't read past eod marker        );        long peek			// same as read but does not update pointers        (            short*,			// where to put the samples            long,			// number of samples to read            BOOLEAN = False		// if True, don't read past eod marker        );        long readall			// read all data between keeper and eod, in cbuf.cc        (            short*,			// where to put the samples            long			// maximum number of samples to read (size of above)        );        long readalltofile		// write all available samples to a file        (				// return number of samples written            char*			// name of file to create         );        long write			// write to buffer, return number written, in cbuf.cc        (            short*,			// samples to write            long			// number to write        );        BOOLEAN overflowed () {return (overflow);}}; // end class cbuf_shortclass cbuf_char: public cbuf{    private:        char	*buffer;		// The actual buffer    public:        cbuf_char			// constructor defined in cbuf.cc        (            long			// size of buffer        );        ~cbuf_char () {delete []buffer;}// destructor        long read			// read samples        (            char*,			// where to put the samples            long,			// number of samples to read            BOOLEAN = False		// if True, don't read past eod marker        );        long peek			// same as read but does not update pointers        (            char*,			// where to put the samples            long,			// number of samples to read            BOOLEAN = False		// if True, don't read past eod marker        );        long readall			// read all data between keeper and eod, in cbuf.cc        (            char*,			// where to put the samples            long			// maximum number of samples to read (size of above)        );        long readalltofile		// write all available samples to a file        (				// return number of samples written            char*			// name of file to create         );        long write			// write to buffer, return number written, in cbuf.cc        (            char*,			// samples to write            long			// number to write        );}; // end class cbuf_charclass cbuf_long: public cbuf{    private:        long	*buffer;		// The actual buffer    public:        cbuf_long			// constructor defined in cbuf.cc        (            long			// size of buffer        );        ~cbuf_long () {delete []buffer;}// destructor        long read			// read samples        (            long*,			// where to put the samples            long,			// number of samples to read            BOOLEAN = False		// if True, don't read past eod marker        );        long peek			// same as read but does not update pointers        (            long*,			// where to put the samples            long,			// number of samples to read            BOOLEAN = False		// if True, don't read past eod marker        );        long readall			// read all data between keeper and eod, in cbuf.cc        (            long*,			// where to put the samples            long			// maximum number of samples to read (size of above)        );        long readalltofile		// write all available samples to a file        (				// return number of samples written            char*			// name of file to create         );        long write			// write to buffer, return number written, in cbuf.cc        (            long*,			// samples to write            long			// number to write        );}; // end class cbuf_longclass cbuf_float: public cbuf{    private:        float	*buffer;		// The actual buffer    public:        cbuf_float			// constructor defined in cbuf.cc        (            long			// size of buffer        );        ~cbuf_float () {delete []buffer;}// destructor        long read			// read samples        (            float*,			// where to put the samples            long,			// number of samples to read            BOOLEAN = False		// if True, don't read past eod marker        );        long peek			// same as read but does not update pointers        (            float*,			// where to put the samples            long,			// number of samples to read            BOOLEAN = False		// if True, don't read past eod marker        );        long readall			// read all data between keeper and eod, in cbuf.cc        (            float*,			// where to put the samples            long			// maximum number of samples to read (size of above)        );        long readalltofile		// write all available samples to a file        (				// return number of samples written            char*			// name of file to create         );        long write			// write to buffer, return number written, in cbuf.cc        (            float*,			// samples to write            long			// number to write        );}; // end class cbuf_float#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -