Ardour  9.2-541-gc1841a13dd
chord_provider.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2026 Paul Davis <paul@linuxaudiosystems.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #pragma once
20 
21 #include <vector>
22 #include <string>
23 #include <map>
24 
25 namespace ARDOUR {
26 
27 class ScaleProvider;
28 
30 {
31  public:
33  virtual ~ChordProvider() {}
34 
35  typedef std::vector<int> Intervals;
36 
37  virtual bool get_midi_chord (int root_pitch, Intervals& pitches) const = 0;
38 
39  /* maps a hash of Intervals to a name */
40  typedef std::map<int64_t, std::string> IntervalsToChordName;
42 
43  /* maps (potentiall multiple) names to Intervals */
44  typedef std::map<std::string,Intervals> ChordNameToIntervals;
46 
47  static void build_12tet_chords ();
48  template<typename...Names> static void register_12tet_chord (Intervals const & intervals, std::string const & canonical_name, Names...chord_names);
49 
50  std::string identify_chord (Intervals const &);
51 
53  Unison = 0,
59  Tritone = 6,
66 
67  /* aliases set #1 */
68 
83 
84  /* aliases set two */
85 
92 
93  /* aliases set three */
94 
98 
99  /* aliases set four */
100 
101  MajorNinth = 14, // Octave + 2
102  M9 = 14,
104  P11 = 17,
105  MajorThirteenth = 21, // Octave + 9
106  M13 = 21,
107 
108  };
109 };
110 
111 }
static void build_12tet_chords()
std::map< std::string, Intervals > ChordNameToIntervals
static IntervalsToChordName tet12_names
std::string identify_chord(Intervals const &)
static ChordNameToIntervals tet12_chords
std::map< int64_t, std::string > IntervalsToChordName
std::vector< int > Intervals
virtual bool get_midi_chord(int root_pitch, Intervals &pitches) const =0
static void register_12tet_chord(Intervals const &intervals, std::string const &canonical_name, Names...chord_names)