mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
return pitch names as TranslatableString
This commit is contained in:
parent
a325247525
commit
86e9288bbd
@ -949,35 +949,32 @@ void FrequencyPlotDialog::PlotPaint(wxPaintEvent & event)
|
||||
value = mAnalyst->GetProcessedValue(xPos, xPos + xStep);
|
||||
}
|
||||
|
||||
wxString cursor;
|
||||
wxString peak;
|
||||
wxString xpitch;
|
||||
wxString peakpitch;
|
||||
const wxChar *xp;
|
||||
const wxChar *pp;
|
||||
TranslatableString cursor;
|
||||
TranslatableString peak;
|
||||
|
||||
if (mAlg == SpectrumAnalyst::Spectrum) {
|
||||
xpitch = PitchName_Absolute(FreqToMIDInote(xPos));
|
||||
peakpitch = PitchName_Absolute(FreqToMIDInote(bestpeak));
|
||||
xp = xpitch;
|
||||
pp = peakpitch;
|
||||
auto xp = PitchName_Absolute(FreqToMIDInote(xPos));
|
||||
auto pp = PitchName_Absolute(FreqToMIDInote(bestpeak));
|
||||
/* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#*/
|
||||
cursor.Printf(_("%d Hz (%s) = %d dB"), (int)(xPos + 0.5), xp, (int)(value + 0.5));
|
||||
peak.Printf(_("%d Hz (%s) = %.1f dB"), (int)(bestpeak + 0.5), pp, bestValue);
|
||||
cursor = XO("%d Hz (%s) = %d dB")
|
||||
.Format( (int)(xPos + 0.5), xp, (int)(value + 0.5));
|
||||
/* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#*/
|
||||
peak = XO("%d Hz (%s) = %.1f dB")
|
||||
.Format( (int)(bestpeak + 0.5), pp, bestValue );
|
||||
} else if (xPos > 0.0 && bestpeak > 0.0) {
|
||||
xpitch = PitchName_Absolute(FreqToMIDInote(1.0 / xPos));
|
||||
peakpitch = PitchName_Absolute(FreqToMIDInote(1.0 / bestpeak));
|
||||
xp = xpitch;
|
||||
pp = peakpitch;
|
||||
auto xp = PitchName_Absolute(FreqToMIDInote(1.0 / xPos));
|
||||
auto pp = PitchName_Absolute(FreqToMIDInote(1.0 / bestpeak));
|
||||
/* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#
|
||||
* the %.4f are numbers, and 'sec' should be an abbreviation for seconds */
|
||||
cursor.Printf(_("%.4f sec (%d Hz) (%s) = %f"),
|
||||
xPos, (int)(1.0 / xPos + 0.5), xp, value);
|
||||
peak.Printf(_("%.4f sec (%d Hz) (%s) = %.3f"),
|
||||
bestpeak, (int)(1.0 / bestpeak + 0.5), pp, bestValue);
|
||||
cursor = XO("%.4f sec (%d Hz) (%s) = %f")
|
||||
.Format( xPos, (int)(1.0 / xPos + 0.5), xp, value );
|
||||
/* i18n-hint: The %d's are replaced by numbers, the %s by musical notes, e.g. A#
|
||||
* the %.4f are numbers, and 'sec' should be an abbreviation for seconds */
|
||||
peak = XO("%.4f sec (%d Hz) (%s) = %.3f")
|
||||
.Format( bestpeak, (int)(1.0 / bestpeak + 0.5), pp, bestValue );
|
||||
}
|
||||
mCursorText->SetValue(cursor);
|
||||
mPeakText->SetValue(peak);
|
||||
mCursorText->SetValue( cursor.Translation() );
|
||||
mPeakText->SetValue( peak.Translation() );
|
||||
}
|
||||
else {
|
||||
mCursorText->SetValue(wxT(""));
|
||||
|
@ -57,7 +57,7 @@ int PitchOctave(const double dMIDInote)
|
||||
}
|
||||
|
||||
|
||||
wxString PitchName(const double dMIDInote, const PitchNameChoice choice)
|
||||
TranslatableString PitchName(const double dMIDInote, const PitchNameChoice choice)
|
||||
{
|
||||
static const TranslatableString sharpnames[12] = {
|
||||
/* i18n-hint: Name of a musical note in the 12-tone chromatic scale */
|
||||
@ -148,14 +148,14 @@ wxString PitchName(const double dMIDInote, const PitchNameChoice choice)
|
||||
default: wxASSERT(false); break;
|
||||
}
|
||||
|
||||
return table[PitchIndex(dMIDInote)].Translation();
|
||||
return table[PitchIndex(dMIDInote)];
|
||||
}
|
||||
|
||||
wxString PitchName_Absolute(const double dMIDInote, const PitchNameChoice choice)
|
||||
TranslatableString PitchName_Absolute(const double dMIDInote, const PitchNameChoice choice)
|
||||
{
|
||||
// The format string is not localized. Should it be?
|
||||
return wxString::Format(
|
||||
wxT("%s%d"), PitchName(dMIDInote, choice), PitchOctave(dMIDInote) );
|
||||
return Verbatim( wxT("%s%d") )
|
||||
.Format( PitchName(dMIDInote, choice), PitchOctave(dMIDInote) );
|
||||
}
|
||||
|
||||
double PitchToMIDInote(const unsigned int nPitchIndex, const int nPitchOctave)
|
||||
|
@ -18,7 +18,7 @@
|
||||
#ifndef __AUDACITY_PITCHNAME__
|
||||
#define __AUDACITY_PITCHNAME__
|
||||
|
||||
class wxString;
|
||||
class TranslatableString;
|
||||
|
||||
// FreqToMIDInote takes a frequency in Hz (exponential scale relative to
|
||||
// alphabetic pitch names) and returns a pitch ID number (linear
|
||||
@ -44,14 +44,14 @@ enum class PitchNameChoice { Sharps, Flats, Both };
|
||||
|
||||
// PitchName takes dMIDInote (per result from
|
||||
// FreqToMIDInote) and returns a standard pitch/note name [C, C#, etc.).
|
||||
wxString PitchName(
|
||||
TranslatableString PitchName(
|
||||
const double dMIDInote,
|
||||
const PitchNameChoice choice = PitchNameChoice::Sharps );
|
||||
|
||||
// PitchName_Absolute does the same thing as PitchName, but appends
|
||||
// the octave number, e.g., instead of "C" it will return "C4"
|
||||
// if the dMIDInote corresonds to middle C, i.e., is 60.
|
||||
wxString PitchName_Absolute(
|
||||
TranslatableString PitchName_Absolute(
|
||||
const double dMIDInote,
|
||||
const PitchNameChoice choice = PitchNameChoice::Sharps);
|
||||
|
||||
|
@ -255,7 +255,7 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S)
|
||||
|
||||
wxArrayStringEx pitch;
|
||||
for (int ii = 0; ii < 12; ++ii)
|
||||
pitch.push_back( PitchName( ii, PitchNameChoice::Both ) );
|
||||
pitch.push_back( PitchName( ii, PitchNameChoice::Both ).Translation() );
|
||||
|
||||
S.SetBorder(5);
|
||||
|
||||
@ -265,8 +265,9 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
S.AddTitle(_("Change Pitch without Changing Tempo"));
|
||||
S.AddTitle(
|
||||
wxString::Format(_("Estimated Start Pitch: %s%d (%.3f Hz)"),
|
||||
pitch[m_nFromPitch], m_nFromOctave, m_FromFrequency));
|
||||
XO("Estimated Start Pitch: %s%d (%.3f Hz)")
|
||||
.Format( pitch[m_nFromPitch], m_nFromOctave, m_FromFrequency)
|
||||
.Translation() );
|
||||
}
|
||||
S.EndVerticalLay();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user