1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-04 21:50:51 +01:00

Fixed various casting to (WaveTrack*) without a test for GetKind()==Track::Wave. Was causing crash in (at least) the Contrast.cpp analyze function, when a label was selected but not audio. Also fixed log-of-zero problem in Contrast.cpp when sampling silence.

This commit is contained in:
james.k.crook@gmail.com
2011-04-23 18:53:48 +00:00
parent 14bc36ee39
commit f2bf104922
4 changed files with 94 additions and 90 deletions

View File

@@ -94,13 +94,11 @@ void CloseContrastDialog()
float ContrastDialog::GetDB()
{
// not good
// why not?
// what if more than one track?
// FIX-ME: what if more than one track?
float rms = float(0.0);
AudacityProject *p = GetActiveProject();
TrackListIterator iter(p->GetTracks());
TrackListOfKindIterator iter(Track::Wave, p->GetTracks());
Track *t = iter.First();
if(mT0 > mT1)
{
@@ -120,10 +118,15 @@ float ContrastDialog::GetDB()
}
if(mT0 == mT1)
return 1234.0;
while(t) { // this isn't quite right. What to do if more than one track selected?
while(t) {
// FIX-ME: This isn't quite right.
// What to do if more than one track selected?
// Also what if tracks in selection are not wavetracks?
((WaveTrack *)t)->GetRMS(&rms, mT0, mT1);
t = iter.Next();
}
if( rms < 1.0E-30 )
return -60.0;
return 20.0*log10(rms);
}

View File

@@ -93,10 +93,11 @@ bool EffectSimplePairedTwoTrack<_DataType,_xxxSample>::Init()
mnTracks = 1;
mnBlockSize = 0;
TrackListIterator iter(mTracks);
WaveTrack *left = (WaveTrack*)(iter.First());
if ( left == 0 )
return false; // Must have an existing track.
// FIX-ME: Should this be SelectedTrackListOfKindIterator?
TrackListOfKindIterator iter(Track::Wave, mTracks);
WaveTrack *left = (WaveTrack*)iter.First();
if( NULL == left )
return false;
while(left) {
sampleCount lstart, rstart;