Drag[en]gine Game Engine 1.32.3
Loading...
Searching...
No Matches
deSynthesizerInstance Class Reference

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

#include <deSynthesizerInstance.h>

Inheritance diagram for deSynthesizerInstance:
deResource deObject

Public Types

using Ref = deTObjectReference< deSynthesizerInstance >
 Type holding strong reference.
 
- Public Types inherited from deResource
using Ref = deTObjectReference< deResource >
 Type holding strong reference.
 
- Public Types inherited from deObject
using Ref = deTObjectReference< deObject >
 Type holding strong reference.
 

Public Member Functions

Management
const deSynthesizer::RefGetSynthesizer () const
 Synthesizer or NULL if not set.
 
void SetSynthesizer (deSynthesizer *synthesizer)
 Set synthesizer or NULL to clear.
 
int GetSampleCount () const
 Number of samples to create.
 
void SetSampleCount (int sampleCount)
 Set number of samples to create.
 
const decTObjectOrderedSet< deSynthesizerController > & GetControllers () const
 Controllers.
 
int IndexOfControllerNamed (const char *name) const
 Index of controller or -1 if absent.
 
void NotifyControllerChangedAt (int index)
 Notify peer controller changed.
 
Generate sound
void Reset ()
 Reset synthesizer playback.
 
void GenerateSound (void *buffer, int bufferSize, int offset, int samples)
 Generate sound.
 
- Public Member Functions inherited from deResource
deResourceManagerGetResourceManager () const
 Resource manager or NULL if resource is leaking.
 
deEngineGetEngine () const
 Game engine object from resource manager.
 
decTLinkedList< deResource >::Element & GetLLManager ()
 Resource manager linked list.
 
const decTLinkedList< deResource >::Element & GetLLManager () const
 
void MarkLeaking ()
 Marks the resource leaking.
 
 deResource (deResourceManager *resourceManager)
 Create resource.
 
- Public Member Functions inherited from deObject
int GetRefCount () const
 Reference count.
 
void AddReference ()
 Add reference increasing reference count by 1.
 
void FreeReference ()
 Decrease reference count by one and delete object if count reaches 0.
 
cWeakRefDataAddWeakReference ()
 Add weak reference.
 
 deObject ()
 Create object with reference count of 1.
 

Constructors and Destructors

 deSynthesizerInstance (deSynthesizerInstanceManager *manager)
 Create synthesizer instance.
 
 deSynthesizerInstance (const deSynthesizerInstance &synthesizerInstance)=delete
 
deSynthesizerInstanceoperator= (const deSynthesizerInstance &synthesizerInstance)=delete
 
 ~deSynthesizerInstance () override
 Clean up the synthesizer instance.
 

System Peers

deBaseSynthesizerSynthesizerInstanceGetPeerSynthesizer () const
 Synthesizer peer or NULL if not set.
 
void SetPeerSynthesizer (deBaseSynthesizerSynthesizerInstance *peer)
 Set synthesizer peer or NULL if not set.
 
deBaseAudioSynthesizerInstanceGetPeerAudio () const
 Audio peer or NULL if not set.
 
void SetPeerAudio (deBaseAudioSynthesizerInstance *peer)
 Set audio peer or NULL if not set.
 

Additional Inherited Members

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

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() [1/2]

deSynthesizerInstance::deSynthesizerInstance ( deSynthesizerInstanceManager manager)

Create synthesizer instance.

◆ deSynthesizerInstance() [2/2]

deSynthesizerInstance::deSynthesizerInstance ( const deSynthesizerInstance synthesizerInstance)
delete

◆ ~deSynthesizerInstance()

deSynthesizerInstance::~deSynthesizerInstance ( )
overrideprotected

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.

◆ GetControllers()

const decTObjectOrderedSet< deSynthesizerController > & deSynthesizerInstance::GetControllers ( ) const
inline

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()

const deSynthesizer::Ref & 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.

◆ operator=()

deSynthesizerInstance & deSynthesizerInstance::operator= ( const deSynthesizerInstance synthesizerInstance)
delete

◆ 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: