Sound System: Difference between revisions

From PSwiki
Jump to navigation Jump to search
Lucubro (talk | contribs)
m fix toc
Lucubro (talk | contribs)
Line 8: Line 8:


=== Make the Sound Manager a plugin ===
=== Make the Sound Manager a plugin ===
The Sound Manager today is inside the main planeshift client sources. It will be nice to have it made as a plugin to have a cleaner abstraction layer.
The Sound Manager today is inside the main planeshift client sources. It will be nice to have it made as a plugin to have a cleaner abstraction layer. The idea is to allow developers to use the sound system's functionalities entirely through an API. The programmers should not need to know any internal mechanics and they should never make use of internal classes of the sound system.
 
===== The API =====
The module provides two interfaces: iSoundManager and iSoundControl defined as follows. These will be basically the corresponding classes of psSoundManager and SoundControl and they will have more or less similar methods. '''(Note that everything here is in progress: these interfaces (expecially iSoundManager) could vary a lot while I will work on the other features and improvements.)'''
 
struct iSoundManager
{
void LoadActiveSector(string sector) // Corresponding of  psSoundManager::Load(). I think this name is more descriptive
void UnloadActiveSector() // Corresponding of  psSoundManager::Unload()
void Reload()
iSoundControl AddSndCtrl(int ctrlID)
void RemoveSndCtrl(int ctrlID)
iSoundControl GetSndCtrl(int ctrlID)
iSoundControl GetMainSndCtrl()
void AddSndQueue(int queueID)
void RemoveSndQueue(int queueID)
bool PushQueueItem(int queueID, string fileName)
void SetCombatStance(int newCombatStance)
int GetCombatStance()
void SetPosition(csVector3 playerPosition)
csVector3 GetPosition()
void SetTimeOfDay(int newTimeOfDay)
int GetTimeOfDay()
void SetWeather(int newWeather)
int GetWeather()
void SetLoopBGMToogle(bool toogle)
bool IsLoopBGMToogleOn()
void SetCombatMusicToogle(bool toogle)
bool IsCombatMusicToogleOn()
void SetListenerOnCameraToogle(bool toogle)
bool IsListenerOnCameraToogleOn()
void PlaySound(string fileName, bool loop, iSoundCtrl ctrl)
void PlaySound(string fileName, bool loop, iSoundCtrl ctrl, csVector3 pos, csVector3 dir, float minDist, float maxDist)
void StopSound(string fileName)
void Update()
void UpdateListener(iView view)
void UpdateSoundPosition(string fileName, csVector3 position)
}


=== Sounds in factories ===
=== Sounds in factories ===

Revision as of 21:00, 1 May 2011

GSoC 2011 > Sound System

In this page are described the features that will be applied to the sound related part of Planeshift. Notes about the features' implementation will be available as well.

Sound improvements

Make the Sound Manager a plugin

The Sound Manager today is inside the main planeshift client sources. It will be nice to have it made as a plugin to have a cleaner abstraction layer. The idea is to allow developers to use the sound system's functionalities entirely through an API. The programmers should not need to know any internal mechanics and they should never make use of internal classes of the sound system.

The API

The module provides two interfaces: iSoundManager and iSoundControl defined as follows. These will be basically the corresponding classes of psSoundManager and SoundControl and they will have more or less similar methods. (Note that everything here is in progress: these interfaces (expecially iSoundManager) could vary a lot while I will work on the other features and improvements.)

struct iSoundManager
{
	void LoadActiveSector(string sector)		// Corresponding of  psSoundManager::Load(). I think this name is more descriptive
	void UnloadActiveSector()			// Corresponding of  psSoundManager::Unload()

	void Reload()

	iSoundControl AddSndCtrl(int ctrlID)
	void RemoveSndCtrl(int ctrlID)
	iSoundControl GetSndCtrl(int ctrlID)
	iSoundControl GetMainSndCtrl()

	void AddSndQueue(int queueID)
	void RemoveSndQueue(int queueID)
	bool PushQueueItem(int queueID, string fileName)

	void SetCombatStance(int newCombatStance)
	int GetCombatStance()
	void SetPosition(csVector3 playerPosition)
	csVector3 GetPosition()
	void SetTimeOfDay(int newTimeOfDay)
	int GetTimeOfDay()
	void SetWeather(int newWeather)
	int GetWeather()

	void SetLoopBGMToogle(bool toogle)
	bool IsLoopBGMToogleOn()
	void SetCombatMusicToogle(bool toogle)
	bool IsCombatMusicToogleOn()
	void SetListenerOnCameraToogle(bool toogle)
	bool IsListenerOnCameraToogleOn()

	void PlaySound(string fileName, bool loop, iSoundCtrl ctrl)
	void PlaySound(string fileName, bool loop, iSoundCtrl ctrl, csVector3 pos, csVector3 dir, float minDist, float maxDist)
	void StopSound(string fileName)

	void Update()
	void UpdateListener(iView view)
	void UpdateSoundPosition(string fileName, csVector3 position)
}

Sounds in factories

In CS every object has a factory and multiple instances, so you can have a mesh factory, which is a rock, and then instanciate it multiple times by changing its coords, rotation and texture. We would like to have the ability to associate sounds to the factories present in the world.

Distance lag effect of 3d emitters

Sound has a certain speed and openal unfortunately doesn't handle this factor so, even if it lowers the volume of distant sources, it will still make the sound of them run at the same time making the actual volume sound higher than it is actually. This would be about making emitters slow down when the player goes away from the source in order to unsync it from the other, more near emitters and go back to the normal speed after it has reached a certain offset from the more near object, in order to simulate this effect of distance and avoid equal sounds to stack.

Overall code cleanup

Here will follow a list of the cleanup interventions in the code.


Sounds events

We need to allow to play a sound when some events happen.

Random sounds on monsters

When they stand still and idle. If the race is an intelligent race, then we can play some phrases, if not we can just have screams/sounds.

Sounds associated to behaviours/actions of monsters

Like he is angry and plays the angry sound.

Sounds for each weapon and attack

If you attack with a sword you should hear the sound of a sword.

Random sounds from environment

Buzzes of flies, water for rivers, wind and so on so forth.


Musical instruments

This will allow players to use musical instruments.


Optional extensions

These things (or part of them) will be done during the GSoC coding time only time permitting. Otherwise they can still be included in the next GSoC or implemented by developers.

  • Add ability to limit number of channels. The idea is to be able to limit the amount of sounds played at the same time coming from different sources. In the same areas you can have rivers, monsters, wind, and even the player clicking on the UI.
  • Special actions to do when particular sound types are being played (for example reducing all other sounds/music volume)
  • Allow voice speech in game through peer to peer connection.
  • Have the walking sounds as a possible perception for monsters nearby. like a thief moving close to a monster to attack him first without making too much noise by walking, while a player with no sneak skills, will just make more noise while walking and the monster will hear this and attach him first.
  • Have the sound of a player walking that vary based on the ground; so if it's rocky texture it's harder sound, and if it's grass is softer sound.

Skills needed

Our server and client are all coded in C++ and the sounds are defined in XML files. For this project C++ knowledge is needed, some basic knowledge of XML. No MySQL knowledge is required.

Difficulty

medium to difficult, depending on the parts of this which are picked up