675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include "ardour/meter.h"
#include <algorithm>
#include <cmath>
+
+#include "ardour/audio_buffer.h"
#include "ardour/buffer_set.h"
-#include "ardour/peak.h"
#include "ardour/dB.h"
-#include "ardour/session.h"
+#include "ardour/meter.h"
#include "ardour/midi_buffer.h"
-#include "ardour/audio_buffer.h"
+#include "ardour/rc_configuration.h"
#include "ardour/runtime_functions.h"
using namespace std;
* be set to 0.
*/
void
-PeakMeter::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes, bool)
+PeakMeter::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool)
{
if (!_active && !_pending_active) {
return;
}
- const uint32_t n_audio = min(_configured_input.n_audio(), bufs.count().n_audio());
- const uint32_t n_midi = min(_configured_input.n_midi(), bufs.count().n_midi());
+ // cerr << "meter " << name() << " runs with " << bufs.available() << " inputs\n";
+
+ const uint32_t n_audio = min (current_meters.n_audio(), bufs.count().n_audio());
+ const uint32_t n_midi = min (current_meters.n_midi(), bufs.count().n_midi());
uint32_t n = 0;
for (uint32_t i = 0; i < n_midi; ++i, ++n) {
float val = 0.0f;
for (MidiBuffer::iterator e = bufs.get_midi(i).begin(); e != bufs.get_midi(i).end(); ++e) {
- const Evoral::MIDIEvent<nframes_t> ev(*e, false);
+ const Evoral::MIDIEvent<framepos_t> ev(*e, false);
if (ev.is_note_on()) {
const float this_vel = log(ev.buffer()[2] / 127.0 * (M_E*M_E-M_E) + M_E) - 1.0;
if (this_vel > val) {
}
}
}
- _peak_power[n] = val;
+ _peak_power[n] = max (val, _peak_power[n]);
}
// Meter audio in to the rest of the peaks
current_meters = in;
- reset_max_channels (in);
+ reset_max_channels (in);
return Processor::configure_io (in, out);
}
PeakMeter::reflect_inputs (const ChanCount& in)
{
current_meters = in;
+
+ ConfigurationChanged (in, in); /* EMIT SIGNAL */
}
void
PeakMeter::reset_max_channels (const ChanCount& chn)
{
- uint32_t limit = chn.n_total();
+ uint32_t const limit = chn.n_total();
while (_peak_power.size() > limit) {
_peak_power.pop_back();