Audacity 3.2.0
Public Member Functions | Private Types | Private Attributes | List of all members
NoteTrackDisplayData Class Reference

Data used to display a note track. More...

#include <NoteTrack.h>

Public Member Functions

 NoteTrackDisplayData (const NoteTrack *track, const wxRect &r)
 
int GetPitchHeight (int factor) const
 
int GetNoteMargin () const
 
int GetOctaveHeight () const
 
int IPitchToY (int p) const
 
int GetOctaveBottom (int oct) const
 
int PitchToY (double p) const
 
int YToIPitch (int y) const
 
int GetNotePos (int p) const
 
int GetBlackPos (int i) const
 
int GetWhitePos (int i) const
 

Private Types

enum  { MinPitchHeight = 1 , MaxPitchHeight = 25 }
 

Private Attributes

float mPitchHeight
 
int mBottom
 
int mMargin
 

Detailed Description

Data used to display a note track.

Definition at line 264 of file NoteTrack.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
MinPitchHeight 
MaxPitchHeight 

Definition at line 273 of file NoteTrack.h.

Constructor & Destructor Documentation

◆ NoteTrackDisplayData()

NoteTrackDisplayData::NoteTrackDisplayData ( const NoteTrack track,
const wxRect &  r 
)

Definition at line 1137 of file NoteTrack.cpp.

1138{
1139 auto span = track->GetTopNote() - track->GetBottomNote() + 1; // + 1 to make sure it includes both
1140
1141 mMargin = std::min((int) (r.height / (float)(span)) / 2, r.height / 4);
1142
1143 // Count the number of dividers between B/C and E/F
1144 int numC = 0, numF = 0;
1145 auto botOctave = track->GetBottomNote() / 12, botNote = track->GetBottomNote() % 12;
1146 auto topOctave = track->GetTopNote() / 12, topNote = track->GetTopNote() % 12;
1147 if (topOctave == botOctave)
1148 {
1149 if (botNote == 0) numC = 1;
1150 if (topNote <= 5) numF = 1;
1151 }
1152 else
1153 {
1154 numC = topOctave - botOctave;
1155 numF = topOctave - botOctave - 1;
1156 if (botNote == 0) numC++;
1157 if (botNote <= 5) numF++;
1158 if (topOctave <= 5) numF++;
1159 }
1160 // Effective space, excluding the margins and the lines between some notes
1161 auto effectiveHeight = r.height - (2 * (mMargin + 1)) - numC - numF;
1162 // Guaranteed that both the bottom and top notes will be visible
1163 // (assuming that the clamping below does not happen)
1164 mPitchHeight = effectiveHeight / ((float) span);
1165
1170
1171 mBottom = r.y + r.height - GetNoteMargin() - 1 - GetPitchHeight(1) +
1172 botOctave * GetOctaveHeight() + GetNotePos(botNote);
1173}
int min(int a, int b)
int GetPitchHeight(int factor) const
Definition: NoteTrack.h:277
int GetNotePos(int p) const
Definition: NoteTrack.h:297
int GetOctaveHeight() const
Definition: NoteTrack.h:280
int GetNoteMargin() const
Definition: NoteTrack.h:279
int GetBottomNote() const
Gets the current bottom note (a pitch)
Definition: NoteTrack.h:124
int GetTopNote() const
Gets the current top note (a pitch)
Definition: NoteTrack.h:126

References NoteTrack::GetBottomNote(), GetNoteMargin(), GetNotePos(), GetOctaveHeight(), GetPitchHeight(), NoteTrack::GetTopNote(), MaxPitchHeight, mBottom, min(), MinPitchHeight, mMargin, and mPitchHeight.

Here is the call graph for this function:

Member Function Documentation

◆ GetBlackPos()

int NoteTrackDisplayData::GetBlackPos ( int  i) const
inline

Definition at line 300 of file NoteTrack.h.

300{ return GetNotePos(i * 2 + 1 + (i > 1)); }

References GetNotePos().

Here is the call graph for this function:

◆ GetNoteMargin()

int NoteTrackDisplayData::GetNoteMargin ( ) const
inline

