2017-08-17 23:41:11 +02:00
|
|
|
//
|
|
|
|
// Created by Syméon on 17/08/2017.
|
|
|
|
//
|
2019-03-27 20:37:30 +01:00
|
|
|
// Side note :
|
2017-08-18 17:42:56 +02:00
|
|
|
//
|
2019-03-27 20:37:30 +01:00
|
|
|
// The tail position could be stored by a number between 0 and 5, if you look at it carefully
|
|
|
|
// every note has exactly 6 different possible LN tail positions,
|
|
|
|
// Doing this would allow any tuple of 4 numbers verifying :
|
2017-08-18 17:42:56 +02:00
|
|
|
//
|
2019-03-27 20:37:30 +01:00
|
|
|
// 0 <= position <= 15
|
|
|
|
// 0 <= timing
|
|
|
|
// 0 <= length
|
|
|
|
// 0 <= tail position <= 5
|
2017-08-18 17:42:56 +02:00
|
|
|
//
|
2019-03-27 20:37:30 +01:00
|
|
|
// To count as a valid note, this would also allow for a purely json-schema based chart validation. since it
|
|
|
|
// removes the need for a fancy consistency check between the note and its tail positions
|
2017-08-17 23:41:11 +02:00
|
|
|
|
|
|
|
#ifndef FEIS_NOTE_H
|
|
|
|
#define FEIS_NOTE_H
|
|
|
|
|
2019-03-27 20:37:30 +01:00
|
|
|
/*
|
|
|
|
* A Note has :
|
|
|
|
*
|
|
|
|
* - a Position, from 0 to 15 given this way :
|
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 4 5 6 7
|
|
|
|
* 8 9 10 11
|
|
|
|
* 12 13 14 15
|
|
|
|
*
|
|
|
|
* - a Timing value, just a positive integer
|
|
|
|
*
|
|
|
|
* - a Length, set to 0 if not a long note, else a positive integer in the same unit as the note's timing
|
|
|
|
*
|
|
|
|
* - a Tail position, currently given this way :
|
|
|
|
*
|
|
|
|
* 8
|
|
|
|
* 4
|
|
|
|
* 0
|
|
|
|
* 11 7 3 . 1 5 9
|
|
|
|
* 2
|
|
|
|
* 6
|
|
|
|
* 10
|
|
|
|
*
|
|
|
|
* with the . marking the note position
|
|
|
|
* gets ignored if the length is zero
|
|
|
|
*/
|
2017-08-17 23:41:11 +02:00
|
|
|
class Note {
|
2017-08-18 17:42:56 +02:00
|
|
|
|
2017-08-17 23:41:11 +02:00
|
|
|
public:
|
2017-08-18 17:42:56 +02:00
|
|
|
|
2017-08-25 13:14:38 +02:00
|
|
|
|
2019-01-19 17:12:41 +01:00
|
|
|
Note(int pos, int timing, int length = 0, int tail_pos = 0);
|
2019-03-28 02:16:29 +01:00
|
|
|
Note(const Note& note_a, const Note& note_b);
|
2019-01-19 17:12:41 +01:00
|
|
|
static bool tail_pos_correct(int pos, int tail_pos);
|
2019-03-28 02:16:29 +01:00
|
|
|
static int tail_pos_to_note_pos(int pos, int tail_pos);
|
|
|
|
static int distance(int pos_a, int pos_b);
|
2017-08-18 17:42:56 +02:00
|
|
|
|
2017-08-25 13:14:38 +02:00
|
|
|
bool operator==(const Note &rhs) const;
|
|
|
|
bool operator!=(const Note &rhs) const;
|
|
|
|
bool operator<(const Note &rhs) const;
|
|
|
|
bool operator>(const Note &rhs) const;
|
|
|
|
bool operator<=(const Note &rhs) const;
|
|
|
|
bool operator>=(const Note &rhs) const;
|
|
|
|
|
|
|
|
int getTiming() const;
|
2017-08-18 17:42:56 +02:00
|
|
|
int getPos() const;
|
|
|
|
int getLength() const;
|
2019-01-19 17:12:41 +01:00
|
|
|
int getTail_pos() const;
|
2019-03-28 02:16:29 +01:00
|
|
|
int getTail_pos_as_note_pos() const {return Note::tail_pos_to_note_pos(pos,tail_pos);};
|
2017-08-18 17:42:56 +02:00
|
|
|
|
2017-08-17 23:41:11 +02:00
|
|
|
private:
|
2017-08-18 17:42:56 +02:00
|
|
|
|
2017-08-25 13:14:38 +02:00
|
|
|
int timing;
|
2017-08-17 23:41:11 +02:00
|
|
|
int pos;
|
2017-08-18 17:42:56 +02:00
|
|
|
int length;
|
2019-01-19 17:12:41 +01:00
|
|
|
int tail_pos;
|
2017-08-18 17:42:56 +02:00
|
|
|
|
2019-03-28 02:16:29 +01:00
|
|
|
void initAsClosestLongNote(const Note& start, int end_timing, int wanted_tail_pos);
|
2017-08-17 23:41:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //FEIS_NOTE_H
|