Commit ab6bad0a authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: vidtv: fix the tone generator logic

The tone generator logic were repeating the song after the
first silent. There's also a wrong logic at the note
offset calculus, which may create some noise.

Fix it.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent af66e03e
...@@ -253,18 +253,12 @@ static u16 vidtv_s302m_get_sample(struct vidtv_encoder *e) ...@@ -253,18 +253,12 @@ static u16 vidtv_s302m_get_sample(struct vidtv_encoder *e)
ctx->last_duration--; ctx->last_duration--;
} }
/* Handle silent */ /* Handle pause notes */
if (!ctx->last_tone) { if (!ctx->last_tone)
e->src_buf_offset = 0;
return 0x8000; return 0x8000;
}
pos = (2 * PI * ctx->note_offset * ctx->last_tone / S302M_SAMPLING_RATE_HZ);
if (pos == 360) pos = (2 * PI * ctx->note_offset * ctx->last_tone) / S302M_SAMPLING_RATE_HZ;
ctx->note_offset = 0; ctx->note_offset++;
else
ctx->note_offset++;
return (fixp_sin32(pos % (2 * PI)) >> 16) + 0x8000; return (fixp_sin32(pos % (2 * PI)) >> 16) + 0x8000;
} }
......
...@@ -39,7 +39,7 @@ struct vidtv_s302m_ctx { ...@@ -39,7 +39,7 @@ struct vidtv_s302m_ctx {
u32 frame_index; u32 frame_index;
u32 au_count; u32 au_count;
int last_duration; int last_duration;
int note_offset; unsigned int note_offset;
enum musical_notes last_tone; enum musical_notes last_tone;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment