svcore  1.9
Pitch.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _PITCH_H_
17 #define _PITCH_H_
18 
19 #include <QString>
20 
21 class Pitch
22 {
23 public:
33  static float getFrequencyForPitch(int midiPitch,
34  float centsOffset = 0,
35  float concertA = 0.0);
36 
49  static int getPitchForFrequency(float frequency,
50  float *centsOffsetReturn = 0,
51  float concertA = 0.0);
52 
67  static int getPitchForFrequencyDifference(float frequencyA,
68  float frequencyB,
69  float *centsOffsetReturn = 0,
70  float concertA = 0.0);
71 
85  static QString getPitchLabel(int midiPitch,
86  float centsOffset = 0,
87  bool useFlats = false);
88 
100  static QString getPitchLabelForFrequency(float frequency,
101  float concertA = 0.0,
102  bool useFlats = false);
103 
108  static QString getLabelForPitchRange(int semis, float cents = 0);
109 
121  static bool isFrequencyInMidiRange(float frequency,
122  float concertA = 0.0);
123 };
124 
125 
126 #endif
static QString getPitchLabelForFrequency(float frequency, float concertA=0.0, bool useFlats=false)
Return a string describing the nearest MIDI pitch to the given frequency, with cents offset.
Definition: Pitch.cpp:130
static QString getPitchLabel(int midiPitch, float centsOffset=0, bool useFlats=false)
Return a string describing the given MIDI pitch, with optional cents offset.
Definition: Pitch.cpp:100
static int getPitchForFrequency(float frequency, float *centsOffsetReturn=0, float concertA=0.0)
Return the nearest MIDI pitch to the given frequency.
Definition: Pitch.cpp:35
static int getPitchForFrequencyDifference(float frequencyA, float frequencyB, float *centsOffsetReturn=0, float concertA=0.0)
Return the nearest MIDI pitch range to the given frequency range, that is, the difference in MIDI pit...
Definition: Pitch.cpp:57
static QString getLabelForPitchRange(int semis, float cents=0)
Return a string describing the given pitch range in octaves, semitones and cents.
Definition: Pitch.cpp:143
static float getFrequencyForPitch(int midiPitch, float centsOffset=0, float concertA=0.0)
Return the frequency at the given MIDI pitch plus centsOffset cents (1/100ths of a semitone).
Definition: Pitch.cpp:23
Definition: Pitch.h:21
static bool isFrequencyInMidiRange(float frequency, float concertA=0.0)
Return true if the given frequency falls within the range of MIDI note pitches, plus or minus half a ...
Definition: Pitch.cpp:184