13using json = nlohmann::json;
158 if (mapping_name_.empty())
160 if (tuning_name_.empty())
161 return mapping_name_;
162 return tuning_name_ +
" / " + mapping_name_;
171 mapping_name_.clear();
207 void loadKeyboardMapFile(File kbm_file);
208 void loadTunFile(File tun_file);
210 int scale_start_midi_note_;
211 float reference_midi_note_;
212 std::vector<float> scale_;
213 std::vector<int> keyboard_mapping_;
215 std::string tuning_name_;
216 std::string mapping_name_;
219 JUCE_LEAK_DETECTOR(
Tuning)
A class for managing microtonal tunings and custom pitch mappings in Vital.
Definition tuning.h:23
Tuning()
Constructs a Tuning object representing default (12-tone equal temperament) tuning.
Definition tuning.cpp:305
void setName(const std::string &name)
Sets a custom name for the current tuning, clearing any mapping name.
Definition tuning.h:170
void setReferenceNoteFrequency(int midi_note, float frequency)
Sets the reference note and frequency pair.
Definition tuning.cpp:379
static constexpr int kTuningCenter
The center index of the tuning table.
Definition tuning.h:38
void setReferenceRatio(float ratio)
Sets the reference ratio, defining a pitch offset in ratio form.
Definition tuning.cpp:383
static String allFileExtensions()
Returns a string listing all supported tuning file extensions.
Definition tuning.cpp:93
void setReferenceNote(int reference_note)
Sets the reference MIDI note number around which the tuning is centered.
Definition tuning.h:128
void setStartMidiNote(int start_midi_note)
Sets the starting MIDI note for the scale mapping.
Definition tuning.h:121
static constexpr int kTuningSize
The total size of the internal tuning table.
Definition tuning.h:31
void setConstantTuning(float note)
Sets a constant tuning, making all notes map to the same pitch offset.
Definition tuning.cpp:349
json stateToJson() const
Saves the current tuning state into a JSON object.
Definition tuning.cpp:387
void loadScalaFile(const StringArray &scala_lines)
Loads a Scala (.scl) file from a set of lines.
Definition tuning.cpp:160
static int noteToMidiKey(const String ¬e)
Converts a note name (e.g. "A4") to a MIDI key number.
Definition tuning.cpp:99
void loadFile(File file)
Loads a tuning from a given file, automatically detecting its format (.scl, .kbm, ....
Definition tuning.cpp:147
static Tuning getTuningForFile(File file)
Creates a Tuning object from a given file.
Definition tuning.cpp:143
void loadScale(std::vector< float > scale)
Loads a custom scale from a vector of offsets, specified in semitones or transposition units.
Definition tuning.cpp:316
std::string getName() const
Gets the name of the current tuning, combining tuning and mapping names if both exist.
Definition tuning.h:157
void setDefaultTuning()
Resets the tuning to the default 12-tone equal temperament with a standard reference pitch.
Definition tuning.cpp:354
vital::mono_float convertMidiNote(int note) const
Converts a MIDI note number to a pitch offset based on the current tuning.
Definition tuning.cpp:370
void setReferenceFrequency(float frequency)
Sets the reference frequency used for calculating pitches.
Definition tuning.cpp:375
bool isDefault() const
Checks if the tuning is the default equal temperament.
Definition tuning.h:180
void jsonToState(const json &data)
Restores the tuning state from a JSON object.
Definition tuning.cpp:410
nlohmann::json json
Definition line_generator.h:7
constexpr int kMidiSize
MIDI note count (0-127).
Definition common.h:44
float mono_float
Definition common.h:33