LCOV - code coverage report
Current view: top level - source/soundmanager/scripting - SoundGroup.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 2 0.0 %
Date: 2023-01-19 00:18:29 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2021 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #ifndef INCLUDED_SOUNDGROUP_H
      19             : #define INCLUDED_SOUNDGROUP_H
      20             : 
      21             : #include "lib/config2.h"
      22             : #include "lib/file/vfs/vfs_path.h"
      23             : #include "lib/types.h"
      24             : #include "simulation2/system/Entity.h"
      25             : #include "soundmanager/data/SoundData.h"
      26             : 
      27             : #include <vector>
      28             : 
      29             : class CVector3D;
      30             : 
      31             : enum eSndGrpFlags
      32             : {
      33             :     eRandOrder = 0x01,
      34             :     eRandGain = 0x02,
      35             :     eRandPitch = 0x04,
      36             :     eLoop = 0x08,
      37             :     eOmnipresent = 0x10,
      38             :     eDistanceless = 0x20,
      39             :     eOwnerOnly = 0x40
      40             : };
      41             : 
      42             : // Loads up a group of sound files with shared properties,
      43             : // and provides a simple interface for playing them.
      44             : class CSoundGroup
      45             : {
      46             :     NONCOPYABLE(CSoundGroup);
      47             : public:
      48             :     CSoundGroup(const VfsPath& pathnameXML);
      49             :     CSoundGroup();
      50             :     ~CSoundGroup();
      51             : 
      52             :     // Play next sound in group
      53             :     // @param position world position of the entity generating the sound
      54             :     // (ignored if the eOmnipresent flag is set)
      55             :     void PlayNext(const CVector3D& position, entity_id_t source);
      56             : 
      57             :     float RadiansOffCenter(const CVector3D& position, bool& onScreen, float& itemRollOff);
      58             : 
      59             :     // Load a group
      60             :     bool LoadSoundGroup(const VfsPath& pathnameXML);
      61             : 
      62             :     void Reload();
      63             : 
      64             :     // Release all remaining loaded handles
      65             :     void ReleaseGroup();
      66             : 
      67             :     // Update SoundGroup, remove dead sounds from intensity count
      68             :     void Update(float TimeSinceLastFrame);
      69             : 
      70             :     // Set a flag using a value from eSndGrpFlags
      71           0 :     inline void SetFlag(int flag) { m_Flags = (unsigned char)(m_Flags | flag); }
      72             : 
      73             :     // Test flag, returns true if flag is set.
      74           0 :     inline bool TestFlag(int flag) { return (m_Flags & flag) != 0; }
      75             : 
      76             : private:
      77             :     void SetGain(float gain);
      78             : 
      79             :     void UploadPropertiesAndPlay(size_t theIndex, const CVector3D& position, entity_id_t source);
      80             : 
      81             :     void SetDefaultValues();
      82             : #if CONFIG2_AUDIO
      83             :     // We store the handles so we can load now and play later
      84             :     std::vector<CSoundData*> m_SoundGroups;
      85             : #endif
      86             :     u32 m_Seed;
      87             :     // We need the filenames so we can reload when necessary.
      88             :     std::vector<std::wstring> m_Filenames;
      89             :     // The file path for the list of sound file resources
      90             :     VfsPath m_Filepath;
      91             :     size_t m_CurrentSoundIndex;
      92             :     float m_ConeInnerAngle;
      93             :     float m_ConeOuterAngle;
      94             :     float m_ConeOuterGain;
      95             :     // Time elapsed since soundgroup was created
      96             :     float m_CurTime;
      97             :     float m_Decay;
      98             :     float m_Gain;
      99             :     float m_GainUpper;
     100             :     float m_GainLower;
     101             :     // Distance attenuation settings
     102             :     float m_MinDist;
     103             :     float m_MaxDist;
     104             :     // How much stereo separation to apply to sounds based on L-R position relative to the camera.
     105             :     float m_MaxStereoAngle;
     106             :     // The allowable intensity before a sound switch
     107             :     float m_IntensityThreshold;
     108             :     float m_Pitch;
     109             :     float m_PitchLower;
     110             :     float m_PitchUpper;
     111             :     float m_Priority;
     112             :     // Up to eight individual parameters, use with eSndGrpFlags.
     113             :     u8 m_Flags;
     114             : };
     115             : 
     116             : #endif //#ifndef INCLUDED_SOUNDGROUP_H

Generated by: LCOV version 1.13