2 * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "ardour_ui.h"
20 #include "dsp_load_indicator.h"
22 #include "ardour/audioengine.h"
28 DspLoadIndicator::DspLoadIndicator ()
29 : ArdourGauge ("00.0%")
32 , _xrun_while_recording (false)
37 DspLoadIndicator::set_xrun_count (const unsigned int xruns)
39 if (xruns == _xrun_count) {
47 DspLoadIndicator::set_dsp_load (const double load)
49 if (load == _dsp_load) {
55 snprintf (buf, sizeof (buf), "DSP %.1f%%", _dsp_load);
56 update (std::string (buf));
60 DspLoadIndicator::level () const {
61 return (100.0-_dsp_load) / 100.f;
65 DspLoadIndicator::alert () const
69 //xrun while recording
70 ret |= _xrun_while_recording;
73 ret |= !ARDOUR::AudioEngine::instance()->running();
79 DspLoadIndicator::indicator () const
82 return ArdourGauge::Level_CRIT;
83 } else if (_dsp_load > 80) {
84 return ArdourGauge::Level_WARN;
86 return ArdourGauge::Level_OK;
91 DspLoadIndicator::tooltip_text ()
96 if (_xrun_count == UINT_MAX) {
97 snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: ?"), _dsp_load);
98 } else if (_xrun_count > 9999) {
99 snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: >10k"), _dsp_load);
101 snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: %u"), _dsp_load, _xrun_count);
108 DspLoadIndicator::on_button_release_event (GdkEventButton *ev)
110 ARDOUR::Session* s = ARDOUR_UI::instance ()->the_session ();
112 s->reset_xrun_count ();
113 _xrun_while_recording = false;