Display the memory usage
This commit is contained in:
parent
d1be18c0d9
commit
51b85bc17e
1 changed files with 33 additions and 0 deletions
|
|
@ -47,6 +47,8 @@ struct Editor::Impl : EditorController::Receiver, IControlListener {
|
|||
std::string userFilesDir_;
|
||||
std::string fallbackFilesDir_;
|
||||
|
||||
SharedPointer<CVSTGUITimer> memQueryTimer_;
|
||||
|
||||
enum {
|
||||
kPanelGeneral,
|
||||
kPanelControls,
|
||||
|
|
@ -172,6 +174,7 @@ struct Editor::Impl : EditorController::Receiver, IControlListener {
|
|||
void updateCCValue(unsigned cc, float value);
|
||||
void updateCCDefaultValue(unsigned cc, float value);
|
||||
void updateCCLabel(unsigned cc, const char* label);
|
||||
void updateMemoryUsed(uint64_t mem);
|
||||
|
||||
// edition of CC by UI
|
||||
void performCCValueChange(unsigned cc, float value);
|
||||
|
|
@ -224,6 +227,10 @@ void Editor::open(CFrame& frame)
|
|||
impl.frame_ = &frame;
|
||||
frame.addView(impl.mainView_.get());
|
||||
|
||||
impl.memQueryTimer_ = makeOwned<CVSTGUITimer>([this](CVSTGUITimer*) {
|
||||
impl_->sendQueuedOSC("/mem/buffers", "", nullptr);
|
||||
}, 1000, true);
|
||||
|
||||
// request the whole Key and CC information
|
||||
impl.sendQueuedOSC("/key/slots", "", nullptr);
|
||||
impl.sendQueuedOSC("/sw/slots", "", nullptr);
|
||||
|
|
@ -236,6 +243,8 @@ void Editor::close()
|
|||
|
||||
impl.clearQueuedOSC();
|
||||
|
||||
impl.memQueryTimer_ = nullptr;
|
||||
|
||||
if (impl.frame_) {
|
||||
impl.frame_->removeView(impl.mainView_.get(), false);
|
||||
impl.frame_ = nullptr;
|
||||
|
|
@ -461,6 +470,9 @@ void Editor::Impl::uiReceiveMessage(const char* path, const char* sig, const sfi
|
|||
else if (Messages::matchOSC("/cc&/label", path, indices) && !strcmp(sig, "s")) {
|
||||
updateCCLabel(indices[0], args[0].s);
|
||||
}
|
||||
else if (Messages::matchOSC("/mem/buffers", path, indices) && !strcmp(sig, "h")) {
|
||||
updateMemoryUsed(args[0].h);
|
||||
}
|
||||
else {
|
||||
//fprintf(stderr, "Receive unhandled OSC: %s\n", path);
|
||||
}
|
||||
|
|
@ -1349,6 +1361,27 @@ void Editor::Impl::updateCCLabel(unsigned cc, const char* label)
|
|||
panel->setControlLabelText(cc, label);
|
||||
}
|
||||
|
||||
void Editor::Impl::updateMemoryUsed(uint64_t mem)
|
||||
{
|
||||
if (CTextLabel* label = memoryLabel_) {
|
||||
double value = mem / 1e3;
|
||||
const char* unit = "kB";
|
||||
int precision = 0;
|
||||
if (value >= 1e3) {
|
||||
value /= 1e3;
|
||||
unit = "MB";
|
||||
}
|
||||
if (value >= 1e3) {
|
||||
value /= 1e3;
|
||||
unit = "GB";
|
||||
precision = 1;
|
||||
}
|
||||
char textbuf[128];
|
||||
snprintf(textbuf, sizeof(textbuf), "%.*f %s", precision, value, unit);
|
||||
label->setText(textbuf);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::Impl::performCCValueChange(unsigned cc, float value)
|
||||
{
|
||||
// TODO(jpc) CC as parameters and automation
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue