summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-06-04 01:38:28 +0000
committerDavid Robillard <d@drobilla.net>2007-06-04 01:38:28 +0000
commit10a282777a48cc067f04d1a439c67990dbb10231 (patch)
tree2be46ab765c953fb57dbf9b12abf44a0f2ecd190 /libs
parent70fd14afe809c7ac7d3b5b382c77580d7b8f6085 (diff)
MIDI metering.
git-svn-id: svn://localhost/ardour2/trunk@1950 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/buffer_set.h2
-rw-r--r--libs/ardour/io.cc1
-rw-r--r--libs/ardour/meter.cc36
-rw-r--r--libs/ardour/midi_track.cc9
-rw-r--r--libs/ardour/route.cc10
5 files changed, 43 insertions, 15 deletions
diff --git a/libs/ardour/ardour/buffer_set.h b/libs/ardour/ardour/buffer_set.h
index 2f20453d45..2e0f604ace 100644
--- a/libs/ardour/ardour/buffer_set.h
+++ b/libs/ardour/ardour/buffer_set.h
@@ -149,7 +149,7 @@ private:
/// Available counts (number of buffers actually allocated)
ChanCount _available;
- /// Whether we (don't) 'own' the contained buffers (are a mirror of a PortSet)
+ /// Whether we (don't) 'own' the contained buffers (otherwise we mirror a PortSet)
bool _is_mirror;
};
diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc
index b08450d549..5df8532959 100644
--- a/libs/ardour/io.cc
+++ b/libs/ardour/io.cc
@@ -164,7 +164,6 @@ IO::IO (Session& s, const XMLNode& node, DataType dt)
_gain_control (X_("gaincontrol"), *this),
_gain_automation_curve (0, 0, 0) // all reset in set_state()
{
- // FIXME: hack
_meter = new PeakMeter (_session);
_panner = 0;
diff --git a/libs/ardour/meter.cc b/libs/ardour/meter.cc
index f0547e1e0c..2a7b438c52 100644
--- a/libs/ardour/meter.cc
+++ b/libs/ardour/meter.cc
@@ -23,22 +23,48 @@
#include <ardour/peak.h>
#include <ardour/dB.h>
#include <ardour/session.h>
+#include <ardour/midi_events.h>
namespace ARDOUR {
/** Get peaks from @a bufs
- * Input acceptance is lenient - the first n audio buffers from @a bufs will
+ * Input acceptance is lenient - the first n buffers from @a bufs will
* be metered, where n was set by the last call to setup(), excess meters will
* be set to 0.
*/
void
PeakMeter::run (BufferSet& bufs, nframes_t nframes, nframes_t offset)
{
- size_t meterable = std::min(bufs.count().n_audio(), _peak_power.size());
+ size_t meterable = std::min(bufs.count().n_total(), _peak_power.size());
- // Meter what we have
- for (size_t n = 0; n < meterable; ++n) {
+ size_t n = 0;
+
+ // Meter what we have (midi)
+ for ( ; n < meterable && n < bufs.count().n_midi(); ++n) {
+
+ float val = 0;
+
+ // GUI needs a better MIDI meter, not much information can be
+ // expressed through peaks alone
+ const unsigned n_events = bufs.get_midi(n).size();
+ for (size_t i=0; i < n_events; ++i) {
+ const MidiEvent& ev = bufs.get_midi(n)[i];
+ if ((ev.buffer[0] & 0xF0) == MIDI_CMD_NOTE_ON) {
+ const float normal_vel = ev.buffer[2] / 127.0;
+ if (normal_vel > val)
+ val += normal_vel;
+ } else {
+ val += 1.0 / bufs.get_midi(n).capacity();
+ }
+ }
+
+ _peak_power[n] = val;
+
+ }
+
+ // Meter what we have (audio)
+ for ( ; n < meterable && n < bufs.count().n_audio(); ++n) {
_peak_power[n] = compute_peak (bufs.get_audio(n).data(nframes, offset), nframes, _peak_power[n]);
}
@@ -67,7 +93,7 @@ PeakMeter::reset_max ()
void
PeakMeter::setup (const ChanCount& in)
{
- uint32_t limit = in.n_audio();
+ uint32_t limit = in.n_total();
while (_peak_power.size() > limit) {
_peak_power.pop_back();
diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc
index 72e703d906..7f3287a994 100644
--- a/libs/ardour/midi_track.cc
+++ b/libs/ardour/midi_track.cc
@@ -35,6 +35,7 @@
#include <ardour/panner.h>
#include <ardour/utils.h>
#include <ardour/buffer_set.h>
+#include <ardour/meter.h>
#include "i18n.h"
@@ -524,6 +525,10 @@ MidiTrack::process_output_buffers (BufferSet& bufs,
* too much until the SoC settles down. We'll do all the MIDI route work here for now,
* but the long-term goal is to have Route::process_output_buffers handle everything */
+ if (meter && (_meter_point == MeterInput || _meter_point == MeterPreFader)) {
+ _meter->run(bufs, nframes);
+ }
+
// Run all redirects
if (with_redirects) {
Glib::RWLock::ReaderLock rm (redirect_lock, Glib::TRY_LOCK);
@@ -534,6 +539,10 @@ MidiTrack::process_output_buffers (BufferSet& bufs,
}
}
+ if (meter && (_meter_point == MeterPostFader)) {
+ _meter->run(bufs, nframes);
+ }
+
// Main output stage
if (muted()) {
IO::silence(nframes, offset);
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index 9359c8f767..49870abf37 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -699,18 +699,12 @@ Route::passthru (nframes_t start_frame, nframes_t end_frame, nframes_t nframes,
collect_input (bufs, nframes, offset);
-#define meter_stream meter_first
-
if (meter_first) {
_meter->run(bufs, nframes);
- meter_stream = false;
- } else {
- meter_stream = true;
+ meter_first = false;
}
- process_output_buffers (bufs, start_frame, end_frame, nframes, offset, true, declick, meter_stream);
-
-#undef meter_stream
+ process_output_buffers (bufs, start_frame, end_frame, nframes, offset, true, declick, meter_first);
}
void