1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 08:09:32 +02:00

Bug 258 (P2) - Mixer Board: max peak and clipping lines removed

Fixed bug in resetting mPrevT1. That caused remaining issue noted in Bug 258 comments 2 and 3.

Moved call to UpdateMeters from TrackPanel::OnTimer() to audacityAudioCallback, where it calls gAudioIO->mOutputMeter->UpdateDisplay(), so the updates are synchronized with Meter Toolbar updates.

Removed unnecessary call to MixerBoard::UpdateMeters() in AudacityProject::UpdateMixerBoard().

Various cleanup.
This commit is contained in:
v.audacity 2011-01-31 01:49:01 +00:00
parent 7d6c347140
commit d2d876d9a5
7 changed files with 51 additions and 26 deletions

View File

@ -316,7 +316,6 @@ writing audio.
#include "NoteTrack.h"
#endif
#define NO_STABLE_INDICATOR -1000000000
#define LOWER_BOUND 0.0
#define UPPER_BOUND 1.0
@ -1875,7 +1874,7 @@ double AudioIO::NormalizeStreamTime(double absoluteTime) const
double AudioIO::GetStreamTime()
{
if( !IsStreamActive() )
return -1000000000;
return BAD_STREAM_TIME;
return NormalizeStreamTime(mTime);
}
@ -3648,6 +3647,11 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
gAudioIO->mOutputMeter->UpdateDisplay(numPlaybackChannels,
framesPerBuffer,
outputMeterFloats);
AudacityProject* pProj = GetActiveProject();
MixerBoard* pMixerBoard = pProj->GetMixerBoard();
if (pMixerBoard)
pMixerBoard->UpdateMeters(gAudioIO->GetStreamTime(),
(pProj->mLastPlayMode == loopedPlay));
}
gAudioIO->mUpdatingMeters = false;
} // end playback VU meter update

View File

@ -63,6 +63,8 @@ public:
virtual void OnAudioIONewBlockFiles(const wxString& blockFileLog) = 0;
};
#define BAD_STREAM_TIME -1000000000.0
#define MAX_MIDI_BUFFER_SIZE 5000
#define DEFAULT_SYNTH_LATENCY 5

View File

@ -78,7 +78,7 @@ LyricsWindow::LyricsWindow(AudacityProject *parent):
wxPoint panelPos(0, 0);
wxSize panelSize = gSize;
//vvvvv not yet working right in ported version, so choice is disabled.
//vvv not yet working right in ported version, so choice is disabled.
// It seems when you select highlight style, the TrackPanel timer stops working, but
// going back to bouncing ball style starts it up again (!!!), per breakpoints in TrackPanel::OnTimer().
//
@ -112,7 +112,7 @@ LyricsWindow::LyricsWindow(AudacityProject *parent):
mLyricsPanel = new Lyrics(this, -1, panelPos, panelSize);
//vvvvv Highlight style is broken in ported version.
//vvv Highlight style is broken in ported version.
//switch (mLyricsPanel->GetLyricsStyle())
//{
// case Lyrics::kBouncingBallLyrics:

View File

