Audacity 3.2.0
PitchName.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4 Audacity(R) is copyright (c) 1999-2013 Audacity Team.
5 License: GPL v2 or later. See License.txt.
6
7 PitchName.h
8 Vaughan Johnson, Dominic Mazzoni
9
10******************************************************************//*******************************************************************/
16
17
18#ifndef __AUDACITY_PITCHNAME__
19#define __AUDACITY_PITCHNAME__
20
22
23// FreqToMIDInote takes a frequency in Hz (exponential scale relative to
24// alphabetic pitch names) and returns a pitch ID number (linear
25// scale), such that A440 (A4) is 69, middle C (C4) is 60, etc.
26// Each register starts with C (e.g., for middle C and A440,
27// it's register 4).
28// MIDI note number 0 is C-1 in Scientific pitch notation.
29AUDACITY_DLL_API double FreqToMIDInote(const double freq);
30
31AUDACITY_DLL_API double MIDInoteToFreq(const double dMIDInote);
32
33// PitchIndex returns the [0,11] index for a double MIDI note number,
34// per result from FreqToMIDInote, corresponding to modulo 12
35// of the integer part of (dMIDInote + 0.5), so 0=C, 1=C#, etc.
36AUDACITY_DLL_API unsigned int PitchIndex(const double dMIDInote);
37
38// PitchOctave returns the octave index for a double dMIDInote note number,
39// per result from FreqToMIDInote.
40// MIDI note number 0 is C-1 in Scientific pitch notation.
41AUDACITY_DLL_API int PitchOctave(const double dMIDInote);
42
44
45// PitchName takes dMIDInote (per result from
46// FreqToMIDInote) and returns a standard pitch/note name [C, C#, etc.).
47AUDACITY_DLL_API TranslatableString PitchName(
48 const double dMIDInote,
50
51// PitchName_Absolute does the same thing as PitchName, but appends
52// the octave number, e.g., instead of "C" it will return "C4"
53// if the dMIDInote corresponds to middle C, i.e., is 60.
55 const double dMIDInote,
57
58AUDACITY_DLL_API
59double PitchToMIDInote(const unsigned int nPitchIndex, const int nPitchOctave);
60
61AUDACITY_DLL_API
62double PitchToFreq(const unsigned int nPitchIndex, const int nPitchOctave);
63
64#endif // __AUDACITY_PITCHNAME__
PitchNameChoice
Definition: PitchName.h:43
AUDACITY_DLL_API TranslatableString PitchName_Absolute(const double dMIDInote, const PitchNameChoice choice=PitchNameChoice::Sharps)
Definition: PitchName.cpp:153
AUDACITY_DLL_API double MIDInoteToFreq(const double dMIDInote)
Definition: PitchName.cpp:34
AUDACITY_DLL_API int PitchOctave(const double dMIDInote)
Definition: PitchName.cpp:52
AUDACITY_DLL_API TranslatableString PitchName(const double dMIDInote, const PitchNameChoice choice=PitchNameChoice::Sharps)
Definition: PitchName.cpp:59
AUDACITY_DLL_API double PitchToMIDInote(const unsigned int nPitchIndex, const int nPitchOctave)
Definition: PitchName.cpp:160
AUDACITY_DLL_API double FreqToMIDInote(const double freq)
Definition: PitchName.cpp:28
AUDACITY_DLL_API unsigned int PitchIndex(const double dMIDInote)
Definition: PitchName.cpp:39
AUDACITY_DLL_API double PitchToFreq(const unsigned int nPitchIndex, const int nPitchOctave)
Definition: PitchName.cpp:165
Holds a msgid for the translation catalog; may also bind format arguments.