// NeL - MMORPG Framework
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// 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. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
#ifndef NL_U_SOURCE_H
#define NL_U_SOURCE_H
#include "nel/misc/types_nl.h"
#include "nel/misc/vector.h"
namespace NLMISC {
class CVector;
}
namespace NLSOUND {
static const uint SoundContextNbArgs = 10;
struct CSoundContext
{
// -1 for args is a special value means that unset. Don't use negative number
CSoundContext()
: Position(NLMISC::CVector::Null),
PreviousRandom(100),
RelativeGain(1.0f)
{
for (uint i = 0; i < SoundContextNbArgs; i++)
Args[i] = -1;
}
sint32 Args[SoundContextNbArgs];
NLMISC::CVector Position;
uint32 PreviousRandom;
float RelativeGain;
};
class CSound;
class USource;
/// Sound sample identifiers
typedef CSound* TSoundId;
/// Priority of the sources (p1 3D position
* st mode -> x is the pan value (from left (-1) to right (1)), set y and z to 0
*/
virtual void setPos( const NLMISC::CVector& pos ) = 0;
/// Get the position vector (3D mode only)
virtual const NLMISC::CVector &getPos() const = 0;
/// Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0))
virtual void setVelocity( const NLMISC::CVector& vel ) = 0;
/// Get the velocity vector
virtual void getVelocity( NLMISC::CVector& vel ) const = 0;
/// Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional)
virtual void setDirection( const NLMISC::CVector& dir ) = 0;
/// Get the direction vector
virtual void getDirection( NLMISC::CVector& dir ) const = 0;
/** Set the gain (volume value inside [0 , 1]). (default: 1)
* 0.0 -> silence
* 0.5 -> -6dB
* 1.0 -> no attenuation
* values > 1 (amplification) not supported by most drivers
*/
virtual void setGain( float gain ) = 0;
/// Get the gain
virtual float getGain() const = 0;
/** Set the gain amount (value inside [0, 1]) to map between 0 and the nominal gain
* (which is getSource()->getGain()). Does nothing if getSource() is null.
*/
virtual void setRelativeGain( float gain ) = 0;
/// Return the relative gain (see setRelativeGain()), or the absolute gain if getSource() is null.
virtual float getRelativeGain() const = 0;
/** Shift the frequency. 1.0f equals identity, each reduction of 50% equals a pitch shift
* of one octave. 0 is not a legal value.
*/
virtual void setPitch( float pitch ) = 0;
/// Get the pitch
virtual float getPitch() const = 0;
/// Set the source relative mode. If true, positions are interpreted relative to the listener position (default: false)
virtual void setSourceRelativeMode( bool mode ) = 0;
/// Get the source relative mode
virtual bool getSourceRelativeMode() const = 0;
//@}
/// Destructor
virtual ~USource() {}
protected:
/// Constructor
USource() {}
};
} // NLSOUND
#endif // NL_U_SOURCE_H
/* End of u_source.h */