DirectMusic 0.0.1
An incomplete re-implementation of DirectMusic, Microsoft's adaptive soundtrack API for games delivered as part of Direct3D and DirectX
|
Data Structures | |
struct | DmGuid |
Contains a 128-bit GUID (aka UUID) value. More... | |
Typedefs | |
typedef enum DmResult | DmResult |
Possible operation result values. | |
typedef struct DmGuid | DmGuid |
Contains a 128-bit GUID (aka UUID) value. | |
typedef void * | DmMemoryAlloc(void *ctx, size_t len) |
A malloc -like memory allocation function. | |
typedef void | DmMemoryFree(void *ctx, void *ptr) |
A free -like memory de-allocation function. | |
typedef uint32_t | DmRng(void *ctx) |
A rand_r -like random number generation function. | |
typedef enum DmLogLevel | DmLogLevel |
The set of message levels supported by the logging facilities. | |
typedef void | DmLogHandler(void *ctx, DmLogLevel lvl, char const *msg) |
Enumerations | |
enum | DmResult { DmResult_SUCCESS = 0 , DmResult_INVALID_ARGUMENT , DmResult_INVALID_STATE , DmResult_MEMORY_EXHAUSTED , DmResult_NOT_FOUND , DmResult_FILE_CORRUPT , DmResult_MUTEX_ERROR } |
Possible operation result values. More... | |
enum | DmLogLevel { DmLogLevel_FATAL = 10 , DmLogLevel_ERROR = 20 , DmLogLevel_WARN = 30 , DmLogLevel_INFO = 40 , DmLogLevel_DEBUG = 50 , DmLogLevel_TRACE = 60 } |
The set of message levels supported by the logging facilities. More... | |
Functions | |
size_t | DmGuid_toString (DmGuid const *slf, char *out, size_t len) |
Convert the given GUID to a string. | |
DmResult | Dm_setHeapAllocator (DmMemoryAlloc *alloc, DmMemoryFree *free, void *ctx) |
Set the memory allocator to use internally. | |
void | Dm_setRandomNumberGenerator (DmRng *rng, void *ctx) |
Set the random number generator to use internally. | |
void | Dm_setLogger (DmLogLevel lvl, DmLogHandler *log, void *ctx) |
Set a callback to send log messages to. | |
void | Dm_setLoggerDefault (DmLogLevel lvl) |
Set a default logging function. | |
void | Dm_setLoggerLevel (DmLogLevel lvl) |
Set the log level of the library. | |
Contains a 128-bit GUID (aka UUID) value.
GUIDs are used in DirectMusic Segments, Styles, Bands and Downloadable Sound files as a way to uniquely identify distinct objects. For some of these objects, these GUIDs are exposed by their APIs. Many of these GUIDs could be manually set by the composer although generally, they are generated randomly by DirectMusic Producer upon object creation.
typedef void DmLogHandler(void *ctx, DmLogLevel lvl, char const *msg) |
typedef void * DmMemoryAlloc(void *ctx, size_t len) |
A malloc
-like memory allocation function.
Allocates len
bytes of contiguous memory and returns a pointer to the first byte allocated. May return NULL if memory allocation fails for any reason. In this case, function which relies on the allocation will fail with DmResult_MEMORY_EXHAUSTED to indicate memory allocation failure.
ctx[in] | An arbitrary pointer provided when calling Dm_setHeapAllocator. |
len[in] | The number of bytes to allocate. |
NULL | Memory allocation failed. |
typedef void DmMemoryFree(void *ctx, void *ptr) |
A free
-like memory de-allocation function.
De-allocates bytes starting a the memory location pointed to by ptr
, which were previously allocated by calling a corresponding DmMemoryAlloc function. This function must not fail. If ptr
is NULL
, this function must be a no-op.
ctx[in] | An arbitrary pointer provided when calling Dm_setHeapAllocator. |
ptr[in] | A pointer to free, previously returned by the corresponding DmMemoryAlloc function or NULL . |
typedef uint32_t DmRng(void *ctx) |
A rand_r
-like random number generation function.
Generates a random number between 0 and UINT32_MAX. Functions implementing this interface must be thread-safe. The function is not required to produce different numbers upon invocation and it does not need to be cryptographically secure. Calling a function implementing this interface should be inexpensive.
ctx[in] | An arbitrary pointer provided when calling Dm_setRandomNumberGenerator. |
enum DmLogLevel |
The set of message levels supported by the logging facilities.
enum DmResult |
Possible operation result values.
DmResult Dm_setHeapAllocator | ( | DmMemoryAlloc * | alloc, |
DmMemoryFree * | free, | ||
void * | ctx | ||
) |
Set the memory allocator to use internally.
This function should be called before calling any other library functions since, calling it after any allocation has been made internally will result in an error. It is guaranteed, however, that logging-related functions will never allocate.
alloc[in] | A malloc -like function, which allocates memory. May not be NULL. |
free[in] | A free -like function, which free memory previously allocated using alloc . May not be NULL. |
ctx[in] | An arbitrary pointer passed to alloc and free on every invocation. |
DmResult_INVALID_ARGUMENT | Either alloc or free was NULL . |
DmResult_INVALID_STATE | The function was called after an allocation was already made. |
void Dm_setLogger | ( | DmLogLevel | lvl, |
DmLogHandler * | log, | ||
void * | ctx | ||
) |
Set a callback to send log messages to.
Registers the given log
function to be called whenever a log message is issued by the library. The given ctx
pointer is passed alongside the log message on every invocation. If log
is set to NULL
, any existing log callback function is removed and logging is disabled.
lvl | The log level to set for the library. |
log[in] | The callback function to invoke whenever log message is generated or NULL |
ctx[in] | An arbitrary pointer passed to log on every invocation. |
void Dm_setLoggerDefault | ( | DmLogLevel | lvl | ) |
Set a default logging function.
Registers a default log handler which outputs all log messages at or above the given level to the standard error stream (stderr
).
lvl | The log level to set for the library. |
void Dm_setLoggerLevel | ( | DmLogLevel | lvl | ) |
Set the log level of the library.
lvl | The log level to set. |
void Dm_setRandomNumberGenerator | ( | DmRng * | rng, |
void * | ctx | ||
) |
Set the random number generator to use internally.
The given random number generator is sampled every time the library requires a random number. This includes but is not limited to:
rng[in] | A pointer to a function to use as a random number generator or NULL to reset to the default random number generator. |
ctx[in] | An arbitrary pointer passed to rng on every invocation. |
size_t DmGuid_toString | ( | DmGuid const * | slf, |
char * | out, | ||
size_t | len | ||
) |
Convert the given GUID to a string.
The output string is generated in 8-4-4-4-12 format and thus needs 36 chars (excl. nul-terminator) to be fully converted. The number of chars actually converted can be obtained from the return value.
slf[in] | The GUID to convert to a string. |
out[out] | The output buffer to write the chars to. |
len | The maximum number of bytes available in the out buffer. |
out
buffer.