Okay, once again i remaked my code:
Note class:
class Note { //SOUNDS COUNTAINER AND LAUNCHER
public:
sf::SoundBuffer Metronome_buffer; //BUFFER FOR METRONOME SOUND
sf::Sound Metronome_sound; //SOUND OF METRONOME
//SEPARATED BUFFERS
sf::SoundBuffer Buffer_clean[STRINGS];
sf::SoundBuffer Buffer_lead[STRINGS];
sf::SoundBuffer Buffer_pm[STRINGS];
//SEPARATED SOUNDS
sf::Sound Sound_clean[STRINGS][RANGEOFSTRINGS];
sf::Sound Sound_lead[STRINGS][RANGEOFSTRINGS];
sf::Sound Sound_pm[STRINGS][RANGEOFSTRINGS];
float Pitch_Table[RANGEOFSTRINGS + 1] = { 1.0f, 1.06f, 1.123f, 1.19f, 1.264f, 1.336f, 1.415f, 1.5f, 1.59f, 1.69f, 1.79f, 1.89f, 2.0f,
2.13f, 2.25f, 2.39f, 2.53f, 2.68f, 2.84f, 3.0f, 3.174f, 3.355f, 3.56f, 3.77f, 4.0f, 4.1f }; //TABLE OF PITCHES FOR EACH FRET
Note();
void play(short type, struct Tab::Fret_cutaway *fr_cut = NULL, short string = 0, short fret = 0); //PLAY - TYPES: 0\1\2 -C\L\P || 10 FRETCUT
void load(short type, sf::RenderWindow *window, class System *system); //SHITDOESNTWORK
void load_clean();
void load_lead();
void load_pm();
};
Now i have three separated functions for load each kind of sounds, and i made them as simply as it was possible
void Note::load_clean() {
//LOAD SOUND || 0- C | 1- G | 2- C | 5- D
this->Buffer_clean[0].loadFromFile("Properties/Sounds/C0.wav");
this->Buffer_clean[1].loadFromFile("Properties/Sounds/C1.wav");
this->Buffer_clean[2].loadFromFile("Properties/Sounds/C2.wav");
this->Buffer_clean[3].loadFromFile("Properties/Sounds/C3.wav");
this->Buffer_clean[4].loadFromFile("Properties/Sounds/C4.wav");
this->Buffer_clean[5].loadFromFile("Properties/Sounds/C5.wav");
//PARAMS
for (int j = 0; j < RANGEOFSTRINGS; j++) {
this->Sound_clean[0][j].setBuffer(this->Buffer_clean[0]);
this->Sound_clean[0][j].setPitch(this->Pitch_Table[j]);
this->Sound_clean[1][j].setBuffer(this->Buffer_clean[1]);
this->Sound_clean[1][j].setPitch(this->Pitch_Table[j]);
this->Sound_clean[2][j].setBuffer(this->Buffer_clean[2]);
this->Sound_clean[2][j].setPitch(this->Pitch_Table[j]);
this->Sound_clean[3][j].setBuffer(this->Buffer_clean[3]);
this->Sound_clean[3][j].setPitch(this->Pitch_Table[j]);
this->Sound_clean[4][j].setBuffer(this->Buffer_clean[4]);
this->Sound_clean[4][j].setPitch(this->Pitch_Table[j]);
this->Sound_clean[5][j].setBuffer(this->Buffer_clean[5]);
this->Sound_clean[5][j].setPitch(this->Pitch_Table[j]);
//METRONOME
this->Metronome_buffer.loadFromFile("Properties/Sounds/_M1.wav");
this->Metronome_sound.setBuffer(this->Metronome_buffer);
}
}
void Note::load_pm() {
//LOAD SOUND || 0- C | 1- G | 2- C | 5- D
this->Buffer_pm[0].loadFromFile("Properties/Sounds/P0.wav");
this->Buffer_pm[1].loadFromFile("Properties/Sounds/P1.wav");
this->Buffer_pm[2].loadFromFile("Properties/Sounds/P2.wav");
this->Buffer_pm[3].loadFromFile("Properties/Sounds/P3.wav");
this->Buffer_pm[4].loadFromFile("Properties/Sounds/P4.wav");
this->Buffer_pm[5].loadFromFile("Properties/Sounds/P5.wav");
//PARAMS
for (int j = 0; j < RANGEOFSTRINGS; j++) {
this->Sound_pm[0][j].setBuffer(this->Buffer_pm[0]);
this->Sound_pm[0][j].setPitch(this->Pitch_Table[j]);
this->Sound_pm[1][j].setBuffer(this->Buffer_pm[1]);
this->Sound_pm[1][j].setPitch(this->Pitch_Table[j]);
this->Sound_pm[2][j].setBuffer(this->Buffer_pm[2]);
this->Sound_pm[2][j].setPitch(this->Pitch_Table[j]);
this->Sound_pm[3][j].setBuffer(this->Buffer_pm[3]);
this->Sound_pm[3][j].setPitch(this->Pitch_Table[j]);
this->Sound_pm[4][j].setBuffer(this->Buffer_pm[4]);
this->Sound_pm[4][j].setPitch(this->Pitch_Table[j]);
this->Sound_pm[5][j].setBuffer(this->Buffer_pm[5]);
this->Sound_pm[5][j].setPitch(this->Pitch_Table[j]);
}
}
And what happens now:
In case i loaded only clean in main():
-every sound works right and have right pitch. Its great isnt it ?
In calse i loaded only pm (load_pm() ) in main():
-positions of sound_pm(6)(25)
(0)(8 )
(4)(19)
(4)(8 )
Plays something ....
(i didnt even check pitch becouse it was actually useless)
-rest of table
Sound_pm(6)(25) doesnt play anything
In case i loaded clean and then pm in main():
-Clean works fine (pitch and buffer - type of sound) except:
sound_clean(6)(25) positions:
(1)(18 )
(0)(11)
(0)(3)
On this position buffer is pm. What to say ... :|
-Pm doesnt play any sound except positions
(5)(11) = (2)(14) = (2)(4)
This three plays exactly same sound and pitch, buffer is right
(2)(11)
(1)(3)
(1)(2)
(1)(0)
(5)(12)
(5)(11)
This positions plays something. I didnt check pitch. The rest of table is dead
My play function looks like:
void Note::play(short type, struct Tab::Fret_cutaway *fr_cut, short string, short fret) {
//TYPE 0/1/2 - PLAYING ON KEYBOARD- Clean/Lead/Pm
if (type == 0 || type == 1 || type == 2) {
//KEYBOARD CLEAN-------------------------
if (type == 0) {
this->Sound_clean[string][fret].play();
}
//KEYBOARD LEAD-------------------------
if (type == 1) {
this->Sound_lead[string][fret].play();
}
//KEYBOARD PALM MUTE-------------------------
if (type == 2) {
this->Sound_pm[string][fret].play();
}
}
}
If i run program more times, sometimes different positions works or not.
I completely dont understand what is goin on
PS i had to use (2) - brackets instead of [2] becouse there was some problems with right displaying it on forum