Drag[en]gine Game Engine  1.0
deSynthesizerInstance Class Reference

Synthesizer instance producing source using a synthesizer. More...

#include <deSynthesizerInstance.h>

Inheritance diagram for deSynthesizerInstance:
deResource deObject

Public Member Functions

Management
deSynthesizerGetSynthesizer () const
 Synthesizer or NULL if not set. More...
 
void SetSynthesizer (deSynthesizer *synthesizer)
 Set synthesizer or NULL to clear. More...
 
int GetSampleCount () const
 Number of samples to create. More...
 
void SetSampleCount (int sampleCount)
 Set number of samples to create. More...
 
int GetControllerCount () const
 Number of controllers. More...
 
deSynthesizerControllerGetControllerAt (int index) const
 Controller at index. More...
 
void NotifyControllerChangedAt (int index)
 Notify peer controller changed. More...
 
Generate sound
bool Prepare ()
 Prepare synthesizer. More...
 
void Reset ()
 Reset synthesizer playback. More...
 
void GenerateSound (void *buffer, int bufferSize, int offset, int samples)
 Generate sound. More...
 
System Peers
deBaseSynthesizerSynthesizerInstanceGetPeerSynthesizer () const
 Synthesizer peer or NULL if not set. More...
 
void SetPeerSynthesizer (deBaseSynthesizerSynthesizerInstance *peer)
 Set synthesizer peer or NULL if not set. More...
 
- Public Member Functions inherited from deResource
deResourceManagerGetResourceManager () const
 Resource manager or NULL if resource is leaking. More...
 
deEngineGetEngine () const
 Game engine object from resource manager. More...
 
deResourceGetLLManagerPrev () const
 Previous resource in the resource manager linked list. More...
 
