As process is usually called more often than update_cb, we should store the highest peak value until it is consumed by update_cb.tags/non-daw-v1.2.0
@@ -183,6 +183,7 @@ Meter_Indicator_Module::update_cb ( void ) | |||||
for ( int i = 0; i < dpm_pack->children(); ++i ) | for ( int i = 0; i < dpm_pack->children(); ++i ) | ||||
{ | { | ||||
((DPM*)dpm_pack->child( i ))->value( control_value[i] ); | ((DPM*)dpm_pack->child( i ))->value( control_value[i] ); | ||||
control_value[i] = -70.0f; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -275,7 +276,9 @@ Meter_Indicator_Module::process ( nframes_t ) | |||||
for ( int i = 0; i < p->hints.dimensions; ++i ) | for ( int i = 0; i < p->hints.dimensions; ++i ) | ||||
{ | { | ||||
control_value[i] = ((float*)control_input[0].buffer())[i]; | |||||
float dB = ((float*)control_input[0].buffer())[i]; | |||||
if ( dB > control_value[i]) | |||||
control_value[i] = dB; | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -89,7 +89,10 @@ Meter_Module::update_cb ( void ) | |||||
Fl::repeat_timeout( METER_UPDATE_FREQ, update_cb, this ); | Fl::repeat_timeout( METER_UPDATE_FREQ, update_cb, this ); | ||||
for ( int i = dpm_pack->children(); i--; ) | for ( int i = dpm_pack->children(); i--; ) | ||||
{ | |||||
((DPM*)dpm_pack->child( i ))->value( control_value[i] ); | ((DPM*)dpm_pack->child( i ))->value( control_value[i] ); | ||||
control_value[i] = -70.0f; | |||||
} | |||||
} | } | ||||
bool | bool | ||||
@@ -212,7 +215,8 @@ Meter_Module::process ( nframes_t nframes ) | |||||
float dB = 20 * log10( get_peak_sample( (float*)audio_input[i].buffer(), nframes ) ); | float dB = 20 * log10( get_peak_sample( (float*)audio_input[i].buffer(), nframes ) ); | ||||
((float*)control_output[0].buffer())[i] = dB; | ((float*)control_output[0].buffer())[i] = dB; | ||||
control_value[i] = dB; | |||||
if (dB > control_value[i]) | |||||
control_value[i] = dB; | |||||
} | } | ||||
} | } | ||||
} | } |