nouveaux sons
This commit is contained in:
parent
5c65b99604
commit
4bbdbfe6e4
62 changed files with 51 additions and 67 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/chords/variation1/A.mp3
Normal file
BIN
SimpleGame/media/chords/variation1/A.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation1/B.mp3
Normal file
BIN
SimpleGame/media/chords/variation1/B.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation1/C.mp3
Normal file
BIN
SimpleGame/media/chords/variation1/C.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation1/D.mp3
Normal file
BIN
SimpleGame/media/chords/variation1/D.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation1/E.mp3
Normal file
BIN
SimpleGame/media/chords/variation1/E.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation1/F.mp3
Normal file
BIN
SimpleGame/media/chords/variation1/F.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation1/G.mp3
Normal file
BIN
SimpleGame/media/chords/variation1/G.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation2/A.mp3
Normal file
BIN
SimpleGame/media/chords/variation2/A.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation2/B.mp3
Normal file
BIN
SimpleGame/media/chords/variation2/B.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation2/C.mp3
Normal file
BIN
SimpleGame/media/chords/variation2/C.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation2/D.mp3
Normal file
BIN
SimpleGame/media/chords/variation2/D.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation2/E.mp3
Normal file
BIN
SimpleGame/media/chords/variation2/E.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation2/F.mp3
Normal file
BIN
SimpleGame/media/chords/variation2/F.mp3
Normal file
Binary file not shown.
BIN
SimpleGame/media/chords/variation2/G.mp3
Normal file
BIN
SimpleGame/media/chords/variation2/G.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/A1.mp3
Normal file
BIN
SimpleGame/media/notes/A1.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/A2.mp3
Normal file
BIN
SimpleGame/media/notes/A2.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/A3.mp3
Normal file
BIN
SimpleGame/media/notes/A3.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/B1.mp3
Normal file
BIN
SimpleGame/media/notes/B1.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/B2.mp3
Normal file
BIN
SimpleGame/media/notes/B2.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/C1.mp3
Normal file
BIN
SimpleGame/media/notes/C1.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/C2.mp3
Normal file
BIN
SimpleGame/media/notes/C2.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/D1.mp3
Normal file
BIN
SimpleGame/media/notes/D1.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/D2.mp3
Normal file
BIN
SimpleGame/media/notes/D2.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/E1.mp3
Normal file
BIN
SimpleGame/media/notes/E1.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/E2.mp3
Normal file
BIN
SimpleGame/media/notes/E2.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/F1.mp3
Normal file
BIN
SimpleGame/media/notes/F1.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/F2.mp3
Normal file
BIN
SimpleGame/media/notes/F2.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/G1.mp3
Normal file
BIN
SimpleGame/media/notes/G1.mp3
Normal file
Binary file not shown.
Binary file not shown.
BIN
SimpleGame/media/notes/G2.mp3
Normal file
BIN
SimpleGame/media/notes/G2.mp3
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -13,7 +13,6 @@ private:
|
|||
std::vector<std::unique_ptr<FMOD::Sound>> chords;
|
||||
std::vector<std::unique_ptr<FMOD::Sound>> drums;
|
||||
std::vector<std::unique_ptr<FMOD::Sound>> notes;
|
||||
int tempo{170};
|
||||
std::vector<std::vector<float>> markov_matrix_chords;
|
||||
std::vector<std::vector<float>> markov_matrix_melody;
|
||||
int nbr_melo_max{4};
|
||||
|
@ -24,6 +23,7 @@ private:
|
|||
std::vector<FMOD::Channel *> activeChannels;
|
||||
|
||||
public:
|
||||
int tempo{ 170 };
|
||||
AudioEmitter();
|
||||
std::vector<std::pair<float, int>> generateMusic();
|
||||
void audioUpdate();
|
||||
|
@ -35,5 +35,5 @@ public:
|
|||
int noteSecondaire(int note);
|
||||
float getTimeTempo() const;
|
||||
float getTime() const;
|
||||
float timeBeforeNewGeneration{0.2f};
|
||||
float timeBeforeNewGeneration{4.f};
|
||||
};
|
||||
|
|
|
@ -25,67 +25,70 @@ AudioEmitter::AudioEmitter() {
|
|||
system.reset(rawSystem);
|
||||
ERRCHECK(system->init(512, FMOD_INIT_NORMAL, nullptr));
|
||||
|
||||
std::vector<FMOD::Sound *> rawChords(7);
|
||||
ERRCHECK(system->createSound("media/accords/do.wav", FMOD_LOOP_OFF, nullptr,
|
||||
std::vector<FMOD::Sound *> rawChords(14);
|
||||
printf("coucou\n");
|
||||
ERRCHECK(system->createSound("media/chords/variation1/C.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[0]));
|
||||
ERRCHECK(system->createSound("media/accords/re.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/chords/variation1/D.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[1]));
|
||||
ERRCHECK(system->createSound("media/accords/mi.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/chords/variation1/E.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[2]));
|
||||
ERRCHECK(system->createSound("media/accords/fa.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/chords/variation1/F.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[3]));
|
||||
ERRCHECK(system->createSound("media/accords/sol.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/chords/variation1/G.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[4]));
|
||||
ERRCHECK(system->createSound("media/accords/la.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/chords/variation1/A.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[5]));
|
||||
ERRCHECK(system->createSound("media/accords/si.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/chords/variation1/B.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[6]));
|
||||
for (int i = 0; i < 7; i += 1) {
|
||||
ERRCHECK(system->createSound("media/chords/variation2/C.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[7]));
|
||||
ERRCHECK(system->createSound("media/chords/variation2/D.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[8]));
|
||||
ERRCHECK(system->createSound("media/chords/variation2/E.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[9]));
|
||||
ERRCHECK(system->createSound("media/chords/variation2/F.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[10]));
|
||||
ERRCHECK(system->createSound("media/chords/variation2/G.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[11]));
|
||||
ERRCHECK(system->createSound("media/chords/variation2/A.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[12]));
|
||||
ERRCHECK(system->createSound("media/chords/variation2/B.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawChords[13]));
|
||||
for (int i = 0; i < 14; i += 1) {
|
||||
chords.push_back(std::unique_ptr<FMOD::Sound>(rawChords[i]));
|
||||
}
|
||||
|
||||
int nbr_drums = 3;
|
||||
std::vector<FMOD::Sound *> rawDrums(nbr_drums);
|
||||
ERRCHECK(system->createSound("media/percussions/drums1.wav", FMOD_LOOP_OFF,
|
||||
nullptr, &rawDrums[0]));
|
||||
ERRCHECK(system->createSound("media/percussions/drums2.wav", FMOD_LOOP_OFF,
|
||||
nullptr, &rawDrums[1]));
|
||||
ERRCHECK(system->createSound("media/percussions/drums3.wav", FMOD_LOOP_OFF,
|
||||
nullptr, &rawDrums[2]));
|
||||
for (int i = 0; i < nbr_drums; i += 1) {
|
||||
drums.push_back(std::unique_ptr<FMOD::Sound>(rawDrums[i]));
|
||||
}
|
||||
|
||||
std::vector<FMOD::Sound *> rawNotes(15);
|
||||
ERRCHECK(system->createSound("media/notes/A1.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/A1.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[0]));
|
||||
ERRCHECK(system->createSound("media/notes/B1.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/B1.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[1]));
|
||||
ERRCHECK(system->createSound("media/notes/C1.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/C1.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[2]));
|
||||
ERRCHECK(system->createSound("media/notes/D1.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/D1.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[3]));
|
||||
ERRCHECK(system->createSound("media/notes/E1.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/E1.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[4]));
|
||||
ERRCHECK(system->createSound("media/notes/F1.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/F1.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[5]));
|
||||
ERRCHECK(system->createSound("media/notes/G1.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/G1.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[6]));
|
||||
ERRCHECK(system->createSound("media/notes/A2.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/A2.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[7]));
|
||||
ERRCHECK(system->createSound("media/notes/B2.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/B2.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[8]));
|
||||
ERRCHECK(system->createSound("media/notes/C2.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/C2.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[9]));
|
||||
ERRCHECK(system->createSound("media/notes/D2.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/D2.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[10]));
|
||||
ERRCHECK(system->createSound("media/notes/E2.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/E2.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[11]));
|
||||
ERRCHECK(system->createSound("media/notes/F2.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/F2.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[12]));
|
||||
ERRCHECK(system->createSound("media/notes/G2.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/G2.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[13]));
|
||||
ERRCHECK(system->createSound("media/notes/A3.wav", FMOD_LOOP_OFF, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/A3.mp3", FMOD_LOOP_OFF, nullptr,
|
||||
&rawNotes[14]));
|
||||
for (int i = 0; i < 15; i += 1) {
|
||||
notes.push_back(std::unique_ptr<FMOD::Sound>(rawNotes[i]));
|
||||
|
@ -195,7 +198,7 @@ AudioEmitter::AudioEmitter() {
|
|||
}
|
||||
|
||||
FMOD::Sound *metronome_Sound;
|
||||
ERRCHECK(system->createSound("media/notes/A1.wav", FMOD_DEFAULT, nullptr,
|
||||
ERRCHECK(system->createSound("media/notes/A1.mp3", FMOD_DEFAULT, nullptr,
|
||||
&metronome_Sound));
|
||||
ERRCHECK(system->playSound(metronome_Sound, nullptr, true, &timer));
|
||||
ERRCHECK(timer->setVolume(0));
|
||||
|
@ -264,18 +267,6 @@ int AudioEmitter::nextNote(int currentNote) {
|
|||
return sampleIndex(markov_matrix_melody[currentNote]);
|
||||
}
|
||||
|
||||
int AudioEmitter::noteSecondaire(int note) {
|
||||
std::vector<int> notesPossibles = {note - 4, note - 3, note + 3, note + 4,
|
||||
note + 5};
|
||||
std::vector<double> proba = {0.05, 0.10, 0.60, 0.05, 0.2};
|
||||
for (int i = 0; i < proba.size(); i += 1) {
|
||||
if ((notesPossibles[i] < 0) || (notesPossibles[i] >= notes.size())) {
|
||||
proba[i] = 0;
|
||||
}
|
||||
}
|
||||
return randomWeightedChoice(notesPossibles, proba);
|
||||
}
|
||||
|
||||
/**
|
||||
* generate music
|
||||
*
|
||||
|
@ -299,7 +290,7 @@ std::vector<std::pair<float, int>> AudioEmitter::generateMusic() {
|
|||
for (int i = 1; i < 4; i += 1) {
|
||||
chordProgression[i] = nextChord(chordProgression[i - 1]);
|
||||
}
|
||||
int index_drums = rand() % 3;
|
||||
|
||||
for (int i = current_beat; i < current_beat + nbr_melo_max; i += 1) {
|
||||
// Chords
|
||||
FMOD::Channel *channelChords = nullptr;
|
||||
|
@ -313,14 +304,6 @@ std::vector<std::pair<float, int>> AudioEmitter::generateMusic() {
|
|||
ERRCHECK(channelChords->setPaused(false));
|
||||
|
||||
activeChannels.push_back(channelChords);
|
||||
// Drums
|
||||
FMOD::Channel *channelDrums = nullptr;
|
||||
ERRCHECK(system->playSound(drums[index_drums].get(), nullptr, true,
|
||||
&channelDrums));
|
||||
ERRCHECK(channelDrums->setDelay(delay, 0, true));
|
||||
ERRCHECK(channelDrums->setPaused(false));
|
||||
|
||||
activeChannels.push_back(channelDrums);
|
||||
// Mélodie
|
||||
std::vector<float> rythme_melodie = rythmes[rand() % rythmes.size()];
|
||||
for (float time : rythme_melodie) {
|
||||
|
@ -333,8 +316,8 @@ std::vector<std::pair<float, int>> AudioEmitter::generateMusic() {
|
|||
(unsigned long long)(note_start * sampleRate);
|
||||
ERRCHECK(channelNote->setDelay(delayNote, 0, true));
|
||||
ERRCHECK(channelNote->setPaused(false));
|
||||
index_note = nextNote(index_note);
|
||||
result.push_back(std::pair<float, int>(note_start, index_note));
|
||||
index_note = nextNote(index_note);
|
||||
activeChannels.push_back(channelNote);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
int main() {
|
||||
// from out/build/src
|
||||
if (!NoteSprite::loadTexture("../../../media/sprites/flower_tile.png")) {
|
||||
if (!NoteSprite::loadTexture("media/sprites/flower_tile.png")) {
|
||||
std::cerr << "Failed to load texture!" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <SFML/Graphics/Texture.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <SFML/Window/Window.hpp>
|
||||
#include <bits/types/cookie_io_functions_t.h>
|
||||
//#include <bits/types/cookie_io_functions_t.h>
|
||||
#include <cstdio>
|
||||
|
||||
sf::Texture NoteSprite::texture;
|
||||
|
|
|
@ -12,7 +12,7 @@ NoteTile::NoteTile(float play_time, float good_interval, NotePlaceEnum place,
|
|||
: play_time(play_time), good_interval(good_interval), place(place),
|
||||
note_sprite() {
|
||||
// TODO do real note_sprite init, make it fall at good speed far enough...
|
||||
note_sprite.fall_speed = 100;
|
||||
note_sprite.fall_speed = 500;
|
||||
note_sprite.sprite.setPosition(sf::Vector2f(
|
||||
NOTE_PLACE_X_POS[place],
|
||||
NOTE_PRESS_HEIGHT - note_sprite.fall_speed * (play_time - current_time)));
|
||||
|
|
|
@ -8,12 +8,13 @@
|
|||
void generateTilePattern(std::vector<std::pair<float, int>> new_notes,
|
||||
const AudioEmitter &audio_emitter) {
|
||||
int i = -1;
|
||||
float beatDuration = 60.f / audio_emitter.tempo;
|
||||
for (auto note : new_notes) {
|
||||
i++;
|
||||
if (i % 4 != 0) // skip les 3/4 des notes (je suis trop nul sinon)
|
||||
continue;
|
||||
// if (i % 4 != 0) // skip les 3/4 des notes (je suis trop nul sinon)
|
||||
// continue;
|
||||
float start_time = note.first;
|
||||
NotePlaceEnum notePlace = static_cast<NotePlaceEnum>(i % 3);
|
||||
NoteTile::create(start_time, 0.5, notePlace, audio_emitter.getTime());
|
||||
NoteTile::create(start_time, beatDuration, notePlace, audio_emitter.getTime());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue