Make sure that every highest peak value is drawn

As process is usually called more often than
update_cb, we should store the highest peak
value until it is consumed by update_cb.
This commit is contained in:
Roy Vegard Ovesen 2013-04-27 16:54:39 +02:00
parent e6e101fc67
commit ec8bfcba63
2 changed files with 9 additions and 2 deletions

View File

@ -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;
} }
} }
} }

View File

@ -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,6 +215,7 @@ 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;
if (dB > control_value[i])
control_value[i] = dB; control_value[i] = dB;
} }
} }