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

Per track meter internals #5830

Open
wants to merge 92 commits into
base: master
Choose a base branch
from

Conversation

Paul-Licameli
Copy link
Collaborator

@Paul-Licameli Paul-Licameli commented Dec 30, 2023

Resolves: (direct link to the issue)

Depends on

Some of this originated in #5779

Put into AudioIO.cpp all the support needed for per-track meters displaying correct peak and RMS data
(post all adjustments for the effect stack, pan, gain, envelope).

But also other cleanups of AudioIO. Move the experimental automated input level adjustment out, so the Meter
interface needs fewer virtual functions.

Also clean up the publication of events from AudioIO and correct some non-thread-safe message callbacks.

To do: MixerBoard should use this. It doesn't show correct data now in all cases. See #5117

(short description of the changes and the motivation to make the changes)

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

@Paul-Licameli Paul-Licameli added the refactoring Pull request that restructures code but is not intended to make any observable changes of behavior label Dec 30, 2023
@Paul-Licameli Paul-Licameli force-pushed the Per-track-meter-internals branch 2 times, most recently from 2271159 to f4680c4 Compare January 2, 2024 01:43
@Paul-Licameli Paul-Licameli force-pushed the Per-track-meter-internals branch 8 times, most recently from 4cf0c82 to 7780a46 Compare January 12, 2024 10:56
@@ -1126,8 +1126,8 @@ void MeterPanel::OnMeterUpdate(wxTimerEvent & WXUNUSED(event))

if (numChanges > 0) {
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
if (gAudioIO->AILAIsActive() && mIsInput && !discarded) {
gAudioIO->AILAProcess(maxPeak);
if (AudioIO::Get()->AILAIsActive() && mIsInput && !discarded) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that the only place EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT should be used in such approach is AILAIsActive.

if (gAudioIO->AILAIsActive() && mIsInput && !discarded) {
gAudioIO->AILAProcess(maxPeak);
if (AudioIO::Get()->AILAIsActive() && mIsInput && !discarded) {
AudioIO::Get()->AILAProcess(maxPeak);
putchar('\n');
Copy link
Contributor

Choose a reason for hiding this comment

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

But this code is disturbing. Why is it here?

This transformation is not quite conservative anyway, so probably this line should be removed?

It seems that AILA logs extensively, probably way to extensively. Is it ready for use at all?

gAudioIO->GetMixer(&inputSource, &inputVolume, &outputVolume);

auto settings = gAudioIO->GetMixer();
auto &[inputSource, inputVolume, outputVolume] = settings;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the code would be much more readable without this line.

@@ -2376,7 +2377,9 @@ void AudioIO::AILAProcess(double maxPeak) {

putchar('\n');
mAILAMax = pInputMeter ? ToLinearIfDB(mAILAMax, pInputMeter->GetDBRange()) : 0.0;
double iv = (double) Px_GetInputVolume(mPortMixer);
auto settings = audioIO.GetMixer();
auto &[_, inputVolume, __] = settings;
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, why?

wxPrintf("\tnew vol:%f\n", vol);
float check = Px_GetInputVolume(mPortMixer);
wxPrintf("\tnew vol:%f\n", inputVolume);
auto [_, check, __] = audioIO.GetMixer();
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is the weirdest case of structured binding use so far.

}

double AudioIO::AILAGetLastDecisionTime() {
return mAILAAnalysisEndTime;
}

double AudioIO::GetClockTime() const {
Copy link
Contributor

Choose a reason for hiding this comment

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

GetStreamTime returns stream time specific to Audacity, GetClockTime - actual stream time. Quite confusing, and I don't understand why is it called "clock" time.

AudioIO::AudioIO()
{
wxTimer::Start(kTimerInterval.count());
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no safety around what kind of duration the kTimerInterval will be. Explicit duration_cast<milliseconds> would help.

@Paul-Licameli Paul-Licameli added the Experimental Exploratory, proof-of-concept PRs, never to me merged label Jan 16, 2024
@Paul-Licameli
Copy link
Collaborator Author

I should have put the big red Experimental label on this bit of holiday hackathon. I didn't ask review yet, but thank you.

@Paul-Licameli
Copy link
Collaborator Author

@saintmatthieu @vsverchinsky

Rebased onto latest master.

There is much cleanup of AudioIO.cpp that I prepared. It's still not all of the cleanup.

Correct inter-thread communication of the stream of most recently played samples is necessary for a per-track meter display that is not meaningless garbage.

@Paul-Licameli Paul-Licameli force-pushed the Per-track-meter-internals branch 5 times, most recently from 49f32f5 to afbf2f6 Compare June 2, 2024 19:43
@Paul-Licameli Paul-Licameli mentioned this pull request Jun 2, 2024
6 tasks
... Don't emit start events until success is known.

Only ProjectAudioManager cared, and anyway ignored start events.
@Paul-Licameli Paul-Licameli force-pushed the Per-track-meter-internals branch 2 times, most recently from 5351389 to f0cfee7 Compare June 4, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experimental Exploratory, proof-of-concept PRs, never to me merged refactoring Pull request that restructures code but is not intended to make any observable changes of behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants