Audacity  3.0.3
Public Member Functions | Public Attributes | List of all members
ClipParameters Struct Reference

#include <WaveTrackView.h>

Collaboration diagram for ClipParameters:
[legend]

Public Member Functions

 ClipParameters (bool spectrum, const WaveTrack *track, const WaveClip *clip, const wxRect &rect, const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo)
 
void DrawClipEdges (wxDC &dc, const wxRect &rect) const
 

Public Attributes

double tOffset
 
double rate
 
double h
 
double tpre
 
double h1
 
double tpost
 
double t0
 
double t1
 
double averagePixelsPerSample
 
bool showIndividualSamples
 
sampleCount ssel0
 
sampleCount ssel1
 
wxRect hiddenMid
 
int hiddenLeftOffset
 
wxRect mid
 
int leftOffset
 

Detailed Description

Definition at line 160 of file WaveTrackView.h.

Constructor & Destructor Documentation

◆ ClipParameters()

ClipParameters::ClipParameters ( bool  spectrum,
const WaveTrack track,
const WaveClip clip,
const wxRect &  rect,
const SelectedRegion selectedRegion,
const ZoomInfo zoomInfo 
)

Definition at line 1095 of file WaveTrackView.cpp.

1098 {
1099  tOffset = clip->GetOffset();
1100  rate = clip->GetRate();
1101 
1102  h = zoomInfo.PositionToTime(0, 0
1103  , true
1104  );
1105  h1 = zoomInfo.PositionToTime(rect.width, 0
1106  , true
1107  );
1108 
1109  double sel0 = selectedRegion.t0(); //left selection bound
1110  double sel1 = selectedRegion.t1(); //right selection bound
1111 
1112  //If the track isn't selected, make the selection empty
1113  if (!track->GetSelected() &&
1114  (spectrum || !track->IsSyncLockSelected())) { // PRL: why was there a difference for spectrum?
1115  sel0 = sel1 = 0.0;
1116  }
1117 
1118  const double trackLen = clip->GetEndTime() - clip->GetStartTime();
1119 
1120  tpre = h - tOffset; // offset corrected time of
1121  // left edge of display
1122  tpost = h1 - tOffset; // offset corrected time of
1123  // right edge of display
1124 
1125  const double sps = 1. / rate; //seconds-per-sample
1126 
1127  // Determine whether we should show individual samples
1128  // or draw circular points as well
1129  averagePixelsPerSample = rect.width / (rate * (h1 - h));
1131 
1132  // Calculate actual selection bounds so that t0 > 0 and t1 < the
1133  // end of the track
1134  t0 = (tpre >= 0.0 ? tpre : 0.0);
1135  t1 = (tpost < trackLen - sps * .99 ? tpost : trackLen - sps * .99);
1136  if (showIndividualSamples) {
1137  // adjustment so that the last circular point doesn't appear
1138  // to be hanging off the end
1139  t1 += 2. / (averagePixelsPerSample * rate);
1140  }
1141 
1142  // Make sure t1 (the right bound) is greater than 0
1143  if (t1 < 0.0) {
1144  t1 = 0.0;
1145  }
1146 
1147  // Make sure t1 is greater than t0
1148  if (t0 > t1) {
1149  t0 = t1;
1150  }
1151 
1152  // Use the WaveTrack method to show what is selected and 'should' be copied, pasted etc.
1153  ssel0 = std::max(sampleCount(0), spectrum
1154  ? sampleCount((sel0 - tOffset) * rate + .99) // PRL: why?
1155  : track->TimeToLongSamples(sel0 - tOffset)
1156  );
1157  ssel1 = std::max(sampleCount(0), spectrum
1158  ? sampleCount((sel1 - tOffset) * rate + .99) // PRL: why?
1159  : track->TimeToLongSamples(sel1 - tOffset)
1160  );
1161 
1162  //trim selection so that it only contains the actual samples
1163  if (ssel0 != ssel1 && ssel1 > (sampleCount)(0.5 + trackLen * rate)) {
1164  ssel1 = sampleCount( 0.5 + trackLen * rate );
1165  }
1166 
1167  // The variable "hiddenMid" will be the rectangle containing the
1168  // actual waveform, as opposed to any blank area before
1169  // or after the track, as it would appear without the fisheye.
1170  hiddenMid = rect;
1171 
1172  // If the left edge of the track is to the right of the left
1173  // edge of the display, then there's some unused area to the
1174  // left of the track. Reduce the "hiddenMid"
1175  hiddenLeftOffset = 0;
1176  if (tpre < 0) {
1177  // Fix Bug #1296 caused by premature conversion to (int).
1178  wxInt64 time64 = zoomInfo.TimeToPosition(tOffset, 0 , true);
1179  if( time64 < 0 )
1180  time64 = 0;
1181  hiddenLeftOffset = (time64 < rect.width) ? (int)time64 : rect.width;
1182 
1184  hiddenMid.width -= hiddenLeftOffset;
1185  }
1186 
1187  // If the right edge of the track is to the left of the right
1188  // edge of the display, then there's some unused area to the right
1189  // of the track. Reduce the "hiddenMid" rect by the
1190  // size of the blank area.
1191  if (tpost > t1) {
1192  wxInt64 time64 = zoomInfo.TimeToPosition(tOffset+t1, 0 , true);
1193  if( time64 < 0 )
1194  time64 = 0;
1195  const int hiddenRightOffset = (time64 < rect.width) ? (int)time64 : rect.width;
1196 
1197  hiddenMid.width = std::max(0, hiddenRightOffset - hiddenLeftOffset);
1198  }
1199  // The variable "mid" will be the rectangle containing the
1200  // actual waveform, as distorted by the fisheye,
1201  // as opposed to any blank area before or after the track.
1202  mid = rect;
1203 
1204  // If the left edge of the track is to the right of the left
1205  // edge of the display, then there's some unused area to the
1206  // left of the track. Reduce the "mid"
1207  leftOffset = 0;
1208  if (tpre < 0) {
1209  wxInt64 time64 = zoomInfo.TimeToPosition(tOffset, 0 , false);
1210  if( time64 < 0 )
1211  time64 = 0;
1212  leftOffset = (time64 < rect.width) ? (int)time64 : rect.width;
1213 
1214  mid.x += leftOffset;
1215  mid.width -= leftOffset;
1216  }
1217 
1218  // If the right edge of the track is to the left of the right
1219  // edge of the display, then there's some unused area to the right
1220  // of the track. Reduce the "mid" rect by the
1221  // size of the blank area.
1222  if (tpost > t1) {
1223  wxInt64 time64 = zoomInfo.TimeToPosition(tOffset+t1, 0 , false);
1224  if( time64 < 0 )
1225  time64 = 0;
1226  const int distortedRightOffset = (time64 < rect.width) ? (int)time64 : rect.width;
1227 
1228  mid.width = std::max(0, distortedRightOffset - leftOffset);
1229  }
1230 }

References averagePixelsPerSample, WaveClip::GetEndTime(), WaveClip::GetOffset(), WaveClip::GetRate(), Track::GetSelected(), WaveClip::GetStartTime(), h, h1, hiddenLeftOffset, hiddenMid, Track::IsSyncLockSelected(), leftOffset, mid, ZoomInfo::PositionToTime(), rate, showIndividualSamples, ssel0, ssel1, SelectedRegion::t0(), t0, SelectedRegion::t1(), t1, WaveTrack::TimeToLongSamples(), ZoomInfo::TimeToPosition(), tOffset, tpost, and tpre.

Here is the call graph for this function:

Member Function Documentation

◆ DrawClipEdges()

void ClipParameters::DrawClipEdges ( wxDC &  dc,
const wxRect &  rect 
) const

Definition at line 1232 of file WaveTrackView.cpp.

1233 {
1234  // Draw clip edges
1235  dc.SetPen(*wxGREY_PEN);
1236  if (tpre < 0) {
1237  AColor::Line(dc,
1238  mid.x - 1, mid.y,
1239  mid.x - 1, mid.y + rect.height);
1240  }
1241  if (tpost > t1) {
1242  AColor::Line(dc,
1243  mid.x + mid.width, mid.y,
1244  mid.x + mid.width, mid.y + rect.height);
1245  }
1246 }

References AColor::Line(), mid, t1, tpost, and tpre.

Here is the call graph for this function:

Member Data Documentation

◆ averagePixelsPerSample

double ClipParameters::averagePixelsPerSample

Definition at line 179 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ h

double ClipParameters::h

Definition at line 169 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ h1

double ClipParameters::h1

Definition at line 171 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ hiddenLeftOffset

int ClipParameters::hiddenLeftOffset

Definition at line 186 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ hiddenMid

wxRect ClipParameters::hiddenMid

Definition at line 185 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ leftOffset

int ClipParameters::leftOffset

Definition at line 189 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ mid

wxRect ClipParameters::mid

Definition at line 188 of file WaveTrackView.h.

Referenced by ClipParameters(), and DrawClipEdges().

◆ rate

double ClipParameters::rate

Definition at line 168 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ showIndividualSamples

bool ClipParameters::showIndividualSamples

Definition at line 180 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ ssel0

sampleCount ClipParameters::ssel0

Definition at line 182 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ ssel1

sampleCount ClipParameters::ssel1

Definition at line 183 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ t0

double ClipParameters::t0

Definition at line 176 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ t1

double ClipParameters::t1

Definition at line 177 of file WaveTrackView.h.

Referenced by ClipParameters(), and DrawClipEdges().

◆ tOffset

double ClipParameters::tOffset

Definition at line 167 of file WaveTrackView.h.

Referenced by ClipParameters().

◆ tpost

double ClipParameters::tpost

Definition at line 172 of file WaveTrackView.h.

Referenced by ClipParameters(), and DrawClipEdges().

◆ tpre

double ClipParameters::tpre

Definition at line 170 of file WaveTrackView.h.

Referenced by ClipParameters(), and DrawClipEdges().


The documentation for this struct was generated from the following files:
ClipParameters::tpost
double tpost
Definition: WaveTrackView.h:172
ClipParameters::rate
double rate
Definition: WaveTrackView.h:168
ClipParameters::averagePixelsPerSample
double averagePixelsPerSample
Definition: WaveTrackView.h:179
SelectedRegion::t1
double t1() const
Definition: SelectedRegion.h:95
WaveClip::GetOffset
double GetOffset() const
Definition: WaveClip.h:219
WaveClip::GetRate
int GetRate() const
Definition: WaveClip.h:207
AColor::Line
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:112
WaveClip::GetEndTime
double GetEndTime() const
Definition: WaveClip.cpp:253
ClipParameters::h
double h
Definition: WaveTrackView.h:169
ClipParameters::hiddenLeftOffset
int hiddenLeftOffset
Definition: WaveTrackView.h:186
Track::IsSyncLockSelected
bool IsSyncLockSelected() const
Definition: Track.cpp:245
ZoomInfo::TimeToPosition
wxInt64 TimeToPosition(double time, wxInt64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ZoomInfo.cpp:53
ClipParameters::ssel0
sampleCount ssel0
Definition: WaveTrackView.h:182
WaveClip::GetStartTime
double GetStartTime() const
Definition: WaveClip.cpp:247
ClipParameters::hiddenMid
wxRect hiddenMid
Definition: WaveTrackView.h:185
ClipParameters::showIndividualSamples
bool showIndividualSamples
Definition: WaveTrackView.h:180
ClipParameters::ssel1
sampleCount ssel1
Definition: WaveTrackView.h:183
ClipParameters::tOffset
double tOffset
Definition: WaveTrackView.h:167
ClipParameters::t0
double t0
Definition: WaveTrackView.h:176
Track::GetSelected
bool GetSelected() const
Definition: Track.h:414
ClipParameters::leftOffset
int leftOffset
Definition: WaveTrackView.h:189
SelectedRegion::t0
double t0() const
Definition: SelectedRegion.h:94
WaveTrack::TimeToLongSamples
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1772
sampleCount
Definition: Types.h:66
ClipParameters::h1
double h1
Definition: WaveTrackView.h:171
ClipParameters::mid
wxRect mid
Definition: WaveTrackView.h:188
ClipParameters::t1
double t1
Definition: WaveTrackView.h:177
ClipParameters::tpre
double tpre
Definition: WaveTrackView.h:170
ZoomInfo::PositionToTime
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:43