2019-02-02 11:30:40 +08:00
|
|
|
#ifndef WAVE_BUFFER_H
|
|
|
|
#define WAVE_BUFFER_H
|
2017-12-06 21:43:47 +08:00
|
|
|
|
2018-08-10 17:17:37 +08:00
|
|
|
#define WAVE_BUFFER_LEN 1024
|
2019-01-17 14:39:18 +08:00
|
|
|
#define WAVE_READ_CACHE_LEN 8
|
2017-12-06 21:43:47 +08:00
|
|
|
#define BUFFER_EMPTY -1111
|
|
|
|
#define BUFFER_FULL -2222;
|
|
|
|
class c_wave_buffer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
c_wave_buffer();
|
|
|
|
int write_wave_data(short data);
|
2019-01-17 14:39:18 +08:00
|
|
|
int read_wave_data_by_frame(short &max, short &min, short frame_len, unsigned int sequence, short offset);
|
2017-12-06 21:43:47 +08:00
|
|
|
void reset();
|
|
|
|
void clear_data();
|
|
|
|
short get_cnt();
|
|
|
|
private:
|
|
|
|
int read_data();
|
|
|
|
short m_wave_buf[WAVE_BUFFER_LEN];
|
|
|
|
short m_head;
|
|
|
|
short m_tail;
|
|
|
|
|
|
|
|
int m_min_old;
|
|
|
|
int m_max_old;
|
|
|
|
int m_min_older;
|
|
|
|
int m_max_older;
|
|
|
|
int m_last_data;
|
|
|
|
|
2019-01-17 14:39:18 +08:00
|
|
|
short m_read_cache_min[WAVE_READ_CACHE_LEN];
|
|
|
|
short m_read_cache_mid[WAVE_READ_CACHE_LEN];
|
|
|
|
short m_read_cache_max[WAVE_READ_CACHE_LEN];
|
|
|
|
short m_read_cache_sum;
|
|
|
|
unsigned int m_refresh_sequence;
|
2017-12-06 21:43:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|