comparison base/Pitch.h @ 373:0a44caddd9fe

* Add pitch range in octaves, semitones and cents to the measurement rect as well as in Hz * Avoid crash when adding time ruler This commit contains a lot of debug output (will be slow)
author Chris Cannam
date Wed, 06 Feb 2008 16:21:29 +0000
parents e412f65884ee
children 451f7f3ab6e7
comparison
equal deleted inserted replaced
372:d31b4ccb7ddb 373:0a44caddd9fe
49 static int getPitchForFrequency(float frequency, 49 static int getPitchForFrequency(float frequency,
50 float *centsOffsetReturn = 0, 50 float *centsOffsetReturn = 0,
51 float concertA = 0.0); 51 float concertA = 0.0);
52 52
53 /** 53 /**
54 * Return the nearest MIDI pitch range to the given frequency
55 * range, that is, the difference in MIDI pitch values between the
56 * higher and lower frequencies.
57 *
58 * If centsOffsetReturn is non-NULL, return in *centsOffsetReturn
59 * the number of cents (1/100ths of a semitone) difference between
60 * the given frequency difference and the returned MIDI pitch
61 * range. The cents offset will be in the range [-50,50).
62 *
63 * If concertA is non-zero, use that as the reference frequency
64 * for the A at MIDI pitch 69; otherwise use the tuning frequency
65 * specified in the application preferences (default 440Hz).
66 */
67 static int getPitchForFrequencyDifference(float frequencyA,
68 float frequencyB,
69 float *centsOffsetReturn = 0,
70 float concertA = 0.0);
71
72 /**
54 * Return a string describing the given MIDI pitch, with optional 73 * Return a string describing the given MIDI pitch, with optional
55 * cents offset. This consists of the note name, octave number 74 * cents offset. This consists of the note name, octave number
56 * (with MIDI pitch 0 having octave number -2), and optional 75 * (with MIDI pitch 0 having octave number -2), and optional
57 * cents. 76 * cents.
58 * 77 *
80 static QString getPitchLabelForFrequency(float frequency, 99 static QString getPitchLabelForFrequency(float frequency,
81 float concertA = 0.0, 100 float concertA = 0.0,
82 bool useFlats = false); 101 bool useFlats = false);
83 102
84 /** 103 /**
104 * Return a string describing the given pitch range in octaves,
105 * semitones and cents. This is in the form e.g. "1'2+4c".
106 */
107 static QString getLabelForPitchRange(int semis, float cents = 0);
108
109 /**
85 * Return true if the given frequency falls within the range of 110 * Return true if the given frequency falls within the range of
86 * MIDI note pitches, plus or minus half a semitone. This is 111 * MIDI note pitches, plus or minus half a semitone. This is
87 * equivalent to testing whether getPitchForFrequency returns a 112 * equivalent to testing whether getPitchForFrequency returns a
88 * pitch in the MIDI range (0 to 127 inclusive) with any cents 113 * pitch in the MIDI range (0 to 127 inclusive) with any cents
89 * offset. 114 * offset.