Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overview scale options #14463

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 57 additions & 18 deletions src/preferences/dialog/dlgprefwaveform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const ConfigKey kOverviewTypeCfgKey(QStringLiteral("[Waveform]"),
QStringLiteral("WaveformOverviewType"));
} // namespace

// for OverviewScaleMode from waveform/waveformwidgetfactory.h
using namespace mixxx;

DlgPrefWaveform::DlgPrefWaveform(
QWidget* pParent,
UserSettingsPointer pConfig,
Expand Down Expand Up @@ -173,14 +176,17 @@ DlgPrefWaveform::DlgPrefWaveform(
QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this,
&DlgPrefWaveform::slotSetVisualGainHigh);
connect(normalizeOverviewCheckBox,
&QCheckBox::toggled,

connect(overview_scale_options,
QOverload<QAbstractButton*>::of(&QButtonGroup::buttonClicked),
this,
&DlgPrefWaveform::slotSetNormalizeOverview);
connect(overviewMinuteMarkersCheckBox,
&QCheckBox::toggled,
QOverload<QAbstractButton*>::of(
&DlgPrefWaveform::slotSetOverviewScaling));
connect(overview_scale_custom_spinbox,
QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this,
&DlgPrefWaveform::slotSetOverviewMinuteMarkers);
&DlgPrefWaveform::slotSetOverviewCustomScaling);

connect(factory,
&WaveformWidgetFactory::waveformMeasured,
this,
Expand Down Expand Up @@ -289,7 +295,6 @@ void DlgPrefWaveform::slotUpdate() {
lowVisualGain->setValue(factory->getVisualGain(BandIndex::Low));
midVisualGain->setValue(factory->getVisualGain(BandIndex::Mid));
highVisualGain->setValue(factory->getVisualGain(BandIndex::High));
normalizeOverviewCheckBox->setChecked(factory->isOverviewNormalized());
// Round zoom to int to get a default zoom index.
defaultZoomComboBox->setCurrentIndex(static_cast<int>(factory->getDefaultZoom()) - 1);
playMarkerPositionSlider->setValue(static_cast<int>(factory->getPlayMarkerPosition() * 100));
Expand All @@ -315,6 +320,21 @@ void DlgPrefWaveform::slotUpdate() {
waveformOverviewComboBox->setCurrentIndex(cfgOverviewTypeIndex);
}

auto* pWidgetFactory = WaveformWidgetFactory::instance();
const OverviewScaleMode mode = pWidgetFactory->getOverviewScaleMode();
if (mode == OverviewScaleMode::FileGain) {
overview_scale_fileGain->setChecked(true);
} else if (mode == OverviewScaleMode::Normalize) {
overview_scale_normalize->setChecked(true);
} else if (mode == OverviewScaleMode::AllGainReplayGain) {
overview_scale_allReplayGain->setChecked(true);
} else { // OverviewScaleMode::Custom
overview_scale_custom_button->setChecked(true);
}

double customGain = pWidgetFactory->getOverviewCustomGain();
overview_scale_custom_spinbox->setValue(customGain);

bool drawOverviewMinuteMarkers = m_pConfig->getValue(
ConfigKey("[Waveform]", "draw_overview_minute_markers"), true);
overviewMinuteMarkersCheckBox->setChecked(drawOverviewMinuteMarkers);
Expand All @@ -328,6 +348,7 @@ void DlgPrefWaveform::slotUpdate() {
}

void DlgPrefWaveform::slotApply() {
// All other settings have already been applied instantly for preview purpose
WaveformSettings waveformSettings(m_pConfig);
waveformSettings.setWaveformCachingEnabled(enableWaveformCaching->isChecked());
waveformSettings.setWaveformGenerationWithAnalysisEnabled(
Expand Down Expand Up @@ -374,12 +395,15 @@ void DlgPrefWaveform::slotResetToDefaults() {
waveformOverviewComboBox->setCurrentIndex(
waveformOverviewComboBox->findData(QVariant::fromValue(WOverview::Type::RGB)));

// Don't normalize overview.
normalizeOverviewCheckBox->setChecked(false);

// Show minute markers.
overviewMinuteMarkersCheckBox->setChecked(true);

// Use file gain
overview_scale_fileGain->setChecked(false);

// load custom gain
overview_scale_custom_spinbox->setValue(1.0);

// 60FPS is the default
frameRateSlider->setValue(60);
endOfTrackWarningTimeSlider->setValue(30);
Expand Down Expand Up @@ -572,12 +596,12 @@ void DlgPrefWaveform::updateWaveformGeneralOptionsEnabled() {
}

void DlgPrefWaveform::updateWaveformGainEnabled() {
bool enabled = useWaveformCheckBox->isChecked() ||
!normalizeOverviewCheckBox->isChecked();
allVisualGain->setEnabled(enabled);
lowVisualGain->setEnabled(enabled);
midVisualGain->setEnabled(enabled);
highVisualGain->setEnabled(enabled);
bool waveformsEnabled = useWaveformCheckBox->isChecked();
bool allGainEnabled = waveformsEnabled || overview_scale_allReplayGain->isChecked();
allVisualGain->setEnabled(allGainEnabled);
lowVisualGain->setEnabled(waveformsEnabled);
midVisualGain->setEnabled(waveformsEnabled);
highVisualGain->setEnabled(waveformsEnabled);
}

void DlgPrefWaveform::slotSetWaveformOverviewType() {
Expand Down Expand Up @@ -613,11 +637,26 @@ void DlgPrefWaveform::slotSetVisualGainHigh(double gain) {
WaveformWidgetFactory::instance()->setVisualGain(BandIndex::High, gain);
}

void DlgPrefWaveform::slotSetNormalizeOverview(bool normalize) {
WaveformWidgetFactory::instance()->setOverviewNormalized(normalize);
void DlgPrefWaveform::slotSetOverviewScaling(QAbstractButton* b) {
auto* pWidgetFactory = WaveformWidgetFactory::instance();
if (b == overview_scale_fileGain) {
pWidgetFactory->setOverviewScaleMode(OverviewScaleMode::FileGain);
} else if (b == overview_scale_normalize) {
pWidgetFactory->setOverviewScaleMode(OverviewScaleMode::Normalize);
} else if (b == overview_scale_allReplayGain) {
pWidgetFactory->setOverviewScaleMode(OverviewScaleMode::AllGainReplayGain);
} else { // b == overview_scale_custom_button
pWidgetFactory->setOverviewScaleMode(OverviewScaleMode::Custom);
}
overview_scale_custom_spinbox->setEnabled(b == overview_scale_custom_button);
updateWaveformGainEnabled();
}

void DlgPrefWaveform::slotSetOverviewCustomScaling(double gain) {
// TODO validate 0 < v < 5 here or in WaveformWidgetFactory ?
WaveformWidgetFactory::instance()->setOverviewCustomGain(gain);
}

void DlgPrefWaveform::slotSetOverviewMinuteMarkers(bool draw) {
m_pConfig->setValue(ConfigKey("[Waveform]", "draw_overview_minute_markers"), draw);
m_pOverviewMinuteMarkersControl->forceSet(draw);
Expand Down
8 changes: 5 additions & 3 deletions src/preferences/dialog/dlgprefwaveform.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg
slotSetWaveformOptions(allshader::WaveformRendererSignalBase::Option::HighDetail, checked);
}
#endif
void slotSetWaveformOverviewType();
void slotSetDefaultZoom(int index);
void slotSetZoomSynchronization(bool checked);
void slotSetVisualGainAll(double gain);
void slotSetVisualGainLow(double gain);
void slotSetVisualGainMid(double gain);
void slotSetVisualGainHigh(double gain);
void slotSetNormalizeOverview(bool normalize);
void slotSetOverviewMinuteMarkers(bool minuteMarkers);
void slotWaveformMeasured(float frameRate, int droppedFrames);
void slotClearCachedWaveforms();
void slotSetBeatGridAlpha(int alpha);
Expand All @@ -63,6 +60,11 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg
void slotSetUntilMarkAlign(int index);
void slotSetUntilMarkTextPointSize(int value);
void slotSetUntilMarkTextHeightLimit(int index);
// overview options
void slotSetWaveformOverviewType();
void slotSetOverviewMinuteMarkers(bool minuteMarkers);
void slotSetOverviewScaling(QAbstractButton* b);
void slotSetOverviewCustomScaling(double gain);

private:
void initWaveformControl();
Expand Down
83 changes: 78 additions & 5 deletions src/preferences/dialog/dlgprefwaveformdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -620,20 +620,86 @@ Select from different types of displays for the waveform overview, which differ
</item>

<item row="1" column="1" colspan="4">
<widget class="QCheckBox" name="normalizeOverviewCheckBox">
<widget class="QCheckBox" name="overviewMinuteMarkersCheckBox">
<property name="text">
<string>Normalize waveform overview</string>
<string>Show minute markers on waveform overview</string>
</property>
</widget>
</item>

<item row="2" column="0">
<widget class="QLabel" name="overview_gain_label">
<property name="toolTip">
<string extracomment="Select a gain mode for the waveform overview."/>
</property>
<property name="text">
<string>Gain</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="4">
<widget class="QCheckBox" name="overviewMinuteMarkersCheckBox">
<widget class="QRadioButton" name="overview_scale_fileGain">
<property name="text">
<string>Show minute markers on waveform overview</string>
<string>Use file gain</string>
</property>
<attribute name="buttonGroup">
<string notr="true">overview_scale_options</string>
</attribute>
</widget>
</item>
<item row="3" column="1" colspan="4">
<widget class="QRadioButton" name="overview_scale_normalize">
<property name="text">
<string>Normalize</string>
</property>
<attribute name="buttonGroup">
<string notr="true">overview_scale_options</string>
</attribute>
</widget>
</item>
<item row="4" column="1" colspan="4">
<widget class="QRadioButton" name="overview_scale_allReplayGain">
<property name="text">
<string>Use Waveform "All" gain incl. ReplayGain</string>
</property>
<attribute name="buttonGroup">
<string notr="true">overview_scale_options</string>
</attribute>
</widget>
</item>
<item row="5" column="1" colspan="4">
<layout class="QHBoxLayout" name="overview_customGain_layout">
<item>
<widget class="QRadioButton" name="overview_scale_custom_button">
<property name="text">
<string>Use custom gain</string>
</property>
<attribute name="buttonGroup">
<string notr="true">overview_scale_options</string>
</attribute>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="overview_scale_custom_spinbox">
<property name="toolTip">
<string>Global visual gain</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.500000000000000</double>
</property>
<property name="maximum">
<double>5.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
</item>

</layout>
</widget>
Expand Down Expand Up @@ -778,12 +844,19 @@ Select from different types of displays for the waveform overview, which differ
<tabstop>untilMarkTextPointSizeSpinBox</tabstop>
<tabstop>untilMarkTextHeightLimitComboBox</tabstop>
<tabstop>waveformOverviewComboBox</tabstop>
<tabstop>normalizeOverviewCheckBox</tabstop>
<tabstop>overview_scale_fileGain</tabstop>
<tabstop>overview_scale_normalize</tabstop>
<tabstop>overview_scale_allReplayGain</tabstop>
<tabstop>overview_scale_custom_button</tabstop>
<tabstop>overview_scale_custom_spinbox</tabstop>
<tabstop>overviewMinuteMarkersCheckBox</tabstop>
<tabstop>enableWaveformCaching</tabstop>
<tabstop>enableWaveformGenerationWithAnalysis</tabstop>
<tabstop>clearCachedWaveforms</tabstop>
</tabstops>
<buttongroups>
<buttongroup name="overview_scale_options"/>
</buttongroups>
<resources/>
<connections/>
</ui>
Loading
Loading