Definition at line 279 of file NoteTrack.h.

279{ return mMargin; };

References mMargin.

Referenced by NoteTrackDisplayData().

Here is the caller graph for this function:

◆ GetNotePos()

int NoteTrackDisplayData::GetNotePos ( int  p) const
inline

Definition at line 297 of file NoteTrack.h.

298 { return 1 + GetPitchHeight(p + 1) + (p > 4); }

References GetPitchHeight().

Referenced by GetBlackPos(), IPitchToY(), and NoteTrackDisplayData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetOctaveBottom()

int NoteTrackDisplayData::GetOctaveBottom ( int  oct) const
inline

Definition at line 285 of file NoteTrack.h.

285 {
286 return IPitchToY(oct * 12) + GetPitchHeight(1) + 1;
287 }
int IPitchToY(int p) const
Definition: NoteTrack.cpp:1175

References GetPitchHeight(), and IPitchToY().

Here is the call graph for this function:

◆ GetOctaveHeight()

int NoteTrackDisplayData::GetOctaveHeight ( ) const
inline

Definition at line 280 of file NoteTrack.h.

280{ return GetPitchHeight(12) + 2; }

References GetPitchHeight().

Referenced by GetWhitePos(), IPitchToY(), NoteTrackDisplayData(), and YToIPitch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPitchHeight()

int NoteTrackDisplayData::GetPitchHeight ( int  factor) const
inline

Definition at line 277 of file NoteTrack.h.

278 { return std::max(1, (int)(factor * mPitchHeight)); }

References mPitchHeight.

Referenced by GetNotePos(), GetOctaveBottom(), GetOctaveHeight(), and NoteTrackDisplayData().

Here is the caller graph for this function:

◆ GetWhitePos()

int NoteTrackDisplayData::GetWhitePos ( int  i) const
inline

Definition at line 304 of file NoteTrack.h.

304{ return 1 + (i * GetOctaveHeight()) / 7; }

References GetOctaveHeight().

Here is the call graph for this function:

◆ IPitchToY()

int NoteTrackDisplayData::IPitchToY ( int  p) const

Definition at line 1175 of file NoteTrack.cpp.

1176{ return mBottom - (p / 12) * GetOctaveHeight() - GetNotePos(p % 12); }

References GetNotePos(), GetOctaveHeight(), and mBottom.

Referenced by GetOctaveBottom(), and PitchToY().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PitchToY()

int NoteTrackDisplayData::PitchToY ( double  p) const
inline

Definition at line 289 of file NoteTrack.h.

289 {
290 return IPitchToY((int) (p + 0.5));
291 }

References IPitchToY().

Here is the call graph for this function:

◆ YToIPitch()

int NoteTrackDisplayData::YToIPitch ( int  y) const

Definition at line 1178 of file NoteTrack.cpp.

1179{
1180 y = mBottom - y; // pixels above pitch 0
1181 int octave = (y / GetOctaveHeight());
1182 y -= octave * GetOctaveHeight();
1183 // result is approximate because C and G are one pixel taller than
1184 // mPitchHeight.
1185 // Poke 1-13-18: However in practice this seems not to be an issue,
1186 // as long as we use mPitchHeight and not the rounded version
1187 return (y / mPitchHeight) + octave * 12;
1188}

References GetOctaveHeight(), mBottom, and mPitchHeight.

Referenced by NoteTrack::Zoom(), and NoteTrack::ZoomTo().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mBottom

int NoteTrackDisplayData::mBottom
private

Definition at line 270 of file NoteTrack.h.

Referenced by IPitchToY(), NoteTrackDisplayData(), and YToIPitch().

◆ mMargin

int NoteTrackDisplayData::mMargin
private

Definition at line 271 of file NoteTrack.h.

Referenced by GetNoteMargin(), and NoteTrackDisplayData().

◆ mPitchHeight

float NoteTrackDisplayData::mPitchHeight
private

Definition at line 266 of file NoteTrack.h.

Referenced by GetPitchHeight(), NoteTrackDisplayData(), and YToIPitch().


The documentation for this class was generated from the following files: