2022-03-16 02:10:18 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <array>
|
2022-04-09 00:54:06 +02:00
|
|
|
#include <cstddef>
|
2022-03-31 03:50:15 +02:00
|
|
|
#include <interval_tree.hpp>
|
|
|
|
#include <json.hpp>
|
2022-04-04 04:30:02 +02:00
|
|
|
#include <type_traits>
|
|
|
|
#include <utility>
|
2022-03-16 02:10:18 +01:00
|
|
|
|
|
|
|
#include "better_note.hpp"
|
2022-03-31 03:50:15 +02:00
|
|
|
#include "better_timing.hpp"
|
2022-04-04 04:30:02 +02:00
|
|
|
#include "generic_interval.hpp"
|
2022-03-31 03:50:15 +02:00
|
|
|
#include "json.hpp"
|
2022-03-16 02:10:18 +01:00
|
|
|
#include "special_numeric_types.hpp"
|
|
|
|
|
|
|
|
namespace better {
|
2022-04-04 04:30:02 +02:00
|
|
|
class Notes : public interval_tree<Fraction, Note> {
|
2022-03-16 02:10:18 +01:00
|
|
|
public:
|
2022-03-27 03:32:13 +02:00
|
|
|
// try to insert a note, the boolean is true on success
|
2022-03-16 02:10:18 +01:00
|
|
|
std::pair<iterator, bool> insert(const Note& note);
|
2022-04-04 04:30:02 +02:00
|
|
|
// insert a note, erasing any other note it collides with
|
2022-03-27 03:32:13 +02:00
|
|
|
void overwriting_insert(const Note& note);
|
|
|
|
// returns at iterator to a note exactly equal, if found
|
2022-03-23 02:20:07 +01:00
|
|
|
const_iterator find(const Note& note) const;
|
2022-03-25 02:20:22 +01:00
|
|
|
bool contains(const Note& note) const;
|
2022-03-27 03:32:13 +02:00
|
|
|
void erase(const Note& note);
|
2022-03-31 03:50:15 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
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;
|
2022-03-31 03:50:15 +02:00
|
|
|
|
2022-04-04 04:30:02 +02:00
|
|
|
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-04 04:30:02 +02:00
|
|
|
|
2022-04-02 04:10:09 +02:00
|
|
|
nlohmann::ordered_json dump_to_memon_1_0_0() const;
|
2022-03-16 02:10:18 +01:00
|
|
|
};
|
|
|
|
}
|