Initial Commit

This commit is contained in:
2026-02-12 11:46:06 +03:00
commit b044c8d1a5
3973 changed files with 1599881 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
#ifndef miniaudio_channel_combiner_node_c
#define miniaudio_channel_combiner_node_c
#include "ma_channel_combiner_node.h"
#include <string.h> /* For memset(). */
MA_API ma_channel_combiner_node_config ma_channel_combiner_node_config_init(ma_uint32 channels)
{
ma_channel_combiner_node_config config;
memset(&config, 0, sizeof(config));
config.nodeConfig = ma_node_config_init(); /* Input and output channels will be set in ma_channel_combiner_node_init(). */
config.channels = channels;
return config;
}
static void ma_channel_combiner_node_process_pcm_frames(ma_node* pNode, const float** ppFramesIn, ma_uint32* pFrameCountIn, float** ppFramesOut, ma_uint32* pFrameCountOut)
{
ma_channel_combiner_node* pCombinerNode = (ma_channel_combiner_node*)pNode;
(void)pFrameCountIn;
ma_interleave_pcm_frames(ma_format_f32, ma_node_get_output_channels(pCombinerNode, 0), *pFrameCountOut, (const void**)ppFramesIn, (void*)ppFramesOut[0]);
}
static ma_node_vtable g_ma_channel_combiner_node_vtable =
{
ma_channel_combiner_node_process_pcm_frames,
NULL,
MA_NODE_BUS_COUNT_UNKNOWN, /* Input bus count is determined by the channel count and is unknown until the node instance is initialized. */
1, /* 1 output bus. */
0 /* Default flags. */
};
MA_API ma_result ma_channel_combiner_node_init(ma_node_graph* pNodeGraph, const ma_channel_combiner_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_channel_combiner_node* pCombinerNode)
{
ma_result result;
ma_node_config baseConfig;
ma_uint32 inputChannels[MA_MAX_NODE_BUS_COUNT];
ma_uint32 outputChannels[1];
ma_uint32 iChannel;
if (pCombinerNode == NULL) {
return MA_INVALID_ARGS;
}
memset(pCombinerNode, 0, sizeof(*pCombinerNode));
if (pConfig == NULL) {
return MA_INVALID_ARGS;
}
/* All input channels are mono. */
for (iChannel = 0; iChannel < pConfig->channels; iChannel += 1) {
inputChannels[iChannel] = 1;
}
outputChannels[0] = pConfig->channels;
baseConfig = pConfig->nodeConfig;
baseConfig.vtable = &g_ma_channel_combiner_node_vtable;
baseConfig.inputBusCount = pConfig->channels; /* The vtable has an unknown channel count, so must specify it here. */
baseConfig.pInputChannels = inputChannels;
baseConfig.pOutputChannels = outputChannels;
result = ma_node_init(pNodeGraph, &baseConfig, pAllocationCallbacks, &pCombinerNode->baseNode);
if (result != MA_SUCCESS) {
return result;
}
return MA_SUCCESS;
}
MA_API void ma_channel_combiner_node_uninit(ma_channel_combiner_node* pCombinerNode, const ma_allocation_callbacks* pAllocationCallbacks)
{
/* The base node is always uninitialized first. */
ma_node_uninit(pCombinerNode, pAllocationCallbacks);
}
#endif /* miniaudio_channel_combiner_node_c */

View File

@@ -0,0 +1,32 @@
/* Include ma_channel_combiner_node.h after miniaudio.h */
#ifndef miniaudio_channel_combiner_node_h
#define miniaudio_channel_combiner_node_h
#include "../../../miniaudio.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
ma_node_config nodeConfig;
ma_uint32 channels;
} ma_channel_combiner_node_config;
MA_API ma_channel_combiner_node_config ma_channel_combiner_node_config_init(ma_uint32 channels);
typedef struct
{
ma_node_base baseNode;
} ma_channel_combiner_node;
MA_API ma_result ma_channel_combiner_node_init(ma_node_graph* pNodeGraph, const ma_channel_combiner_node_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_channel_combiner_node* pSeparatorNode);
MA_API void ma_channel_combiner_node_uninit(ma_channel_combiner_node* pSeparatorNode, const ma_allocation_callbacks* pAllocationCallbacks);
#ifdef __cplusplus
}
#endif
#endif /* miniaudio_channel_combiner_node_h */

View File

@@ -0,0 +1,2 @@
/* The channel separator example also demonstrates how to use the combiner. */
#include "../ma_channel_separator_node/ma_channel_separator_node_example.c"