| 1 | // (_||_/ |
| 2 | // ( ) Audio class |
| 3 | // ( o 0 ) |
| 4 | //-OOO°--(_)---°OOO--------------------------------------- |
| 5 | // Copyright (C) 2006 By Dominique Roux-Serret |
| 6 | // .OOOo oOOO. [email protected] |
| 7 | //-( )------( )--------------------------------------- |
| 8 | // ( ( ) / Copyright (C) 2023 By Johnny Jazeix |
| 9 | // (_) (_/ [email protected] |
| 10 | |
| 11 | // This program is free software; you can redistribute it and/or modify |
| 12 | // it under the terms of the GNU General Public License as published by |
| 13 | // the Free Software Foundation; either version 2 or version 3 of the License. |
| 14 | |
| 15 | // This program is distributed in the hope that it will be useful, |
| 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | // GNU General Public License for more details. |
| 19 | |
| 20 | // You should have received a copy of the GNU General Public License along |
| 21 | // with this program; if not, write to the Free Software Foundation, Inc., |
| 22 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 23 | |
| 24 | #ifndef AUDIO_DOM_ |
| 25 | #define AUDIO_DOM_ |
| 26 | |
| 27 | #include <SDL2/SDL_mixer.h> |
| 28 | |
| 29 | /*** Enumération des sons ***/ |
| 30 | /****************************/ |
| 31 | enum eSon { |
| 32 | sClic = 0, |
| 33 | sSpeed, |
| 34 | sCrash, |
| 35 | sEnd, |
| 36 | sLose, |
| 37 | sEtire, |
| 38 | sWagon, |
| 39 | sReduit, |
| 40 | sLive, |
| 41 | sFin |
| 42 | }; |
| 43 | |
| 44 | /*** Définition de la classe Audio ***/ |
| 45 | /*************************************/ |
| 46 | class Audio |
| 47 | { |
| 48 | public: |
| 49 | Audio() = default; |
| 50 | ~Audio(); |
| 51 | |
| 52 | /*** Fonctions ***/ |
| 53 | bool Init(); // Initialise et charge les fichiers audio |
| 54 | void LoadMusic(int Num); // Charge une music, 0 = music du menu 1,2,3,4=Jeu |
| 55 | void NextMusic(); // Passe à la music suivante |
| 56 | |
| 57 | void Play(eSon); // Joue un son |
| 58 | void PlayMusic() const; // Joue la music |
| 59 | |
| 60 | void PauseMusic(bool Etat) const; // Met ou no la music en pause |
| 61 | |
| 62 | void DoVolume() const; // Valide les volumes audio |
| 63 | Mix_Music *Music { nullptr }; // Pointe sur les musics |
| 64 | |
| 65 | private: |
| 66 | /*** Variables ***/ |
| 67 | int N { 0 }; // Nombre d'échantillon audio |
| 68 | int NMus { 0 }; // Numéro de la music en cours |
| 69 | int MemoHorloge { 0 }; // Mémorise l'horloge pour les clics |
| 70 | Mix_Chunk **Son { nullptr }; // Pointe sur les sons |
| 71 | }; |
| 72 | |
| 73 | #endif |