Ardour  9.2-654-gd2ed0bd940
ardour/ardour/scale.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 <string>
22 #include <vector>
23 
24 #include "pbd/signals.h"
25 
27 
28 namespace ARDOUR {
29 
37 };
38 
46  China
47 };
48 
50  public:
51 
52  enum Name {
89  Algerian
90  };
91 
92  MusicalMode (std::string const & name, MusicalModeType type, std::vector<float> const & elements);
93  MusicalMode (MusicalMode const & other);
95  MusicalMode (std::ifstream& file); /* Read from a Scala file */
96 
97  MusicalMode operator= (MusicalMode const & other);
98 
99  std::string name() const { return _name; }
100  MusicalModeType type() const { return _type; }
101  int size() const { return _elements.size(); }
102  std::vector<float> const & elements() const { return _elements; }
103 
104  std::vector<float> pitches_from_root (float root, int steps) const;
105  std::vector<int> as_midi (int scale_root) const;
106  void set_name (std::string const & str);
107 
110 
111  protected:
112  std::string _name;
114  std::vector<float> _elements;
115 
116  void fill (Name);
117 
118  std::vector<float> absolute_pitch_pitches_from_root (float root, int steps) const;
119  std::vector<float> semitone_steps_pitches_from_root (float root, int steps) const;
120  std::vector<float> wholetone_steps_pitches_from_root (float root, int steps) const;
121  std::vector<float> ratio_steps_pitches_from_root (float root, int steps) const;
122  std::vector<float> ratio_from_root_pitches_from_root (float root, int steps) const;
123  std::vector<float> midi_note_pitches_from_root (float root, int steps) const;
124 
125  std::vector<int> absolute_pitch_as_midi (int root) const;
126  std::vector<int> semitone_steps_as_midi (int root) const;
127  std::vector<int> wholetone_steps_as_midi (int root) const;
128  std::vector<int> ratio_steps_as_midi (int root) const;
129  std::vector<int> ratio_from_root_as_midi (int root) const;
130  std::vector<int> midi_note_as_midi (int root) const;
131 };
132 
133 
135 {
136  public:
137  MusicalKey (float root, MusicalMode const &);
138  MusicalKey (MusicalKey const & other);
139 
140  MusicalKey operator= (MusicalKey const & other);
141 
142  float root() const { return _root; }
143  float nth (int n) const;
144 
145  private:
146  float _root;
147 
148 };
149 
150 } // namespace
float nth(int n) const
MusicalKey(MusicalKey const &other)
MusicalKey(float root, MusicalMode const &)
MusicalMode(std::ifstream &file)
std::vector< int > ratio_steps_as_midi(int root) const
std::vector< float > pitches_from_root(float root, int steps) const
std::vector< int > semitone_steps_as_midi(int root) const
std::vector< float > wholetone_steps_pitches_from_root(float root, int steps) const
PBD::Signal< void()> NameChanged
void set_name(std::string const &str)
std::vector< float > ratio_from_root_pitches_from_root(float root, int steps) const
MusicalModeType type() const
std::vector< float > midi_note_pitches_from_root(float root, int steps) const
std::vector< float > const & elements() const
std::vector< int > absolute_pitch_as_midi(int root) const
std::vector< float > _elements
PBD::Signal< void()> Changed
std::string name() const
std::vector< int > as_midi(int scale_root) const
std::vector< int > wholetone_steps_as_midi(int root) const
std::vector< int > midi_note_as_midi(int root) const
MusicalMode(std::string const &name, MusicalModeType type, std::vector< float > const &elements)
MusicalMode(MusicalMode const &other)
MusicalMode(MusicalMode::Name)
std::vector< float > absolute_pitch_pitches_from_root(float root, int steps) const
std::vector< float > ratio_steps_pitches_from_root(float root, int steps) const
std::vector< int > ratio_from_root_as_midi(int root) const
std::vector< float > semitone_steps_pitches_from_root(float root, int steps) const
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API