mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Relax restrictions on the maximum input and output buses for nodes.
Previously this was restricted to 2 input buses and 2 output buses, but this has been lifted to 254. When the number exceeds 2, internal data structures will be allocated on the heap, otherwise they'll use a local array contained within the ma_node structure. This commit changes the node configuration. Previously there was a fixed sized array for specifying the channel counts for each bus. This array must now be defined outside of the config by the caller. The following config variables have been renamed: * inputChannels > pInputChannels * outputChannels > pOutputChannels This commit also adds the ability to configure input and output bus counts on a per-instance basis rather than via the node vtable. To do this, set the bus count in the vtable to MA_NODE_BUS_COUNT_UNKNOWN. This will tell miniaudio to look at the node config to determine the bus count rather than the vtable. It's an error to specify this in the node config if the vtable specifies anything other than MA_NODE_BUS_COUNT_UNKNOWN.
This commit is contained in:
@@ -39,6 +39,8 @@ MA_API ma_result ma_vocoder_node_init(ma_node_graph* pNodeGraph, const ma_vocode
|
||||
{
|
||||
ma_result result;
|
||||
ma_node_config baseConfig;
|
||||
ma_uint32 inputChannels[2];
|
||||
ma_uint32 outputChannels[1];
|
||||
|
||||
if (pVocoderNode == NULL) {
|
||||
return MA_INVALID_ARGS;
|
||||
@@ -54,12 +56,14 @@ MA_API ma_result ma_vocoder_node_init(ma_node_graph* pNodeGraph, const ma_vocode
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
inputChannels [0] = pConfig->channels; /* Source/carrier. */
|
||||
inputChannels [1] = 1; /* Excite/modulator. Must always be single channel. */
|
||||
outputChannels[0] = pConfig->channels; /* Output channels is always the same as the source/carrier. */
|
||||
|
||||
baseConfig = pConfig->nodeConfig;
|
||||
baseConfig.vtable = &g_ma_vocoder_node_vtable;
|
||||
baseConfig.inputChannels [0] = pConfig->channels; /* Source/carrier. */
|
||||
baseConfig.inputChannels [1] = 1; /* Excite/modulator. Must always be single channel. */
|
||||
baseConfig.outputChannels[0] = pConfig->channels; /* Output channels is always the same as the source/carrier. */
|
||||
baseConfig.outputChannels[1] = 0; /* Unused. */
|
||||
baseConfig.vtable = &g_ma_vocoder_node_vtable;
|
||||
baseConfig.pInputChannels = inputChannels;
|
||||
baseConfig.pOutputChannels = outputChannels;
|
||||
|
||||
result = ma_node_init(pNodeGraph, &baseConfig, pAllocationCallbacks, &pVocoderNode->baseNode);
|
||||
if (result != MA_SUCCESS) {
|
||||
|
||||
@@ -13,7 +13,7 @@ effect.
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define DEVICE_FORMAT ma_format_f32; /* Must always be f32 for this example because the node graph system only works with this. */
|
||||
#define DEVICE_FORMAT ma_format_f32 /* Must always be f32 for this example because the node graph system only works with this. */
|
||||
#define DEVICE_CHANNELS 1 /* For this example, always set to 1. */
|
||||
|
||||
static ma_waveform g_sourceData; /* The underlying data source of the excite node. */
|
||||
|
||||
Reference in New Issue
Block a user