@ -78,6 +78,7 @@ void MixerTrackSlider::OnMouseEvent(wxMouseEvent &event)
#define kInset 4
#define kDoubleInset (2 * kInset)
#define kTripleInset (3 * kInset)
#define kQuadrupleInset (4 * kInset)
#define TRACK_NAME_HEIGHT 18
@ -354,7 +355,7 @@ void MixerTrackCluster::UpdateForStateChange()
void MixerTrackCluster::UpdateName()
{
wxString newName = mTrack->GetName();
wxString newName = mLeftTrack->GetName();
mStaticText_TrackName->SetLabel(newName);
#if wxUSE_TOOLTIPS
mStaticText_TrackName->SetToolTip(newName);
@ -429,7 +430,7 @@ void MixerTrackCluster::UpdateMeter(const double t0, const double t1)
// instead of passing in all the data and asking the meter to derive peak and rms.
// May be worth revisiting as I think it should perform better, because it uses the min/max/rms
// stored in blockfiles, rather than calculating them, but for now, changing it to use the
// original Meter::UpdateDisplay(). New code is intermixed with the previous (now commented out).
// original Meter::UpdateDisplay(). New code is below the previous (now commented out).
//
//const int kFramesPerBuffer = 4;
//float min; // dummy, since it's not shown in meters
@ -518,7 +519,8 @@ void MixerTrackCluster::UpdateMeter(const double t0, const double t1)
//const bool bWantPostFadeValues = true; //v Turn this into a checkbox on MixerBoard? For now, always true.
//if (bSuccess && bWantPostFadeValues)
if (bSuccess)
{
{
//vvv Need to apply envelope, too? See Mixer::MixSameRate.
float gain = mLeftTrack->GetChannelGain(0);
if (gain < 1.0)
for (int index = 0; index < nFrames; index++)
@ -530,6 +532,13 @@ void MixerTrackCluster::UpdateMeter(const double t0, const double t1)
if (gain < 1.0)
for (int index = 0; index < nFrames; index++)
meterFloatsArray[(2 * index) + 1] *= gain;
// Clip to [-1.0, 1.0] range.
for (int index = 0; index < 2 * nFrames; index++)
if (meterFloatsArray[index] < -1.0)
meterFloatsArray[index] = -1.0;
else if (meterFloatsArray[index] > 1.0)
meterFloatsArray[index] = 1.0;
mMeter->UpdateDisplay(2, nFrames, meterFloatsArray);
}
else
@ -771,7 +780,7 @@ void MixerBoardScrolledWindow::OnMouseEvent(wxMouseEvent& event)
#define MIXER_BOARD_MIN_HEIGHT 460
// Min width is one cluster wide, plus margins.
#define MIXER_BOARD_MIN_WIDTH kDoubleInset + kMixerTrackClusterWidth + kDoubleInset
#define MIXER_BOARD_MIN_WIDTH kTripleInset + kMixerTrackClusterWidth + kTripleInset
BEGIN_EVENT_TABLE(MixerBoard, wxWindow)
@ -1095,7 +1104,7 @@ void MixerBoard::ResizeTrackClusters()
void MixerBoard::ResetMeters(const bool bResetClipping)
{
mPrevT1 = 0.0;
mPrevT1 = BAD_STREAM_TIME;
if (!this->IsShown())
return;
@ -1162,9 +1171,15 @@ void MixerBoard::UpdateGain(const Track* pTrack)
void MixerBoard::UpdateMeters(const double t1, const bool bLoopedPlay)
{
if (!this->IsShown())
if (!this->IsShown() || (t1 == BAD_STREAM_TIME))
return;
if (mPrevT1 == BAD_STREAM_TIME)
{
mPrevT1 = t1;
return;
}
// In loopedPlay mode, at the end of the loop, mPrevT1 is set to
// selection end, so the next t1 will be less, but we do want to
// keep updating the meters.

View File

@ -3647,7 +3647,10 @@ void AudacityProject::UpdateMixerBoard()
if (!mMixerBoard)
return;
mMixerBoard->UpdateTrackClusters();
mMixerBoard->UpdateMeters(gAudioIO->GetStreamTime(), (mLastPlayMode == loopedPlay));
// Vaughan, 2011-01-28: AudacityProject::UpdateMixerBoard() is called on state changes,
// so don't really need to call UpdateMeters().
//mMixerBoard->UpdateMeters(gAudioIO->GetStreamTime(), (mLastPlayMode == loopedPlay));
}
//

View File

@ -883,18 +883,17 @@ void TrackPanel::OnTimer()
}
}
//vvvvv Vaughan, 2010-11-27:
// Since all we're doing here is updating the meters, maybe we should remove it from here
// and we do that in audacityAudioCallback where it calls gAudioIO->mOutputMeter->UpdateDisplay().
// Thread issues?
MixerBoard* pMixerBoard = this->GetMixerBoard();
if (pMixerBoard &&
(p->GetAudioIOToken() > 0) &&
gAudioIO->IsStreamActive(p->GetAudioIOToken()))
{
pMixerBoard->UpdateMeters(gAudioIO->GetStreamTime(),
(p->mLastPlayMode == loopedPlay));
}
// Vaughan, 2010-01-30:
// Since all we're doing here is updating the meters, I moved it to
// audacityAudioCallback where it calls gAudioIO->mOutputMeter->UpdateDisplay().
//MixerBoard* pMixerBoard = this->GetMixerBoard();
//if (pMixerBoard &&
// (p->GetAudioIOToken() > 0) &&
// gAudioIO->IsStreamActive(p->GetAudioIOToken()))
//{
// pMixerBoard->UpdateMeters(gAudioIO->GetStreamTime(),
// (p->mLastPlayMode == loopedPlay));
//}
// Check whether we were playing or recording, but the stream has stopped.
if (p->GetAudioIOToken()>0 &&
@ -912,8 +911,10 @@ void TrackPanel::OnTimer()
pLyricsPanel->Update(p->GetSel0());
}
if (pMixerBoard)
pMixerBoard->ResetMeters(false);
// Vaughan, 2011-01-28: No longer doing this on timer.
// Now it's in AudioIO::SetMeters() and AudioIO::StopStream(), as with Meter Toolbar meters.
//if (pMixerBoard)
// pMixerBoard->ResetMeters(false);
}
// Next, check to see if we were playing or recording

View File

@ -814,7 +814,7 @@ void Meter::HandleLayout()
left += mLeftSize.x+4;
}
mRightTextPos = wxPoint(width-mLeftSize.x, height-2-mLeftSize.y);
width -= mLeftSize.x + mRightSize.x + 8; //vvvvv ...but then -8 in UmixIt? -- for vertical only?
width -= mLeftSize.x + mRightSize.x + 8; //vvv ...but then -8 in UmixIt? -- for vertical only?
}
barw = (width-2)/2;
barh = height - 4;