DirectMusic 0.0.1
An incomplete re-implementation of DirectMusic, Microsoft's adaptive soundtrack API for games delivered as part of Direct3D and DirectX
|
TODO. More...
Typedefs | |
typedef struct DmPerformance | DmPerformance |
Represents a DirectMusic Performance. | |
typedef enum DmRenderOptions | DmRenderOptions |
typedef enum DmTiming | DmTiming |
typedef enum DmEmbellishmentType | DmEmbellishmentType |
Embellishment types for choosing transition patterns. | |
Enumerations | |
enum | DmRenderOptions { DmRender_SHORT = 1 << 0 , DmRender_FLOAT = 1 << 1 , DmRender_STEREO = 1 << 2 } |
enum | DmTiming { DmTiming_INSTANT = 1 , DmTiming_GRID = 2 , DmTiming_BEAT = 3 , DmTiming_MEASURE = 4 } |
enum | DmEmbellishmentType { DmEmbellishment_NONE = 0 , DmEmbellishment_GROOVE = 1 , DmEmbellishment_FILL = 2 , DmEmbellishment_INTRO = 3 , DmEmbellishment_BREAK = 4 , DmEmbellishment_END = 5 , DmEmbellishment_END_AND_INTRO = 6 } |
Embellishment types for choosing transition patterns. More... | |
Functions | |
DmResult | DmPerformance_create (DmPerformance **slf, uint32_t rate) |
Create a new DirectMusic Performance object. | |
DmPerformance * | DmPerformance_retain (DmPerformance *slf) |
Add one to the reference count of a performance. | |
void | DmPerformance_release (DmPerformance *slf) |
Subtract one from the reference count of a performance. | |
DmResult | DmPerformance_playSegment (DmPerformance *slf, DmSegment *sgt, DmTiming timing) |
Schedule a new segment to be played by the given performance. | |
DmResult | DmPerformance_playTransition (DmPerformance *slf, DmSegment *sgt, DmEmbellishmentType embellishment, DmTiming timing) |
Schedule a new segment to play by the given performance with a transition. | |
DmResult | DmPerformance_renderPcm (DmPerformance *slf, void *buf, size_t num, DmRenderOptions opts) |
Render a given number of PCM samples from a performance. | |
void | DmPerformance_setVolume (DmPerformance *slf, float vol) |
Set the playback volume of a performance. | |
TODO.
typedef struct DmPerformance DmPerformance |
enum DmEmbellishmentType |
Embellishment types for choosing transition patterns.
Enumerator | |
---|---|
DmEmbellishment_NONE | Don't choose a pattern. |
DmEmbellishment_GROOVE | Only choose patterns with the default 'groove' embellishment. |
DmEmbellishment_FILL | Only choose patterns with the 'fill' embellishment. |
DmEmbellishment_INTRO | Only choose patterns with the 'intro' embellishment. |
DmEmbellishment_BREAK | Only choose patterns with the 'break' embellishment. |
DmEmbellishment_END | Only choose patterns with the 'end' embellishment. |
DmEmbellishment_END_AND_INTRO | Choose two patterns, one with the 'end' embellishment from the playing segment and one with the 'intro' embellishment from the new segment and play them back-to-back.
|
enum DmRenderOptions |
enum DmTiming |
DmResult DmPerformance_create | ( | DmPerformance ** | slf, |
uint32_t | rate | ||
) |
Create a new DirectMusic Performance object.
slf[out] | A pointer to a variable in which to store the newly created performance. |
rate | The sample rate for the synthesizer. Provide 0 to use the default (44100 Hz). |
DmResult_INVALID_ARGUMENT | slf was NULL . |
DmResult_MEMORY_EXHAUSTED | A dynamic memory allocation failed. |
DmResult DmPerformance_playSegment | ( | DmPerformance * | slf, |
DmSegment * | sgt, | ||
DmTiming | timing | ||
) |
Schedule a new segment to be played by the given performance.
The segment is played at the next timing boundary provided with timing
. This function simply stops the currently playing segment and starts playing the next one. To play a transition between the two segments, use DmPerformance_playTransition.
slf[in] | The performance to play the segment in. |
sgt[in] | The segment to play or NULL to simply stop the playing segment. |
timing | The timing bounding to start playing the segment at. |
DmResult_INVALID_ARGUMENT | slf was NULL . |
DmResult_MEMORY_EXHAUSTED | A dynamic memory allocation failed. |
DmResult_MUTEX_ERROR | An error occurred while trying to lock an internal mutex. |
DmResult DmPerformance_playTransition | ( | DmPerformance * | slf, |
DmSegment * | sgt, | ||
DmEmbellishmentType | embellishment, | ||
DmTiming | timing | ||
) |
Schedule a new segment to play by the given performance with a transition.
Schedules a new transitional segment to be played, which first plays a transitional pattern from the currently playing segment's style and then starts playing the given segment. This can be used to smoothly transition from one segment to another.
The transitional pattern is selected by its embellishment
type provided when calling the function. Only embellishments matching the current groove level are considered.
slf[in] | The performance to play the transition in. |
sgt[in] | The segment to transition to or NULL to transition to silence. |
embellishment | The embellishment type to use for the transition. |
timing | The timing bounding to start playing the transition at. |
DmResult_INVALID_ARGUMENT | slf or sgt was NULL . |
DmResult_MEMORY_EXHAUSTED | A dynamic memory allocation failed. |
DmResult_MUTEX_ERROR | An error occurred while trying to lock an internal mutex. |
void DmPerformance_release | ( | DmPerformance * | slf | ) |
Subtract one from the reference count of a performance.
If a call to this function reduces the reference count to zero, it also de-allocates the performance and releases any resources referenced by it.
slf[in] | The performance to release. |
DmResult DmPerformance_renderPcm | ( | DmPerformance * | slf, |
void * | buf, | ||
size_t | num, | ||
DmRenderOptions | opts | ||
) |
Render a given number of PCM samples from a performance.
Since the performance is played "on demand", calling this function will advance the internal clock and perform all musical operation for the rendered timeframe. If no segment is currently playing, the output will be set to zero samples.
Using the opts
parameter, you can control what data is output. The DmRender_SHORT and DmRender_FLOAT bits indicate the format of the PCM data to output (either as int16_t or 32-bit float). All data is output as host-endian. Setting the DmRender_STEREO bit renders interleaved stereo samples.
slf[in] | The performance to render from. |
buf[out] | A buffer to render PCM into. |
num | The number of elements available in buf . This will be equal to the number of samples when rendering mono PCM or 2 time the number of samples when rendering stereo. |
opts | A bitfield with options for the renderer. |
DmResult_INVALID_ARGUMENT | slf or buf was NULL , opts included multiple format specifiers or opts included DmRender_STEREO and num was not even. |
DmResult_MEMORY_EXHAUSTED | A dynamic memory allocation failed. |
DmResult_MUTEX_ERROR | An error occurred while trying to lock an internal mutex. |
DmPerformance * DmPerformance_retain | ( | DmPerformance * | slf | ) |
Add one to the reference count of a performance.
slf[in] | The performance to retain. |
slf
or NULL
if slf
was NULL
. void DmPerformance_setVolume | ( | DmPerformance * | slf, |
float | vol | ||
) |
Set the playback volume of a performance.
slf[in] | The performance to set the volume of. |
vol | The new volume to set (between 0 and 1). |