Page principale | Hiérarchie des classes | Liste des classes | Liste des fichiers | Membres de classe | Membres de fichier

ctrl_son.cpp

Aller à la documentation de ce fichier.
00001 00002 // Shoot(r) 00009 00010 #include "ctrl_son.h" 00011 00012 CSoundManager* CSoundManager::m_pSoundManager = 0; 00013 00014 CSoundManager::CSoundManager () 00015 { 00016 m_bCanauxJeu = true; 00017 00018 // On initialise Fmod : Fréquence de sortie, nombre de canaux utilisés et option (non util pour nous) 00019 FSOUND_Init (44100, CANAL_MAX, 0); 00020 FSOUND_SetSFXMasterVolume (64); 00021 00022 // On initialise tous les canaux de sons à 0 pour pouvoir vérifier qu'ils sont utilisés ou non. 00023 for (int Canal = CANAL_NULL; Canal < CANAL_MAX; Canal++) 00024 m_pSon[Canal] = 0; 00025 } 00026 00027 CSoundManager::~CSoundManager () 00028 { 00029 // On libère tous les canaux 00030 for (int Canal = CANAL_NULL; Canal < CANAL_MAX; Canal++) 00031 if (m_pSon[Canal]) 00032 FSOUND_Stream_Close (m_pSon[Canal]); 00033 } 00034 00035 // Creation ou récupération de l'instance du gestionnaire de sons. 00036 // Si l'instance n'existe pas (m_pSoundManager == 0), on la créé. 00037 CSoundManager* CSoundManager::Instance () 00038 { 00039 if (m_pSoundManager == 0) 00040 m_pSoundManager = new CSoundManager; 00041 return m_pSoundManager; 00042 } 00043 00044 // Suppression de l'instance du gestionnaire de sons si elle existe. 00045 void CSoundManager::Kill () 00046 { 00047 if (m_pSoundManager != 0) 00048 { 00049 delete m_pSoundManager; 00050 m_pSoundManager = 0; 00051 } 00052 } 00053 00054 #include <stdio.h> 00055 00056 // Lecture des sons. Ils sont lu par streaming c'est à dire qu'ils sont chargés pendant la lecture. 00057 void CSoundManager::Jouer (const char* szFilename, ECanaux Canal, bool bLoop) 00058 { 00059 if (!m_bCanauxJeu && Canal != CANAL_MUSIQUE) 00060 return; 00061 00062 if (m_pSon[Canal]) 00063 FSOUND_Stream_Close (m_pSon[Canal]); 00064 00065 // Si bLoop == true alors le son boucle. 00066 if (bLoop) 00067 { 00068 FSOUND_SetLoopMode (0, FSOUND_LOOP_NORMAL); 00069 m_pSon[Canal] = FSOUND_Stream_Open (szFilename, FSOUND_LOOP_NORMAL, 0, 0); 00070 FSOUND_SetVolume (Canal, 64); 00071 FSOUND_SetVolumeAbsolute (Canal, 64); 00072 } 00073 // Sinon il est jouer une seule fois. 00074 else 00075 { 00076 m_pSon[Canal] = FSOUND_Stream_Open (szFilename, FSOUND_NORMAL, 0, 0); 00077 FSOUND_SetVolume (Canal, 255); 00078 FSOUND_SetVolumeAbsolute (Canal, 255); 00079 } 00080 00081 FSOUND_Stream_Play (Canal, m_pSon[Canal]); 00082 }

Généré le Sun Sep 26 11:36:46 2004 pour Shoot(r) par doxygen 1.3.8