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

Adjust ReplayGain: Allow user to update the replaygain value based on a deck pregain value. #4031

Merged
merged 10 commits into from
Jul 28, 2021
16 changes: 8 additions & 8 deletions src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ BaseTrackPlayerImpl::BaseTrackPlayerImpl(
m_pRateRatio = make_parented<ControlProxy>(getGroup(), "rate_ratio", this);
m_pPitchAdjust = make_parented<ControlProxy>(getGroup(), "pitch_adjust", this);

m_pUpdateReplayGainFromDeckGain = std::make_unique<ControlPushButton>(
m_pUpdateReplayGainFromPregain = std::make_unique<ControlPushButton>(
ConfigKey(getGroup(), "update_replaygain_from_pregain"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite a verbose name for a ControlObject... how about just update_replaygain... or set_replaygain? store_replaygain?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the name. Our other CO names are often extremely ambiguous (so this PR introduces inconsistency 😅). You suggestions sound like I can set a the replaygain value directly, not like a button CO that takes only 1 and 0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I don't know how to make it shorter and include the ideas of both the deck pregain and the track replaygain. "apply_pregain_to_replaygain" ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how to remove any more words without making it confusing, and I don't think we have any limitations on CO name length

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't thought of any better name, so... 🤷 I won't object to merging this over finding a better name.

connect(m_pUpdateReplayGainFromDeckGain.get(),
connect(m_pUpdateReplayGainFromPregain.get(),
&ControlObject::valueChanged,
this,
&BaseTrackPlayerImpl::slotUpdateReplaygainFromDeckGain);
&BaseTrackPlayerImpl::slotUpdateReplaygainFromPregain);
}

BaseTrackPlayerImpl::~BaseTrackPlayerImpl() {
Expand Down Expand Up @@ -375,9 +375,9 @@ void BaseTrackPlayerImpl::connectLoadedTrack() {
this,
&BaseTrackPlayerImpl::slotSetReplayGain);
connect(m_pLoadedTrack.get(),
&Track::updateAndAdjustReplayGain,
&Track::replayGainAdjusted,
this,
&BaseTrackPlayerImpl::slotUpdateAndAdjustReplayGain);
&BaseTrackPlayerImpl::slotAdjustReplayGain);

connect(m_pLoadedTrack.get(),
&Track::colorUpdated,
Expand Down Expand Up @@ -618,7 +618,7 @@ void BaseTrackPlayerImpl::slotSetReplayGain(mixxx::ReplayGain replayGain) {
}
}

void BaseTrackPlayerImpl::slotUpdateAndAdjustReplayGain(mixxx::ReplayGain replayGain) {
void BaseTrackPlayerImpl::slotAdjustReplayGain(mixxx::ReplayGain replayGain) {
const double factor = m_pReplayGain->get() / replayGain.getRatio();
const double newPregain = m_pPreGain->get() * factor;

Expand Down Expand Up @@ -739,7 +739,7 @@ void BaseTrackPlayerImpl::slotShiftCuesMillisButton(double value, double millise
slotShiftCuesMillis(milliseconds);
}

void BaseTrackPlayerImpl::slotUpdateReplaygainFromDeckGain(double pressed) {
void BaseTrackPlayerImpl::slotUpdateReplaygainFromPregain(double pressed) {
if (pressed <= 0) {
return;
}
Expand All @@ -751,7 +751,7 @@ void BaseTrackPlayerImpl::slotUpdateReplaygainFromDeckGain(double pressed) {
if (gain == 1.0) {
return;
}
m_pLoadedTrack->adjustReplayGainFromDeckGain(gain);
m_pLoadedTrack->adjustReplayGainFromPregain(gain);
}

void BaseTrackPlayerImpl::setReplayGain(double value) {
Expand Down
8 changes: 5 additions & 3 deletions src/mixer/basetrackplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class BaseTrackPlayerImpl : public BaseTrackPlayer {
void slotTrackLoaded(TrackPointer pNewTrack, TrackPointer pOldTrack);
void slotLoadFailed(TrackPointer pTrack, const QString& reason);
void slotSetReplayGain(mixxx::ReplayGain replayGain);
void slotUpdateAndAdjustReplayGain(mixxx::ReplayGain replayGain);
// When the replaygain is adjusted, we modify the track pregain
// to compensate so there is no audible change in volume.
void slotAdjustReplayGain(mixxx::ReplayGain replayGain);
void slotSetTrackColor(const mixxx::RgbColor::optional_t& color);
void slotPlayToggled(double);

Expand All @@ -98,7 +100,7 @@ class BaseTrackPlayerImpl : public BaseTrackPlayer {
void slotWaveformZoomSetDefault(double pressed);
void slotShiftCuesMillis(double milliseconds);
void slotShiftCuesMillisButton(double value, double milliseconds);
void slotUpdateReplaygainFromDeckGain(double pressed);
void slotUpdateReplaygainFromPregain(double pressed);

private:
void setReplayGain(double value);
Expand Down Expand Up @@ -144,7 +146,7 @@ class BaseTrackPlayerImpl : public BaseTrackPlayer {
std::unique_ptr<ControlPushButton> m_pShiftCuesLaterSmall;
std::unique_ptr<ControlObject> m_pShiftCues;

std::unique_ptr<ControlObject> m_pUpdateReplayGainFromDeckGain;
std::unique_ptr<ControlObject> m_pUpdateReplayGainFromPregain;

parented_ptr<ControlProxy> m_pReplayGain;
parented_ptr<ControlProxy> m_pPlay;
Expand Down
4 changes: 2 additions & 2 deletions src/track/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,13 @@ void Track::setReplayGain(const mixxx::ReplayGain& replayGain) {
}
}

void Track::adjustReplayGainFromDeckGain(double gain) {
void Track::adjustReplayGainFromPregain(double gain) {
QMutexLocker lock(&m_qMutex);
mixxx::ReplayGain replayGain = m_record.getMetadata().getTrackInfo().getReplayGain();
replayGain.setRatio(gain * replayGain.getRatio());
if (compareAndSet(m_record.refMetadata().refTrackInfo().ptrReplayGain(), replayGain)) {
markDirtyAndUnlock(&lock);
emit updateAndAdjustReplayGain(replayGain);
emit replayGainAdjusted(replayGain);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/track/track.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Track : public QObject {
// Set ReplayGain
void setReplayGain(const mixxx::ReplayGain&);
// Adjust ReplayGain by multiplying the given gain amount.
void adjustReplayGainFromDeckGain(double);
void adjustReplayGainFromPregain(double);
// Returns ReplayGain
mixxx::ReplayGain getReplayGain() const;

Expand Down Expand Up @@ -414,7 +414,7 @@ class Track : public QObject {
void replayGainUpdated(mixxx::ReplayGain replayGain);
// This signal indicates that ReplayGain is being adjusted, and pregains should be
// adjusted in the opposite direction to compensate (no audible change).
void updateAndAdjustReplayGain(const mixxx::ReplayGain&);
void replayGainAdjusted(const mixxx::ReplayGain&);
void colorUpdated(const mixxx::RgbColor::optional_t& color);
void cuesUpdated();
void analyzed();
Expand Down
6 changes: 3 additions & 3 deletions src/widget/wtrackmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ void WTrackMenu::createActions() {
connect(m_pUpdateReplayGain,
&QAction::triggered,
this,
&WTrackMenu::slotUpdateReplaygainFromDeckGain);
&WTrackMenu::slotUpdateReplaygainFromPregain);
}

if (featureIsEnabled(Feature::Color)) {
Expand Down Expand Up @@ -915,7 +915,7 @@ class ImportMetadataFromFileTagsTrackPointerOperation : public mixxx::TrackPoint

} // anonymous namespace

void WTrackMenu::slotUpdateReplaygainFromDeckGain() {
void WTrackMenu::slotUpdateReplaygainFromPregain() {
VERIFY_OR_DEBUG_ASSERT(m_pTrack) {
return;
}
Expand All @@ -928,7 +928,7 @@ void WTrackMenu::slotUpdateReplaygainFromDeckGain() {
if (gain == 1.0) {
return;
}
m_pTrack->adjustReplayGainFromDeckGain(gain);
m_pTrack->adjustReplayGainFromPregain(gain);
}

void WTrackMenu::slotImportMetadataFromFileTags() {
Expand Down
2 changes: 1 addition & 1 deletion src/widget/wtrackmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class WTrackMenu : public QMenu {
void slotScaleBpm(mixxx::Beats::BpmScale scale);

// Info and metadata
void slotUpdateReplaygainFromDeckGain();
void slotUpdateReplaygainFromPregain();
ywwg marked this conversation as resolved.
Show resolved Hide resolved
void slotShowDlgTagFetcher();
void slotImportMetadataFromFileTags();
void slotExportMetadataIntoFileTags();
Expand Down