@@ -10,8 +10,6 @@
|
||||
namespace vamp_style {
|
||||
|
||||
constexpr auto ui_font_path = std::string_view{"/usr/share/product-vamp/fonts/petaluma/PetalumaScript.otf"};
|
||||
constexpr auto score_text_font_path = std::string_view{"/usr/share/product-vamp/fonts/petaluma/PetalumaScript.otf"};
|
||||
constexpr auto score_music_font_path = std::string_view{"/usr/share/product-vamp/fonts/petaluma/Petaluma.otf"};
|
||||
constexpr auto ui_font_height = std::int32_t{36};
|
||||
constexpr auto ui_font_max_width = std::int32_t{28};
|
||||
|
||||
|
||||
@@ -12,6 +12,5 @@
|
||||
namespace vamp_zero {
|
||||
|
||||
auto parse_notation_document(std::string_view json, std::string source_path) -> std::expected<score_document, modulus::error>;
|
||||
auto written_quarters(score_written_duration const &written) -> std::float64_t;
|
||||
|
||||
}
|
||||
|
||||
+17
-94
@@ -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>;
|
||||
|
||||
}
|
||||
|
||||
+5
-120
@@ -13,128 +13,14 @@
|
||||
|
||||
namespace vamp_zero {
|
||||
|
||||
struct score_time {
|
||||
std::int64_t numerator{};
|
||||
std::int64_t denominator{1};
|
||||
auto quarters() const -> double {
|
||||
return static_cast<double>(numerator) / static_cast<double>(denominator);
|
||||
}
|
||||
};
|
||||
|
||||
struct score_written_duration {
|
||||
std::string type{};
|
||||
std::int32_t dots{};
|
||||
score_time ratio{1, 1};
|
||||
std::string normal_type{};
|
||||
std::int32_t normal_dots{};
|
||||
};
|
||||
|
||||
struct score_beam {
|
||||
std::int32_t level{1};
|
||||
std::string type{};
|
||||
};
|
||||
|
||||
struct score_attribute {
|
||||
score_time onset{};
|
||||
std::string clef{};
|
||||
std::string time_signature{};
|
||||
std::string key_signature{};
|
||||
std::optional<std::array<std::int32_t, 7>> key_alterations{};
|
||||
std::vector<score_time> beats{};
|
||||
};
|
||||
|
||||
struct score_harmony {
|
||||
std::string id{};
|
||||
score_time onset{};
|
||||
std::string symbol{};
|
||||
std::string kind{};
|
||||
};
|
||||
|
||||
enum class hardware_mode {
|
||||
FAKE,
|
||||
REAL,
|
||||
};
|
||||
|
||||
struct score_pitch {
|
||||
std::char_t letter{'c'};
|
||||
std::int32_t octave{};
|
||||
std::string accidental{};
|
||||
std::string id{};
|
||||
std::optional<std::int32_t> alteration{};
|
||||
score_time duration{};
|
||||
score_written_duration written{};
|
||||
std::string tie_to{};
|
||||
std::string tie_from{};
|
||||
std::bool_t explicit_accidental{};
|
||||
std::bool_t accidental_parentheses{};
|
||||
std::bool_t accidental_bracket{};
|
||||
};
|
||||
|
||||
struct score_note {
|
||||
std::string id{};
|
||||
std::string kind{};
|
||||
std::bool_t hidden{};
|
||||
double duration_ticks{};
|
||||
double display_ticks{};
|
||||
std::string notehead{};
|
||||
std::string chord_symbol{};
|
||||
std::string lyric{};
|
||||
std::bool_t tie_to_next{};
|
||||
std::bool_t tie_from_previous{};
|
||||
std::string tuplet_id{};
|
||||
std::vector<vamp_zero::score_pitch> pitches{};
|
||||
score_time onset{};
|
||||
score_time duration{};
|
||||
score_written_duration written{};
|
||||
std::vector<score_beam> beams{};
|
||||
std::vector<std::string> tuplet_ids{};
|
||||
std::string stem{};
|
||||
std::bool_t grace{};
|
||||
std::bool_t grace_slash{};
|
||||
std::bool_t cue{};
|
||||
std::bool_t measure_rest{};
|
||||
std::int32_t tremolo_marks{};
|
||||
std::string tremolo_type{};
|
||||
std::string tremolo_partner{};
|
||||
std::string lyric_extend{};
|
||||
std::string clef{};
|
||||
std::int32_t display_octaves{};
|
||||
std::optional<score_pitch> rest_position{};
|
||||
};
|
||||
|
||||
struct score_tuplet {
|
||||
std::string id{};
|
||||
std::int32_t note_count{};
|
||||
std::int32_t space_count{};
|
||||
std::string start{};
|
||||
std::string end{};
|
||||
std::int32_t depth{};
|
||||
std::string bracket{"auto"};
|
||||
std::string show_number{"actual"};
|
||||
};
|
||||
|
||||
struct score_measure {
|
||||
std::string id{};
|
||||
std::string section_label{};
|
||||
std::string time_signature{};
|
||||
std::string key_signature{};
|
||||
std::vector<vamp_zero::score_note> notes{};
|
||||
std::vector<vamp_zero::score_tuplet> tuplets{};
|
||||
score_time duration{};
|
||||
std::string clef{};
|
||||
std::array<std::int32_t, 7> key_alterations{};
|
||||
std::bool_t structured_key{};
|
||||
std::vector<score_time> beats{};
|
||||
std::vector<score_harmony> harmonies{};
|
||||
std::vector<score_attribute> attributes{};
|
||||
std::string right_barline{"regular"};
|
||||
std::bool_t implicit{};
|
||||
};
|
||||
|
||||
struct score_octave_shift {
|
||||
score_time start{};
|
||||
score_time end{};
|
||||
std::int32_t octaves{};
|
||||
struct score_page {
|
||||
std::string path{};
|
||||
std::string sha256{};
|
||||
};
|
||||
|
||||
struct score_document {
|
||||
@@ -143,13 +29,12 @@ struct score_document {
|
||||
std::string composer{};
|
||||
std::string key_signature{};
|
||||
std::string time_signature{};
|
||||
std::string clef{};
|
||||
std::string part{};
|
||||
std::string arrangement_part_type{};
|
||||
std::string source_path{};
|
||||
std::string source_json{};
|
||||
std::vector<vamp_zero::score_measure> measures{};
|
||||
std::vector<score_octave_shift> octave_shifts{};
|
||||
std::size_t measure_count{};
|
||||
std::vector<vamp_zero::score_page> pages{};
|
||||
};
|
||||
|
||||
struct library_part {
|
||||
|
||||
Reference in New Issue
Block a user