mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
Seems to be working properly now!
This commit is contained in:
parent
0681e09e18
commit
f70c58ef6b
@ -60,12 +60,14 @@ static const std::vector<std::string> BANDS = {
|
|||||||
"11840", "16744"
|
"11840", "16744"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const int UPDATE_DEBOUNCE_MS = 350;
|
||||||
static const int VERTICAL_PADDING = 2;
|
static const int VERTICAL_PADDING = 2;
|
||||||
static const int MAX_HEIGHT = 7 + (int) BANDS.size();
|
static const int MAX_HEIGHT = 7 + (int) BANDS.size();
|
||||||
|
|
||||||
static std::string formatBandRow(size_t width, const std::string& band, double value) {
|
static std::string formatBandRow(size_t width, const std::string& band, double value) {
|
||||||
width -= 2; /* left/right padding */
|
width -= 2; /* left/right padding */
|
||||||
std::string left = u8fmt(" %s khz (%0.2f) ", band.c_str(), value);
|
|
||||||
|
std::string left = u8fmt(" %s khz ", band.c_str());
|
||||||
|
|
||||||
int remain = width - u8cols(left);
|
int remain = width - u8cols(left);
|
||||||
int trackWidth = std::min(remain, 25);
|
int trackWidth = std::min(remain, 25);
|
||||||
@ -79,7 +81,11 @@ static std::string formatBandRow(size_t width, const std::string& band, double v
|
|||||||
right += (i == thumbOffset) ? "■" : "─";
|
right += (i == thumbOffset) ? "■" : "─";
|
||||||
}
|
}
|
||||||
|
|
||||||
remain = width - (u8cols(left) + u8cols(right));
|
right = u8fmt(" %s %0.2f", right.c_str(), value);
|
||||||
|
|
||||||
|
/* TODO: i'm dumb and it's late; we shouldn't need the `+ 1` here, there's
|
||||||
|
another calculation error that i'm currently blind to. */
|
||||||
|
remain = width - (u8cols(left) + u8cols(right)) + 1;
|
||||||
|
|
||||||
return text::Align(left, text::AlignLeft, u8cols(left) + remain) + right;
|
return text::Align(left, text::AlignLeft, u8cols(left) + remain) + right;
|
||||||
}
|
}
|
||||||
@ -166,7 +172,7 @@ void EqualizerOverlay::Layout() {
|
|||||||
|
|
||||||
void EqualizerOverlay::OnEnabledChanged(cursespp::Checkbox* cb, bool checked) {
|
void EqualizerOverlay::OnEnabledChanged(cursespp::Checkbox* cb, bool checked) {
|
||||||
this->prefs->SetBool("enabled", checked);
|
this->prefs->SetBool("enabled", checked);
|
||||||
this->DebounceMessage(message::UpdateEqualizer, 0, 0, 500);
|
this->NotifyAndRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EqualizerOverlay::KeyPress(const std::string& key) {
|
bool EqualizerOverlay::KeyPress(const std::string& key) {
|
||||||
@ -176,17 +182,28 @@ bool EqualizerOverlay::KeyPress(const std::string& key) {
|
|||||||
this->Dismiss();
|
this->Dismiss();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (key == "z") {
|
||||||
|
for (auto band : BANDS) {
|
||||||
|
this->prefs->SetDouble(band.c_str(), 1.0);
|
||||||
|
}
|
||||||
|
this->NotifyAndRedraw();
|
||||||
|
}
|
||||||
else if (keys.Left(key)) {
|
else if (keys.Left(key)) {
|
||||||
this->UpdateSelectedBand(-0.05f);
|
this->UpdateSelectedBand(-0.1f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (keys.Right(key)) {
|
else if (keys.Right(key)) {
|
||||||
this->UpdateSelectedBand(0.05f);
|
this->UpdateSelectedBand(0.1f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return OverlayBase::KeyPress(key);
|
return OverlayBase::KeyPress(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EqualizerOverlay::NotifyAndRedraw() {
|
||||||
|
this->listView->OnAdapterChanged();
|
||||||
|
this->DebounceMessage(message::UpdateEqualizer, 0, 0, UPDATE_DEBOUNCE_MS);
|
||||||
|
}
|
||||||
|
|
||||||
void EqualizerOverlay::ProcessMessage(musik::core::runtime::IMessage &message) {
|
void EqualizerOverlay::ProcessMessage(musik::core::runtime::IMessage &message) {
|
||||||
if (message.Type() == message::UpdateEqualizer) {
|
if (message.Type() == message::UpdateEqualizer) {
|
||||||
this->plugin->Reload();
|
this->plugin->Reload();
|
||||||
@ -198,8 +215,7 @@ void EqualizerOverlay::UpdateSelectedBand(double delta) {
|
|||||||
double existing = this->prefs->GetDouble(band.c_str(), 1.0);
|
double existing = this->prefs->GetDouble(band.c_str(), 1.0);
|
||||||
double updated = std::min(2.0, std::max(0.0, existing + delta));
|
double updated = std::min(2.0, std::max(0.0, existing + delta));
|
||||||
this->prefs->SetDouble(band.c_str(), updated);
|
this->prefs->SetDouble(band.c_str(), updated);
|
||||||
this->listView->OnAdapterChanged();
|
this->NotifyAndRedraw();
|
||||||
this->DebounceMessage(message::UpdateEqualizer, 0, 0, 500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ~~~~~~ BandsAdapter ~~~~~ */
|
/* ~~~~~~ BandsAdapter ~~~~~ */
|
||||||
|
@ -78,6 +78,7 @@ namespace musik {
|
|||||||
|
|
||||||
bool CanScroll(int listViewHeight);
|
bool CanScroll(int listViewHeight);
|
||||||
void UpdateSelectedBand(double delta);
|
void UpdateSelectedBand(double delta);
|
||||||
|
void NotifyAndRedraw();
|
||||||
|
|
||||||
void OnEnabledChanged(cursespp::Checkbox* cb, bool checked);
|
void OnEnabledChanged(cursespp::Checkbox* cb, bool checked);
|
||||||
|
|
||||||
|
@ -75,10 +75,6 @@ void SuperEqDsp::Release() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SuperEqDsp::Process(IBuffer* buffer) {
|
bool SuperEqDsp::Process(IBuffer* buffer) {
|
||||||
if (!this->enabled) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int channels = buffer->Channels();
|
int channels = buffer->Channels();
|
||||||
int current = ::currentState.load();
|
int current = ::currentState.load();
|
||||||
|
|
||||||
@ -93,7 +89,7 @@ bool SuperEqDsp::Process(IBuffer* buffer) {
|
|||||||
float bands[17];
|
float bands[17];
|
||||||
|
|
||||||
for (int i = 0; i < BANDS.size(); i++) {
|
for (int i = 0; i < BANDS.size(); i++) {
|
||||||
prefs->GetDouble(BANDS[i].c_str(), 1.0);
|
bands[i] = prefs->GetDouble(BANDS[i].c_str(), 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
equ_makeTable(
|
equ_makeTable(
|
||||||
@ -105,6 +101,10 @@ bool SuperEqDsp::Process(IBuffer* buffer) {
|
|||||||
paramlist_free(params);
|
paramlist_free(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this->enabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return equ_modifySamples_float(
|
return equ_modifySamples_float(
|
||||||
this->supereq,
|
this->supereq,
|
||||||
(char*) buffer->BufferPointer(),
|
(char*) buffer->BufferPointer(),
|
||||||
|
Loading…
Reference in New Issue
Block a user