Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Audio::Renderer Class Referenceabstract

#include <Renderer.h>

Inheritance diagram for Audio::Renderer:
Audio::OpenALRenderer Audio::BorrowedOpenALRenderer

Public Member Functions

 Renderer () throw (Exception)
 
virtual ~Renderer ()
 
virtual SharedPtr< SoundgetSound (const std::string &name, VSFileSystem::VSFileType type=VSFileSystem::UnknownFile, bool streaming=false)=0 throw (Exception)
 
virtual bool owns (SharedPtr< Sound > sound)=0
 
virtual void attach (SharedPtr< Source > source)=0 throw (Exception)
 
virtual void attach (SharedPtr< Listener > listener)=0 throw (Exception)
 
virtual void detach (SharedPtr< Source > source)=0 throw ()
 
virtual void detach (SharedPtr< Listener > listener)=0 throw ()
 
virtual void setMeterDistance (Scalar distance) throw ()
 
virtual Scalar getMeterDistance () const throw ()
 
virtual void setDopplerFactor (Scalar factor) throw ()
 
virtual Scalar getDopplerFactor () const throw ()
 
virtual void setOutputFormat (const Format &format) throw (Exception)
 
virtual const FormatgetOutputFormat () const throw ()
 
virtual void beginTransaction () throw (Exception)
 
virtual void commitTransaction () throw (Exception)
 

Detailed Description

Audio Renderer interface.

Remarks
Audio renderer implementations will implement this interface to communicate with SceneManager s.
Renderers are also the factories for sound resources, since most APIs already
handle sample storage and other sound resource aspects.
The interface is rather simple since most operations are done through
RenderableSource proxies.

Definition at line 36 of file Renderer.h.

Constructor & Destructor Documentation

Audio::Renderer::Renderer ( )
throw (Exception
)

Initialize the renderer with default or config-driven settings.

Remarks
End-users might want to use specific constructors of specific renderers.

Definition at line 10 of file Renderer.cpp.

11  {
12  }
Audio::Renderer::~Renderer ( )
virtual

Definition at line 14 of file Renderer.cpp.

15  {
16  }

Member Function Documentation

virtual void Audio::Renderer::attach ( SharedPtr< Source source)
throw (Exception
)
pure virtual

Attach a source to this renderer

Remarks
A source may only be attached to one renderer. If the source was attached already, an exception will be thrown.
Attachment may mean resource allocation. Either immediate or deferred. So it may
fail if resources are scarce.

Implemented in Audio::OpenALRenderer.

virtual void Audio::Renderer::attach ( SharedPtr< Listener listener)
throw (Exception
)
pure virtual

Attach a listener to this renderer

Remarks
A listener may only be attached to one renderer. If the listener was attached already, an exception will be thrown.
Attachment may mean resource allocation. Either immediate or deferred. So it may
fail if resources are scarce.

Implemented in Audio::OpenALRenderer.

void Audio::Renderer::beginTransaction ( )
throw (Exception
)
virtual

Begins a transaction

Remarks
state changes will be piled up and applied at commit. This is, though, an optional feature: renderers may choose not to implement it, and perform state changes immediately. In any case, the result ought to be the same.

Reimplemented in Audio::OpenALRenderer.

Definition at line 54 of file Renderer.cpp.

56  {
57  // intentionally blank
58  }
void Audio::Renderer::commitTransaction ( )
throw (Exception
)
virtual
See Also
begin()

Reimplemented in Audio::OpenALRenderer.

Definition at line 60 of file Renderer.cpp.

62  {
63  // intentionally blank
64  }
virtual void Audio::Renderer::detach ( SharedPtr< Source source)
throw (
)
pure virtual

Detach a source from this renderer.

Remarks
Immediately frees any allocated resources.

Implemented in Audio::OpenALRenderer.

virtual void Audio::Renderer::detach ( SharedPtr< Listener listener)
throw (
)
pure virtual

