Skip to content

Commit

Permalink
spectrum: implementing the bar mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmm committed Jan 3, 2025
1 parent a4ba780 commit 9c01037
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/contents/kcfg/easyeffects_db_spectrum.kcfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<label>Enable Dynamic Scaling for the Vertical Axis</label>
<default>true</default>
</entry>
<entry name="logarithimicHorizontalAxis" type="Bool">
<label>Enable logarithmic scale for the Frequency Axis</label>
<default>true</default>
</entry>
<entry name="spectrumShape" type="Enum">
<label>Spectrum Type</label>
<choices>
Expand All @@ -28,7 +32,7 @@
<label>Area</label>
</choice>
</choices>
<default>1</default>
<default>0</default>
</entry>
<entry name="spectrumColorScheme" type="Enum">
<label>Spectrum Color Scheme</label>
Expand Down
25 changes: 22 additions & 3 deletions src/contents/ui/EeChart.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ Item {
if (areaSeries.visible === true)
areaLineSeries.replace(newData);

if (barSeries.visible === true) {
barSeriesSet.clear();
for (let n = 0; n < newData.length; n++) {
barSeriesSet.append(newData[n].y);
}
}
}

Kirigami.Theme.inherit: false
Expand All @@ -68,15 +74,19 @@ Item {
marginRight: 0
Layout.fillWidth: true
Layout.fillHeight: true
axisX: {
if (barSeries.visible === false)
return horizontalAxis;
else
return barAxis;
}

BarSeries {
id: barSeries

visible: seriesType === 0

BarSet {
// values: widgetRoot.graphData

id: barSeriesSet
}

Expand Down Expand Up @@ -105,7 +115,7 @@ Item {

}

axisX: ValueAxis {
ValueAxis {
id: horizontalAxis

labelFormat: "%.1f"
Expand All @@ -118,6 +128,15 @@ Item {
labelDecimals: 0
}

BarCategoryAxis {
id: barAxis

categories: [2024, 2025, 2026]
gridVisible: false
subGridVisible: false
visible: false
}

axisY: ValueAxis {
id: verticalAxis

Expand Down
1 change: 1 addition & 0 deletions src/contents/ui/PageStreamsEffects.qml
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ Kirigami.Page {
xMax: DB.Manager.spectrum.maximumFrequency
yMin: -100
yMax: 0
logarithimicHorizontalAxis: DB.Manager.spectrum.logarithimicHorizontalAxis
Component.onCompleted: {
headerFrameAnimation.start();
}
Expand Down
12 changes: 12 additions & 0 deletions src/contents/ui/PreferencesSheet.qml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,18 @@ Kirigami.OverlaySheet {
}
}

EeSwitch {
id: logarithimicHorizontalAxis

label: i18n("Logarithmic Frequency Axis")
isChecked: DB.Manager.spectrum.logarithimicHorizontalAxis
onCheckedChanged: {
if (isChecked !== DB.Manager.spectrum.logarithimicHorizontalAxis)
DB.Manager.spectrum.logarithimicHorizontalAxis = isChecked;

}
}

EeSpinBox {
id: nPoints

Expand Down
10 changes: 9 additions & 1 deletion src/effects_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <ranges>
#include <string>
#include <utility>
#include <vector>
#include "autogain.hpp"
#include "bass_enhancer.hpp"
#include "compressor.hpp"
Expand Down Expand Up @@ -376,7 +377,14 @@ void EffectsBase::requestSpectrumData() {
return;
}

auto log_x_axis = util::logspace(min_freq, max_freq, db::Spectrum::nPoints());
// auto log_x_axis = util::logspace(min_freq, max_freq, db::Spectrum::nPoints());
std::vector<float> log_x_axis;

if (db::Spectrum::logarithimicHorizontalAxis()) {
log_x_axis = util::logspace(min_freq, max_freq, db::Spectrum::nPoints());
} else {
log_x_axis = util::linspace(min_freq, max_freq, db::Spectrum::nPoints());
}

auto* acc = gsl_interp_accel_alloc();
auto* spline = gsl_spline_alloc(gsl_interp_steffen, n_bands);
Expand Down

0 comments on commit 9c01037

Please sign in to comment.