mirror of
https://github.com/xdsopl/robot36.git
synced 2025-12-06 07:12:07 +01:00
renamed variables for normalization, export float instead of int volume
This commit is contained in:
parent
ada2422531
commit
c42b2cba47
|
|
@ -43,7 +43,7 @@ public class Decoder {
|
|||
private final int[] savedBuffer;
|
||||
private final int[] savedWidth;
|
||||
private final int[] savedHeight;
|
||||
private final int[] volume;
|
||||
private final float[] volume;
|
||||
|
||||
private final RenderScript rs;
|
||||
private final Allocation rsDecoderAudioBuffer;
|
||||
|
|
@ -110,7 +110,7 @@ public class Decoder {
|
|||
currentMode = new int[1];
|
||||
savedWidth = new int[1];
|
||||
savedHeight = new int[1];
|
||||
volume = new int[1];
|
||||
volume = new float[1];
|
||||
savedBuffer = new int[pixelBuffer.length];
|
||||
|
||||
rs = RenderScript.create(activity.getApplicationContext());
|
||||
|
|
@ -121,7 +121,7 @@ public class Decoder {
|
|||
rsDecoderCurrentMode = Allocation.createSized(rs, Element.I32(rs), 1, Allocation.USAGE_SHARED | Allocation.USAGE_SCRIPT);
|
||||
rsDecoderSavedWidth = Allocation.createSized(rs, Element.I32(rs), 1, Allocation.USAGE_SHARED | Allocation.USAGE_SCRIPT);
|
||||
rsDecoderSavedHeight = Allocation.createSized(rs, Element.I32(rs), 1, Allocation.USAGE_SHARED | Allocation.USAGE_SCRIPT);
|
||||
rsDecoderVolume = Allocation.createSized(rs, Element.I32(rs), 1, Allocation.USAGE_SHARED | Allocation.USAGE_SCRIPT);
|
||||
rsDecoderVolume = Allocation.createSized(rs, Element.F32(rs), 1, Allocation.USAGE_SHARED | Allocation.USAGE_SCRIPT);
|
||||
rsDecoderSavedBuffer = Allocation.createSized(rs, Element.I32(rs), savedBuffer.length, Allocation.USAGE_SHARED | Allocation.USAGE_SCRIPT);
|
||||
rsDecoder = new ScriptC_decoder(rs);
|
||||
rsDecoder.bind_audio_buffer(rsDecoderAudioBuffer);
|
||||
|
|
@ -249,7 +249,7 @@ public class Decoder {
|
|||
switch_mode(currentMode[0]);
|
||||
|
||||
rsDecoderVolume.copyTo(volume);
|
||||
meter.volume = volume[0] / 1023.0f;
|
||||
meter.volume = volume[0];
|
||||
|
||||
rsDecoderSavedHeight.copyTo(savedHeight);
|
||||
if (savedHeight[0] > 0) {
|
||||
|
|
|
|||
|
|
@ -212,14 +212,14 @@ void decode(int samples) {
|
|||
*saved_height = 0;
|
||||
for (int sample = 0; sample < samples; ++sample, ++buffer_pos) {
|
||||
int amp = audio_buffer[sample];
|
||||
float avg_rms = filter(&avg_amplitude, amp * amp);
|
||||
float avg_amp = sqrt(2.0f * avg_rms);
|
||||
*volume = clamp(avg_amp / 32.0f, 0.0f, 1023.0f);
|
||||
float avg_pow = filter(&avg_power, amp * amp);
|
||||
float avg_amp = min(sqrt(2.0f * avg_pow), 32767.0f);
|
||||
*volume = avg_amp / 32767.0f;
|
||||
if (avg_amp < 16.0f)
|
||||
continue;
|
||||
float norm_amp = amp / avg_amp;
|
||||
float norm_amp = (127 * amp) / avg_amp;
|
||||
|
||||
spectrum_analyzer(127.0f * norm_amp);
|
||||
spectrum_analyzer(norm_amp);
|
||||
|
||||
complex_t cnt_baseband = convert(&cnt_ddc, norm_amp);
|
||||
complex_t dat_baseband = convert(&dat_ddc, norm_amp);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,6 @@ uchar4 *saved_buffer;
|
|||
int *saved_width;
|
||||
int *saved_height;
|
||||
int *current_mode;
|
||||
int *volume;
|
||||
float *volume;
|
||||
|
||||
#endif
|
||||
|
|
@ -87,7 +87,7 @@ void initialize(float rate, int length, int iw, int ih, int sw, int sh)
|
|||
const float dat_bandwidth = 800.0f;
|
||||
const float cnt_bandwidth = 200.0f;
|
||||
|
||||
avg_amplitude = ema_cutoff(10.0f, sample_rate);
|
||||
avg_power = ema_cutoff(10.0f, sample_rate);
|
||||
leader_lowpass = ema_cutoff(100.0f, sample_rate);
|
||||
|
||||
cnt_ddc = ddc(cnt_carrier, cnt_bandwidth, sample_rate);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
#ifndef STATE_RSH
|
||||
#define STATE_RSH
|
||||
|
||||
static ema_t avg_amplitude, leader_lowpass;
|
||||
static ema_t avg_power, leader_lowpass;
|
||||
static ddc_t cnt_ddc, dat_ddc;
|
||||
static fmd_t cnt_fmd, dat_fmd;
|
||||
static int disable_analyzer;
|
||||
|
|
|
|||
Loading…
Reference in a new issue