/**
* =========================================================================
* File : SoundGroup.h
* Project : 0 A.D.
* Description : Loads up a group of sound files with shared properties,
* and provides a simple interface for playing them.
*
* Author : Gavin Fowler
* =========================================================================
*/
/*
* Copyright (c) 2005-2006 Gavin Fowler
*
* Redistribution and/or modification are also permitted under the
* terms of the GNU General Public License as published by the
* Free Software Foundation (version 2 or later, at your option).
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/*
Example usage: (SEE SOUNDGROUPMGR.H)
Example SoundGroup.xml
1.0
0
1.0
100
0
0
0
1.0
360
360
audio/voice/hellenes/soldier/Attack_Attackx.ogg
audio/voice/hellenes/soldier/Attack_Chargex.ogg
audio/voice/hellenes/soldier/Attack_Engagex.ogg
audio/voice/hellenes/soldier/Attack_ForMyFamily.ogg
*/
#ifndef SOUNDGROUP_H_
#define SOUNDGROUP_H_
#include "lib/res/handle.h"
#include "ps/CStr.h"
#include "lib/res/sound/snd_mgr.h"
#include
using namespace std;
enum eSndGrpFlags
{
eRandOrder = 0x01,
eRandGain = 0x02,
eRandPitch = 0x04,
eLoop = 0x08
};
class CSoundGroup
{
size_t m_index; // index of the next sound to play
Handle m_hReplacement;
vector snd_group; // we store the handles so we can load now and play later
vector filenames; // we need the filenames so we can reload when necessary.
vector playtimes; // it would be better to store this in with the Handles perhaps?
CStr m_filepath; // the file path for the list of sound file resources
CStr m_intensity_file; // the replacement aggregate 'intense' sound
float m_CurTime; // Time elapsed since soundgroup was created
float m_TimeWindow; // The Intensity Threshold Window
size_t m_IntensityThreshold; // the allowable intensity before a sound switch
size_t m_Intensity; // our current intensity(number of sounds played since m_CurTime - m_TimeWindow)
float m_Decay; //
unsigned char m_Flags; // up to eight individual parameters, use with eSndGrpFlags.
float m_Gain;
float m_Pitch;
float m_Priority;
float m_ConeOuterGain;
float m_PitchUpper;
float m_PitchLower;
float m_GainUpper;
float m_GainLower;
float m_ConeInnerAngle;
float m_ConeOuterAngle;
public:
CSoundGroup(const char *XMLfile);
CSoundGroup(void);
~CSoundGroup(void);
// Play next sound in group
void PlayNext();
// Load a group
bool LoadSoundGroup(const char *XMLfile);
void Reload();
// Release all remaining loaded handles
void ReleaseGroup();
// Update SoundGroup, remove dead sounds from intensity count
void Update(float TimeSinceLastFrame);
// Set a flag using a value from eSndGrpFlags
inline void SetFlag(int flag){ m_Flags |= flag; }
// Test flag, returns true if flag is set.
inline bool TestFlag(int flag) { return (m_Flags & flag) == flag;}
};
#endif //#ifndef SOUNDGROUP_H_