Drag[en]gine Game Engine  1.21
deSynthesizerInstance Class Reference

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

#include <deSynthesizerInstance.h>

Inheritance diagram for deSynthesizerInstance:
deResource deObject

Public Types

typedef deTObjectReference< deSynthesizerInstanceRef
 Type holding strong reference. More...
 
- Public Types inherited from deResource
typedef deTObjectReference< deResourceRef
 Type holding strong reference. More...
 
- Public Types inherited from deObject
typedef deTObjectReference< deObjectRef
 Type holding strong reference. More...
 

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...
 
int IndexOfControllerNamed (const char *name) const
 Index of controller or -1 if absent. More...
 
void NotifyControllerChangedAt (int index)
 Notify peer controller changed. More...
 
Generate sound
void Reset ()
 Reset synthesizer playback. More...
 
void GenerateSound (void *buffer, int bufferSize, int offset, int samples)
 Generate sound. 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...
 

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...
 
deBaseAudioSynthesizerInstanceGetPeerAudio () const
 Audio peer or NULL if not set. More...
 
void SetPeerAudio (deBaseAudioSynthesizerInstance *peer)
 Set audio peer or NULL if not set. 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 calls GenerateSound() to obtain continuous sound to play. The synthesizer module will update internal states if required whenever GenerateSound() is called.

Because this requires the audio module and the synthesizer module to use the same sound data format it is not allowed for the user to change the synthesizer object while it is in use. It is thus correct for the audio module to assume the synthesizer format parameters (bytes per sample, channel count and sample rate) to stay constant as long as the synthesizer is assigned. Inconsistencies created by the user incorrectly manipulating the synthesizer object while it is in use has to be catched by the synthesizer module throwing an exception.

The audio module can call Reset() on the synthesizer instance any time it wants to reset playback.

To allow performant synthesizing of sound the audio and synthesizer module are allowed to run their work asynchronously. In particular this means GenerateSound() is allowed to be called asynchronously while any manipulation of the synthesizer instance states (like changing sample count or controller curves) is allowed only by the main thread. The synthesizer module has to be prepared to deal with this asynchronous handling safely.

Synthesizers can not be shared. If done so problems will most likely happen.

Member Typedef Documentation

◆ Ref

Type holding strong reference.

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.

Warning
Audio module is allowed to call this asynchronously.
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.
EInvalidParamAssigned synthesizer object changed while in use.

◆ GetControllerAt()

deSynthesizerController* deSynthesizerInstance::GetControllerAt ( int  index) const

Controller at index.

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

◆ GetControllerCount()

int deSynthesizerInstance::GetControllerCount ( ) const

Number of controllers.

◆ GetPeerAudio()

deBaseAudioSynthesizerInstance* deSynthesizerInstance::GetPeerAudio ( ) const
inline

Audio peer or NULL if not set.

◆ GetPeerSynthesizer()

deBaseSynthesizerSynthesizerInstance* deSynthesizerInstance::GetPeerSynthesizer ( ) const
inline

Synthesizer peer or NULL if not set.

◆ GetSampleCount()

int deSynthesizerInstance::GetSampleCount ( ) const
inline

Number of samples to create.

◆ GetSynthesizer()

deSynthesizer* deSynthesizerInstance::GetSynthesizer ( ) const
inline

Synthesizer or NULL if not set.

◆ IndexOfControllerNamed()

int deSynthesizerInstance::IndexOfControllerNamed ( const char *  name) const

Index of controller or -1 if absent.

◆ NotifyControllerChangedAt()

void deSynthesizerInstance::NotifyControllerChangedAt ( int  index)

Notify peer controller changed.

◆ Reset()

void deSynthesizerInstance::Reset ( )

Reset synthesizer playback.

Warning
Audio module is allowed to call this asynchronously.

◆ SetPeerAudio()

void deSynthesizerInstance::SetPeerAudio ( deBaseAudioSynthesizerInstance peer)

Set audio peer or NULL if not set.

◆ SetPeerSynthesizer()

void deSynthesizerInstance::SetPeerSynthesizer ( deBaseSynthesizerSynthesizerInstance peer)

Set synthesizer peer or NULL if not set.

◆ SetSampleCount()

void deSynthesizerInstance::SetSampleCount ( int  sampleCount)

Set number of samples to create.

◆ SetSynthesizer()

void deSynthesizerInstance::SetSynthesizer ( deSynthesizer synthesizer)

Set synthesizer or NULL to clear.


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