refactor wave

This commit is contained in:
idea4good 2019-01-16 13:24:09 +08:00
parent aebfd5449c
commit 6213bdb1e8
2 changed files with 11 additions and 13 deletions

View File

@ -57,8 +57,7 @@ int c_wave_buffer::read_wave_data_by_frame(short &max, short &min, short len, un
ASSERT(FALSE); ASSERT(FALSE);
} }
if(((m_refresh_sqence & 0xff) == (seq & 0xff)) && if(((m_refresh_sqence & 0xff) == (seq & 0xff)))
((m_refresh_sqence & 0xffff0000) != (seq & 0xffff0000)))
{ {
max = m_fb_max[offset]; max = m_fb_max[offset];
min = m_fb_min[offset]; min = m_fb_min[offset];

View File

@ -16,8 +16,8 @@
}while(0) }while(0)
#define WAVE_CURSOR_WIDTH 8 #define WAVE_CURSOR_WIDTH 8
#define DATA_THRESHOLD 4
#define WAVE_LINE_WIDTH 1 #define WAVE_LINE_WIDTH 1
#define WAVE_MARGIN 5
c_wave_ctrl::c_wave_ctrl() c_wave_ctrl::c_wave_ctrl()
{ {
@ -43,10 +43,10 @@ void c_wave_ctrl::on_init_children()
c_rect rect; c_rect rect;
get_screen_rect(rect); get_screen_rect(rect);
m_wave_left = rect.m_left + 22; m_wave_left = rect.m_left + WAVE_MARGIN;
m_wave_right = rect.m_right; m_wave_right = rect.m_right - WAVE_MARGIN;
m_wave_top = rect.m_top + 2; m_wave_top = rect.m_top + WAVE_MARGIN;
m_wave_bottom = rect.m_bottom - 4; m_wave_bottom = rect.m_bottom - WAVE_MARGIN;
m_wave_cursor = m_wave_left; m_wave_cursor = m_wave_left;
m_bg_fb = (unsigned int*)calloc(rect.Width() * rect.Height(), 4); m_bg_fb = (unsigned int*)calloc(rect.Width() * rect.Height(), 4);
@ -112,8 +112,7 @@ bool c_wave_ctrl::is_data_enough()
ASSERT(FALSE); ASSERT(FALSE);
return false; return false;
} }
return ((m_frame_len_map[m_frame_len_map_index] * m_wave_speed - m_wave->get_cnt()) < return (m_wave->get_cnt() - m_frame_len_map[m_frame_len_map_index] * m_wave_speed);
DATA_THRESHOLD)?true:false;
} }
void c_wave_ctrl::refresh_wave(unsigned char frame) void c_wave_ctrl::refresh_wave(unsigned char frame)
@ -124,14 +123,14 @@ void c_wave_ctrl::refresh_wave(unsigned char frame)
return; return;
} }
short max, min, mid, speed; short max, min, mid, offset;
speed = m_wave_speed; offset = m_wave_speed;
while(--speed >= 0) while(--offset >= 0)
{ {
//get wave value //get wave value
mid = m_wave->read_wave_data_by_frame(max, min, mid = m_wave->read_wave_data_by_frame(max, min,
m_frame_len_map[m_frame_len_map_index++], m_frame_len_map[m_frame_len_map_index++],
(frame | (speed << 8) | (((unsigned long)this & 0xffff) << 16))); (frame | (offset << 8)));
m_frame_len_map_index %= sizeof(m_frame_len_map); m_frame_len_map_index %= sizeof(m_frame_len_map);
//gain //gain
switch(m_gain) switch(m_gain)