void SetLLManagerPrev (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
deResourceGetLLManagerNext () const
 Next resource in the resource manager linked list. More...
 
void SetLLManagerNext (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
void MarkLeaking ()
 Marks the resource leaking. More...
 
 deResource (deResourceManager *resourceManager)
 Create resource. More...
 
- Public Member Functions inherited from deObject
int GetRefCount () const
 Reference count. More...
 
void AddReference ()
 Add reference increasing reference count by 1. More...
 
void FreeReference ()
 Decrease reference count by one and delete object if count reaches 0. More...
 
 deObject ()
 Create object with reference count of 1. More...
 

Constructors and Destructors

 deSynthesizerInstance (deSynthesizerInstanceManager *manager)
 Create synthesizer instance. More...
 
virtual ~deSynthesizerInstance ()
 Clean up the synthesizer instance. More...
 

Additional Inherited Members

- Protected Member Functions inherited from deResource
virtual ~deResource ()
 Clean up resource. More...
 
- Protected Member Functions inherited from deObject
virtual ~deObject ()
 Clean up object. More...
 

Detailed Description

Synthesizer instance producing source using a synthesizer.

Every synthesizer contains a set of sources and controllers indicating how the final sound is produced. While synthesizers define this production process the synthesizer instance produces the actual sound using per instance parameters.

Module interaction

Synthesizer instance has module interaction between synthesizer and audio module. The audio module has to call Prepare() before calling GenerateSound() every time since the internal synthesizer configuration can change at any time. This allows the synthesizer module to adjust internal parameters before generating sound. If Prepare() returns true the one or more of these synthesizer parameters changed since the last call to Prepare():

  • Synthesizer using SetSynthesizer() and its parameters differ from the last one.
  • Sample count using SetSampleCount() on instance or set synthesizer.
  • Sample rate on set synthesizer.
  • Bit count on set synthesizer.

Prepare() does not return true if the controllers, links or sources of the set synthesizer changed. true is only returned if a parameter changes affecting playback in an audio module like the sound data format

Starting playback on a speaker the audio module has to call Prepare().

For retrieving the next chunk of sample data the audio module has to call Prepare() and check the result. If true is returned the audio module has rewind to the beginning of the play range. Afterwards GenerateSound() is called.

The audio module can call Reset() on the synthesizer instance any time it wants to reset playback of the synthesizer but always only after calling Prepare() to make sure internal states are correct.

Author
Pl├╝ss Roland
Version
1.0
Date
2015

Constructor & Destructor Documentation

◆ deSynthesizerInstance()

deSynthesizerInstance::deSynthesizerInstance ( deSynthesizerInstanceManager manager)

Create synthesizer instance.

◆ ~deSynthesizerInstance()

virtual deSynthesizerInstance::~deSynthesizerInstance ( )
protectedvirtual

Clean up the synthesizer instance.

Note
Subclasses should set their destructor protected too to avoid users accidently deleting a reference counted object through the object pointer. Only FreeReference() is allowed to delete the object.

Member Function Documentation

◆ GenerateSound()

void deSynthesizerInstance::GenerateSound ( void *  buffer,
int  bufferSize,
int  offset,
int  samples 
)

Generate sound.

Parameters
[out]bufferBuffer to store samples in.
[in]bufferSizeSize of buffer in bytes to store samples in. Has to match format.
[in]offsetOffset in samples to produce sound at.
[in]samplesNumber of samples to produce.
Exceptions
EInvalidParambufferSize does not match format.
EInvalidParambuffer is NULL.

Referenced by GetSampleCount().

◆ GetControllerAt()

deSynthesizerController& deSynthesizerInstance::GetControllerAt ( int  index) const

Controller at index.

Exceptions
deeInvalidParamindex is less than 0 or greater or equal than GetControllerCount().

Referenced by GetSampleCount().

◆ GetControllerCount()

int deSynthesizerInstance::GetControllerCount ( ) const

Number of controllers.

Referenced by GetSampleCount().

◆ GetPeerSynthesizer()

deBaseSynthesizerSynthesizerInstance* deSynthesizerInstance::GetPeerSynthesizer ( ) const
inline

Synthesizer peer or NULL if not set.

References SetPeerSynthesizer().

◆ GetSampleCount()

int deSynthesizerInstance::GetSampleCount ( ) const
inline

◆ GetSynthesizer()

deSynthesizer* deSynthesizerInstance::GetSynthesizer ( ) const
inline

Synthesizer or NULL if not set.

References SetSynthesizer().

◆ NotifyControllerChangedAt()

void deSynthesizerInstance::NotifyControllerChangedAt ( int  index)

Notify peer controller changed.

Referenced by GetSampleCount().

◆ Prepare()

bool deSynthesizerInstance::Prepare ( )

Prepare synthesizer.

Has to be called before GenerateSound() is called.

Returns
true If playback relevant data changed. The audio module has to restart playing from the start of the play range. These are playback relevant data causing Prepare() to return true:
  • Synthesizer using SetSynthesizer() and its parameters differ from the last one.
  • Sample count using SetSampleCount() on instance or set synthesizer.
  • Sample rate on set synthesizer.
  • Bit count on set synthesizer.

Prepare() does not return true if the controllers, links or sources of the set synthesizer changed. true is only returned if a parameter changes affecting playback in an audio module like the sound data format

Referenced by GetSampleCount().

◆ Reset()

void deSynthesizerInstance::Reset ( )

Reset synthesizer playback.

Referenced by GetSampleCount().

◆ SetPeerSynthesizer()

void deSynthesizerInstance::SetPeerSynthesizer ( deBaseSynthesizerSynthesizerInstance peer)

Set synthesizer peer or NULL if not set.

Referenced by GetPeerSynthesizer().

◆ SetSampleCount()

void deSynthesizerInstance::SetSampleCount ( int  sampleCount)

Set number of samples to create.

Referenced by GetSampleCount().

◆ SetSynthesizer()

void deSynthesizerInstance::SetSynthesizer ( deSynthesizer synthesizer)

Set synthesizer or NULL to clear.

Referenced by GetSynthesizer().


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