Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
scala_tuning.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <filesystem>
6#include <memory>
7#include <string>
8#include <string_view>
9
10#ifndef PULP_HAS_SCALA_TUNING
11#define PULP_HAS_SCALA_TUNING 0
12#endif
13
14namespace pulp::midi {
15
16inline constexpr bool kHasScalaTuning = static_cast<bool>(PULP_HAS_SCALA_TUNING);
17
18#if PULP_HAS_SCALA_TUNING
19
20class ScalaTuningProvider final : public TuningProvider {
21public:
22 ScalaTuningProvider();
23 ~ScalaTuningProvider() override;
24
25 ScalaTuningProvider(const ScalaTuningProvider&) = delete;
26 ScalaTuningProvider& operator=(const ScalaTuningProvider&) = delete;
27
28 ScalaTuningProvider(ScalaTuningProvider&&) noexcept;
29 ScalaTuningProvider& operator=(ScalaTuningProvider&&) noexcept;
30
31 bool load_scl_file(const std::filesystem::path& path, std::string* error = nullptr);
32 bool load_kbm_file(const std::filesystem::path& path, std::string* error = nullptr);
33 bool load_scl_kbm_files(
34 const std::filesystem::path& scl_path,
35 const std::filesystem::path& kbm_path,
36 std::string* error = nullptr);
37
38 bool load_scl_data(std::string_view scl_data, std::string* error = nullptr);
39 bool load_kbm_data(std::string_view kbm_data, std::string* error = nullptr);
40 bool load_scl_kbm_data(
41 std::string_view scl_data,
42 std::string_view kbm_data,
43 std::string* error = nullptr);
44
45 bool tune_note_to(int midi_note, double frequency_hz, std::string* error = nullptr);
46 void reset_to_equal_temperament();
47
48 bool has_loaded_scale() const noexcept;
49 bool has_loaded_keyboard_mapping() const noexcept;
50
51 TuningQueryResult note_to_frequency(
52 int midi_note,
53 int midi_channel = kUnknownMidiChannel) const override;
54
55 TuningNoteResult frequency_to_note(
56 double frequency_hz,
57 int preferred_midi_channel = kUnknownMidiChannel) const override;
58
59 TuningNoteResult frequency_to_note_and_channel(double frequency_hz) const override;
60 TuningStatus status() const override;
61
62private:
63 struct Impl;
64 std::unique_ptr<Impl> impl_;
65};
66
67#endif // PULP_HAS_SCALA_TUNING
68
69} // namespace pulp::midi
Definition tuning.hpp:46
Definition custom_node_events.hpp:26
constexpr bool kHasScalaTuning
Definition scala_tuning.hpp:16
constexpr int kUnknownMidiChannel
Definition tuning.hpp:9
#define PULP_HAS_SCALA_TUNING
Definition scala_tuning.hpp:11
Definition tuning.hpp:26
Definition tuning.hpp:18
Definition tuning.hpp:32