Detach a listener from this renderer.

Remarks
Immediately frees any allocated resources.

Implemented in Audio::OpenALRenderer.

Scalar Audio::Renderer::getDopplerFactor ( ) const
throw (
)
virtual

Gets how much the doppler effect will be accounted for.

See Also
setDopplerFactor

Definition at line 36 of file Renderer.cpp.

38  {
39  return dopplerFactor;
40  }
Scalar Audio::Renderer::getMeterDistance ( ) const
throw (
)
virtual

Gets the distance in world units that represents one meter.

See Also
setMeterDistance

Definition at line 24 of file Renderer.cpp.

26  {
27  return meterDistance;
28  }
const Format & Audio::Renderer::getOutputFormat ( ) const
throw (
)
virtual

Gets the distance in world units that represents one meter.

See Also
setMeterDistance

Definition at line 48 of file Renderer.cpp.

50  {
51  return outputFormat;
52  }
virtual SharedPtr<Sound> Audio::Renderer::getSound ( const std::string &  name,
VSFileSystem::VSFileType  type = VSFileSystem::UnknownFile,
bool  streaming = false 
)
throw (Exception
)
pure virtual

Create a sound, from the stream of the specified name.

Parameters
nameThe path of the soundfile.
typeThe file type (needed by the filesystem).
straemingIf true, requests for a streaming sound - one that is not loaded to memory for playback, but rather read on-demand during playback.
Remarks
The name is the path of a soundstream as it would be passed to the CodecRegistry.
Streaming sounds can also be created, which depending on the renderer implementation
may or may not result in a different kind of sound resource. Most notably, the difference may depend on runtime-dependant state. For instance, it is quite reasonable that a streaming sound won't be created if the same sound file exists in a non-streaming form.
See Also
CodecRegistry

Implemented in Audio::OpenALRenderer.

virtual bool Audio::Renderer::owns ( SharedPtr< Sound sound)
pure virtual

Return whether the specified sound has been created using this renderer or not

Implemented in Audio::OpenALRenderer.

void Audio::Renderer::setDopplerFactor ( Scalar  factor)
throw (
)
virtual

Sets how much the doppler effect will be accounted for.

Remarks
This sets a semi-opaque value which controls how much of the doppler effect will be simulated. All that is required is that 0 maps to fully disabled doppler effect, 1 maps to a realistic effect, in between a disimulated effect, and above 1 an exaggerated effect. The spec is purposefully vague on the specifics.

Reimplemented in Audio::OpenALRenderer.

Definition at line 30 of file Renderer.cpp.

Referenced by Audio::OpenALRenderer::setDopplerFactor().

32  {
33  dopplerFactor = factor;
34  }
void Audio::Renderer::setMeterDistance ( Scalar  distance)
throw (
)
virtual

Sets the distance in world units that represents one meter.

Remarks
This reference distance is required by environmental effect processing to accurately account for distance factors beyond simple gain falloff.

Reimplemented in Audio::OpenALRenderer.

Definition at line 18 of file Renderer.cpp.

Referenced by Audio::OpenALRenderer::setMeterDistance().

20  {
21  meterDistance = distance;
22  }
void Audio::Renderer::setOutputFormat ( const Format format)
throw (Exception
)
virtual

Sets the (preferred) output format.

Remarks
Renderers are encouraged to set their effective output format to the closest "better" format, where better is defined as either having heigher sampling frequency, bit depth, or number of channels. The effective output format, if known, must be reflected in subsequent calls to getOutputFormat.

Reimplemented in Audio::OpenALRenderer, and Audio::BorrowedOpenALRenderer.

Definition at line 42 of file Renderer.cpp.

Referenced by Audio::BorrowedOpenALRenderer::setOutputFormat(), and Audio::OpenALRenderer::setOutputFormat().

44  {
45  outputFormat = format;
46  }

The documentation for this class was generated from the following files: