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 250 of file NoteTrack.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
MinPitchHeight 
MaxPitchHeight 

Definition at line 259 of file NoteTrack.h.

Constructor & Destructor Documentation

◆ NoteTrackDisplayData()

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

Definition at line 1118 of file NoteTrack.cpp.

1119{
1120 auto span = track->GetTopNote() - track->GetBottomNote() + 1; // + 1 to make sure it includes both
1121
1122 mMargin = std::min((int) (r.height / (float)(span)) / 2, r.height / 4);
1123
1124 // Count the number of dividers between B/C and E/F
1125 int numC = 0, numF = 0;
1126 auto botOctave = track->GetBottomNote() / 12, botNote = track->GetBottomNote() % 12;
1127 auto topOctave = track->GetTopNote() / 12, topNote = track->GetTopNote() % 12;
1128 if (topOctave == botOctave)
1129 {
1130 if (botNote == 0) numC = 1;
1131 if (topNote <= 5) numF = 1;
1132 }
1133 else
1134 {
1135 numC = topOctave - botOctave;
1136 numF = topOctave - botOctave - 1;
1137 if (botNote == 0) numC++;
1138 if (botNote <= 5) numF++;
1139 if (topOctave <= 5) numF++;
1140 }
1141 // Effective space, excluding the margins and the lines between some notes
1142 auto effectiveHeight = r.height - (2 * (mMargin + 1)) - numC - numF;
1143 // Guaranteed that both the bottom and top notes will be visible
1144 // (assuming that the clamping below does not happen)
1145 mPitchHeight = effectiveHeight / ((float) span);
1146
1151
1152 mBottom = r.y + r.height - GetNoteMargin() - 1 - GetPitchHeight(1) +
1153 botOctave * GetOctaveHeight() + GetNotePos(botNote);
1154}
int min(int a, int b)
int GetPitchHeight(int factor) const
Definition: NoteTrack.h:263
int GetNotePos(int p) const
Definition: NoteTrack.h:283
int GetOctaveHeight() const
Definition: NoteTrack.h:266
int GetNoteMargin() const
Definition: NoteTrack.h:265
int GetBottomNote() const
Gets the current bottom note (a pitch)
Definition: NoteTrack.h:122
int GetTopNote() const
Gets the current top note (a pitch)
Definition: NoteTrack.h:124

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 286 of file NoteTrack.h.

286{ 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 265 of file NoteTrack.h.

265{ 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 283 of file NoteTrack.h.

284 { 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 271 of file NoteTrack.h.

271 {
272 return IPitchToY(oct * 12) + GetPitchHeight(1) + 1;
273 }
int IPitchToY(int p) const
Definition: NoteTrack.cpp:1156

References GetPitchHeight(), and IPitchToY().

Here is the call graph for this function:

◆ GetOctaveHeight()

int NoteTrackDisplayData::GetOctaveHeight ( ) const
inline

Definition at line 266 of file NoteTrack.h.

266{ 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 263 of file NoteTrack.h.

264 { 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 290 of file NoteTrack.h.

290{ 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 1156 of file NoteTrack.cpp.

1157{ 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 275 of file NoteTrack.h.

275 {
276 return IPitchToY((int) (p + 0.5));
277 }

References IPitchToY().

Here is the call graph for this function:

◆ YToIPitch()

int NoteTrackDisplayData::YToIPitch ( int  y) const

Definition at line 1159 of file NoteTrack.cpp.

1160{
1161 y = mBottom - y; // pixels above pitch 0
1162 int octave = (y / GetOctaveHeight());
1163 y -= octave * GetOctaveHeight();
1164 // result is approximate because C and G are one pixel taller than
1165 // mPitchHeight.
1166 // Poke 1-13-18: However in practice this seems not to be an issue,
1167 // as long as we use mPitchHeight and not the rounded version
1168 return (y / mPitchHeight) + octave * 12;
1169}

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 256 of file NoteTrack.h.

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

◆ mMargin

int NoteTrackDisplayData::mMargin
private

Definition at line 257 of file NoteTrack.h.

Referenced by GetNoteMargin(), and NoteTrackDisplayData().

◆ mPitchHeight

float NoteTrackDisplayData::mPitchHeight
private

Definition at line 252 of file NoteTrack.h.

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


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