diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 022217bcd..a1ac66ef3 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -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 diff --git a/src/AudioIO.h b/src/AudioIO.h index 61b43d207..2d3bf5b78 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -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 diff --git a/src/LyricsWindow.cpp b/src/LyricsWindow.cpp index 919ec7abf..18da766cd 100644 --- a/src/LyricsWindow.cpp +++ b/src/LyricsWindow.cpp @@ -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: diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 1fa090806..407980150 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -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. diff --git a/src/Project.cpp b/src/Project.cpp index fa25facd2..72110f096 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -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)); } // diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index b1c698b00..ea6075558 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -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 diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index 537fc2477..0154956a5 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -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;