Mercurial > hg > svcore
comparison base/Pitch.cpp @ 433:ad4911230a66
* When displaying an absolute pitch range (number of semitones + number
of cents) with a non-negative number of semitones, ensure that the
number of cents is also non-negative. e.g. prefer 1+76c over 2-24c.
In response to request from Craig Sapp
author | Chris Cannam |
---|---|
date | Wed, 02 Jul 2008 08:46:47 +0000 |
parents | 0a44caddd9fe |
children | bdc9bb371a9f |
comparison
equal
deleted
inserted
replaced
432:113cf8781bd1 | 433:ad4911230a66 |
---|---|
133 } | 133 } |
134 | 134 |
135 QString | 135 QString |
136 Pitch::getLabelForPitchRange(int semis, float cents) | 136 Pitch::getLabelForPitchRange(int semis, float cents) |
137 { | 137 { |
138 if (semis > 0) { | |
139 while (cents < 0.f) { | |
140 --semis; | |
141 cents += 100.f; | |
142 } | |
143 } | |
144 if (semis < 0) { | |
145 while (cents > 0.f) { | |
146 ++semis; | |
147 cents -= 100.f; | |
148 } | |
149 } | |
150 | |
138 int ic = lrintf(cents); | 151 int ic = lrintf(cents); |
139 | 152 |
140 if (ic == 0) { | 153 if (ic == 0) { |
141 if (semis >= 12) { | 154 if (semis >= 12) { |
142 return QString("%1'%2").arg(semis/12).arg(semis - 12*(semis/12)); | 155 return QString("%1'%2").arg(semis/12).arg(semis - 12*(semis/12)); |