Drag[en]gine Game Engine
1.21
|
Synthesizer instance producing source using a synthesizer. More...
#include <deSynthesizerInstance.h>
Public Types | |
typedef deTObjectReference< deSynthesizerInstance > | Ref |
Type holding strong reference. More... | |
Public Types inherited from deResource | |
typedef deTObjectReference< deResource > | Ref |
Type holding strong reference. More... | |
Public Types inherited from deObject | |
typedef deTObjectReference< deObject > | Ref |
Type holding strong reference. More... | |
Public Member Functions | |
Management | |
deSynthesizer * | GetSynthesizer () 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... | |
deSynthesizerController * | GetControllerAt (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 | |
deResourceManager * | GetResourceManager () const |
Resource manager or NULL if resource is leaking. More... | |
deEngine * | GetEngine () const |
Game engine object from resource manager. More... | |
deResource * | GetLLManagerPrev () const |
Previous resource in the resource manager linked list. More... | |
void | SetLLManagerPrev (deResource *resource) |
Set next resource in the resource manager linked list. More... | |
deResource * | GetLLManagerNext () 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 | |
deBaseSynthesizerSynthesizerInstance * | GetPeerSynthesizer () const |
Synthesizer peer or NULL if not set. More... | |
void | SetPeerSynthesizer (deBaseSynthesizerSynthesizerInstance *peer) |
Set synthesizer peer or NULL if not set. More... | |
deBaseAudioSynthesizerInstance * | GetPeerAudio () 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... | |
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.
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.
Type holding strong reference.
deSynthesizerInstance::deSynthesizerInstance | ( | deSynthesizerInstanceManager * | manager | ) |
Create synthesizer instance.
|
protectedvirtual |
Clean up the synthesizer instance.
void deSynthesizerInstance::GenerateSound | ( | void * | buffer, |
int | bufferSize, | ||
int | offset, | ||
int | samples | ||
) |
Generate sound.
[out] | buffer | Buffer to store samples in. |
[in] | bufferSize | Size of buffer in bytes to store samples in. Has to match format. |
[in] | offset | Offset in samples to produce sound at. |
[in] | samples | Number of samples to produce. |
EInvalidParam | bufferSize does not match format. |
EInvalidParam | buffer is NULL. |
EInvalidParam | Assigned synthesizer object changed while in use. |
deSynthesizerController* deSynthesizerInstance::GetControllerAt | ( | int | index | ) | const |
Controller at index.
deeInvalidParam | index is less than 0 or greater or equal than GetControllerCount(). |
int deSynthesizerInstance::GetControllerCount | ( | ) | const |
Number of controllers.
|
inline |
Audio peer or NULL if not set.
|
inline |
Synthesizer peer or NULL if not set.
|
inline |
Number of samples to create.
|
inline |
Synthesizer or NULL if not set.
int deSynthesizerInstance::IndexOfControllerNamed | ( | const char * | name | ) | const |
Index of controller or -1 if absent.
void deSynthesizerInstance::NotifyControllerChangedAt | ( | int | index | ) |
Notify peer controller changed.
void deSynthesizerInstance::Reset | ( | ) |
Reset synthesizer playback.
void deSynthesizerInstance::SetPeerAudio | ( | deBaseAudioSynthesizerInstance * | peer | ) |
Set audio peer or NULL if not set.
void deSynthesizerInstance::SetPeerSynthesizer | ( | deBaseSynthesizerSynthesizerInstance * | peer | ) |
Set synthesizer peer or NULL if not set.
void deSynthesizerInstance::SetSampleCount | ( | int | sampleCount | ) |
Set number of samples to create.
void deSynthesizerInstance::SetSynthesizer | ( | deSynthesizer * | synthesizer | ) |
Set synthesizer or NULL to clear.