From 5a8af1f670709d6cd28ad5edda223d9ecbc03bc3 Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Sun, 13 Aug 2017 23:08:54 +0900 Subject: added levelmeter --- libopna/opnassg.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libopna/opnassg.c') diff --git a/libopna/opnassg.c b/libopna/opnassg.c index 86d9c9a..d92a8b8 100644 --- a/libopna/opnassg.c +++ b/libopna/opnassg.c @@ -134,6 +134,9 @@ void opna_ssg_resampler_reset(struct opna_ssg_resampler *resampler) { resampler->buf[i] = 0; } resampler->index = 0; + for (int c = 0; c < 3; c++) { + leveldata_init(&resampler->leveldata[c]); + } } void opna_ssg_writereg(struct opna_ssg *ssg, unsigned reg, unsigned val) { @@ -286,6 +289,7 @@ void opna_ssg_mix_55466( } } } + unsigned level[3] = {0}; for (int i = 0; i < samples; i++) { { int ssg_samples = ((resampler->index + 9)>>1) - ((resampler->index)>>1); @@ -305,6 +309,12 @@ void opna_ssg_mix_55466( opna_ssg_sinc_calc_func(resampler->index, resampler->buf, outbuf); for (int ch = 0; ch < 3; ch++) { if (oscillo) oscillo[ch].buf[offset+i] = outbuf[ch] >> 15; + int32_t nlevel = outbuf[ch]; + nlevel >>= 16; + nlevel *= 13000; + nlevel >>= 14; + if (nlevel < 0) nlevel = -nlevel; + if (((unsigned)nlevel) > level[ch]) level[ch] = nlevel; if (!(ssg->mask & (1<> 2; } sample >>= 16; @@ -322,5 +332,8 @@ void opna_ssg_mix_55466( buf[i*2+0] = lo; buf[i*2+1] = ro; } + for (int c = 0; c < 3; c++) { + leveldata_update(&resampler->leveldata[c], level[c]); + } } #undef BUFINDEX -- cgit v1.2.3