random placement
This commit is contained in:
parent
c010e61522
commit
501f2156cc
1 changed files with 44 additions and 2 deletions
|
@ -9,12 +9,54 @@ void generateTilePattern(std::vector<std::pair<float, int>> new_notes,
|
||||||
const AudioEmitter &audio_emitter) {
|
const AudioEmitter &audio_emitter) {
|
||||||
int i = -1;
|
int i = -1;
|
||||||
float beatDuration = 60.f / audio_emitter.tempo;
|
float beatDuration = 60.f / audio_emitter.tempo;
|
||||||
|
int previous_note_pitch = 0;
|
||||||
|
NotePlaceEnum previous_note_placement = static_cast<NotePlaceEnum>(0);
|
||||||
for (auto note : new_notes) {
|
for (auto note : new_notes) {
|
||||||
i++;
|
i++;
|
||||||
// if (i % 4 != 0) // skip les 3/4 des notes (je suis trop nul sinon)
|
|
||||||
// continue;
|
|
||||||
float start_time = note.first;
|
float start_time = note.first;
|
||||||
NotePlaceEnum notePlace = static_cast<NotePlaceEnum>(i % 3);
|
NotePlaceEnum notePlace = static_cast<NotePlaceEnum>(i % 3);
|
||||||
|
if (i == 0) {
|
||||||
|
notePlace = static_cast<NotePlaceEnum>(rand()%3);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (note.second == previous_note_pitch) {
|
||||||
|
notePlace = previous_note_placement;
|
||||||
|
}
|
||||||
|
else if (note.second < previous_note_pitch) {
|
||||||
|
if (previous_note_placement == Left) {
|
||||||
|
notePlace = Left;
|
||||||
|
}
|
||||||
|
else if (previous_note_placement == Middle) {
|
||||||
|
notePlace = Left;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (rand() % 2 == 0) {
|
||||||
|
notePlace = Left;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
notePlace = Middle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (previous_note_placement == Right) {
|
||||||
|
notePlace = Right;
|
||||||
|
}
|
||||||
|
else if (previous_note_placement == Middle) {
|
||||||
|
notePlace = Right;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (rand() % 2 == 0) {
|
||||||
|
notePlace = Right;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
notePlace = Middle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
previous_note_pitch = note.second;
|
||||||
|
previous_note_placement = notePlace;
|
||||||
NoteTile::create(start_time, beatDuration, notePlace, audio_emitter.getTime());
|
NoteTile::create(start_time, beatDuration, notePlace, audio_emitter.getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue