F.E.I.S/src/better_notes.hpp

44 lines
1.5 KiB
C++
Raw Normal View History

#pragma once
#include <algorithm>
#include <array>
2022-04-09 00:54:06 +02:00
#include <cstddef>
#include <interval_tree.hpp>
#include <json.hpp>
#include <type_traits>
#include <utility>
#include "better_note.hpp"
#include "better_timing.hpp"
#include "generic_interval.hpp"
#include "json.hpp"
#include "special_numeric_types.hpp"
namespace better {
2022-04-14 00:13:38 +02:00
class Notes : public interval_tree<Fraction, Note> {
public:
// try to insert a note, the boolean is true on success
2022-04-14 00:13:38 +02:00
std::pair<iterator, bool> insert(const Note& note);
// insert a note, erasing any other note it collides with
void overwriting_insert(const Note& note);
// returns at iterator to a note exactly equal, if found
2022-04-14 00:13:38 +02:00
const_iterator find(const Note& note) const;
2022-03-25 02:20:22 +01:00
bool contains(const Note& note) const;
void erase(const Note& note);
/*
Returns true if the given note (assumed to already be in the container)
is colliding with ANOTHER note. This means notes exactly equal to the
one passed as an argument are NOT taken into account.
*/
2022-04-09 00:54:06 +02:00
bool is_colliding(const better::Note& note, const better::Timing& timing) const;
Notes between(const Interval<Fraction>& bounds);
2022-04-09 00:54:06 +02:00
std::size_t count_between(const Interval<Fraction>& bounds);
2022-04-02 04:10:09 +02:00
nlohmann::ordered_json dump_to_memon_1_0_0() const;
2022-04-11 01:50:25 +02:00
static Notes load_from_memon_1_0_0(const nlohmann::json& json, std::uint64_t resolution = 240);
static Notes load_from_memon_legacy(const nlohmann::json& json, std::uint64_t resolution);
};
}