Music Notation
ci / checks (push) Successful in 43m19s

This commit is contained in:
khodowany
2026-09-15 01:30:42 -05:00
parent fe42d811fa
commit 1d1bd3e871
41 changed files with 1546 additions and 5236 deletions
+17 -94
View File
@@ -1,10 +1,9 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <limits>
#include <expected>
#include <functional>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include <luma.hpp>
@@ -14,98 +13,22 @@
namespace vamp_zero {
enum class score_accidental_mark {
NONE,
FLAT,
NATURAL,
SHARP,
DOUBLE_FLAT,
DOUBLE_SHARP,
TRIPLE_FLAT,
TRIPLE_SHARP,
class score_page_cache {
public:
explicit score_page_cache(std::function<std::expected<std::shared_ptr<luma::texture>, modulus::error>(std::string const &)> loader);
auto get(std::string path) -> std::expected<std::shared_ptr<luma::texture>, modulus::error>;
auto clear() -> void;
auto size() const -> std::size_t;
private:
struct entry {
std::string path{};
std::shared_ptr<luma::texture> texture{};
};
std::function<std::expected<std::shared_ptr<luma::texture>, modulus::error>(std::string const &)> loader_{};
std::vector<entry> entries_{};
};
enum class score_layout_item_kind {
FILL_RECT,
STROKE_RECT,
STROKE_LINE,
CURVE,
GLYPH,
TEXT,
};
enum class score_layout_item_role {
PAPER,
BORDER,
STAFF_LINE,
BARLINE,
FINAL_BARLINE,
CLEF,
KEY_SIGNATURE,
TIME_SIGNATURE,
NOTEHEAD,
REST,
ACCIDENTAL,
STEM,
FLAG,
BEAM,
DOT,
TIE,
TUPLET,
TUPLET_BRACKET,
OCTAVE_SHIFT,
TREMOLO,
TITLE,
COMPOSER,
PART,
PAGE_NUMBER,
MEASURE_NUMBER,
SECTION_LABEL,
CHORD_SYMBOL,
LYRIC,
};
struct score_layout_item {
vamp_zero::score_layout_item_kind kind{};
vamp_zero::score_layout_item_role role{};
luma::rect bounds{};
luma::point origin{};
luma::point from{};
luma::point control{};
luma::point to{};
luma::color color{};
std::float32_t thickness{};
std::float32_t staff_spacing{};
std::int32_t codepoint{};
std::int32_t text_scale{};
std::float32_t text_size_multiplier{1.0F};
std::size_t system_index{std::numeric_limits<std::size_t>::max()};
std::size_t measure_index{std::numeric_limits<std::size_t>::max()};
std::size_t note_index{std::numeric_limits<std::size_t>::max()};
std::string text{};
};
struct score_page_layout {
luma::rect bounds{};
std::float32_t staff_spacing{};
std::vector<vamp_zero::score_layout_item> items{};
};
struct score_system_range {
std::size_t first_measure{};
std::size_t measure_count{};
std::size_t first_note{};
std::size_t note_count{std::numeric_limits<std::size_t>::max()};
};
constexpr auto score_measures_per_system = std::size_t{4};
constexpr auto score_systems_per_page = std::size_t{3};
auto notated_accidentals_for_measure(vamp_zero::score_measure const &measure, std::string_view inherited_key_signature) -> std::vector<vamp_zero::score_accidental_mark>;
auto score_system_ranges(vamp_zero::score_document const &score) -> std::vector<vamp_zero::score_system_range>;
auto score_page_count(vamp_zero::score_document const &score) -> std::size_t;
auto layout_score_page(luma::rect bounds, vamp_zero::score_document const &score, std::size_t page_index) -> vamp_zero::score_page_layout;
auto draw_score_layout(luma::draw_context &context, vamp_zero::score_page_layout const &layout) -> void;
auto draw_score_page(luma::draw_context &context, luma::rect bounds, vamp_zero::score_document const &score, std::size_t page_index) -> void;
auto validated_page_path(vamp_zero::score_document const &score, std::size_t index) -> std::expected<std::string, modulus::error>;
}