Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
8517b100
Commit
8517b100
authored
Aug 11, 2022
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor style changes.
parent
e327450d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
16 deletions
+30
-16
miniaudio.h
miniaudio.h
+30
-16
No files found.
miniaudio.h
View file @
8517b100
...
@@ -5521,11 +5521,12 @@ The channel map buffer must have a capacity of at least `channels`.
...
@@ -5521,11 +5521,12 @@ The channel map buffer must have a capacity of at least `channels`.
MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition);
MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition);
/*
/*
Find a channel position in the given channel map. Returns index of channel or -1 if not found.
Find a channel position in the given channel map. Returns MA_TRUE if the channel is found; MA_FALSE otherwise. The
index of the channel is output to `pChannelIndex`.
The channel map buffer must have a capacity of at least `channels`.
The channel map buffer must have a capacity of at least `channels`.
*/
*/
MA_API ma_
int32 ma_channel_map_find_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition
);
MA_API ma_
bool32 ma_channel_map_find_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition, ma_uint32* pChannelIndex
);
/*
/*
Generates a string representing the given channel map.
Generates a string representing the given channel map.
...
@@ -50495,17 +50496,20 @@ static ma_int32 ma_channel_converter_float_to_fixed(float x)
...
@@ -50495,17 +50496,20 @@ static ma_int32 ma_channel_converter_float_to_fixed(float x)
return (ma_int32)(x * (1<<MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT));
return (ma_int32)(x * (1<<MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT));
}
}
static ma_
int32 ma_channel_map_num_spatial_channels
(const ma_channel* pChannelMap, ma_uint32 channels)
static ma_
uint32 ma_channel_map_get_spatial_channel_count
(const ma_channel* pChannelMap, ma_uint32 channels)
{
{
ma_
int32 numSpatialChannels
= 0;
ma_
uint32 spatialChannelCount
= 0;
ma_uint32 iChannel;
ma_uint32 iChannel;
MA_ASSERT(pChannelMap != NULL);
MA_ASSERT(pChannelMap != NULL);
MA_ASSERT(channels > 0);
MA_ASSERT(channels > 0);
for (iChannel = 0; iChannel < channels; ++iChannel) {
for (iChannel = 0; iChannel < channels; ++iChannel) {
if (ma_is_spatial_channel_position(pChannelMap[iChannel]))
if (ma_is_spatial_channel_position(pChannelMap[iChannel]))
numSpatialChannels
++;
spatialChannelCount
++;
}
}
return numSpatialChannels;
return spatialChannelCount;
}
}
static ma_bool32 ma_is_spatial_channel_position(ma_channel channelPosition)
static ma_bool32 ma_is_spatial_channel_position(ma_channel channelPosition)
...
@@ -51361,11 +51365,12 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert
...
@@ -51361,11 +51365,12 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert
}
}
/* If LFE is in the output channel map but was not present in the input channel map, configure its weight now */
/* If LFE is in the output channel map but was not present in the input channel map, configure its weight now */
if (ma_channel_map_find_channel_position(pConverter->channelsIn, pConverter->pChannelMapIn, MA_CHANNEL_LFE) == -1) {
if (!ma_channel_map_contains_channel_position(pConverter->channelsIn, pConverter->pChannelMapIn, MA_CHANNEL_LFE)) {
const ma_int32 numSpatialChannels = ma_channel_map_num_spatial_channels(pConverter->pChannelMapIn, pConverter->channelsIn);
ma_uint32 spatialChannelCount = ma_channel_map_get_spatial_channel_count(pConverter->pChannelMapIn, pConverter->channelsIn);
const ma_int32 iChannelOutLFE = ma_channel_map_find_channel_position(pConverter->channelsOut, pConverter->pChannelMapOut, MA_CHANNEL_LFE);
ma_uint32 iChannelOutLFE;
if (numSpatialChannels > 0 && iChannelOutLFE != -1) {
const float weightForLFE = 1.0f / (float)numSpatialChannels;
if (spatialChannelCount > 0 && ma_channel_map_find_channel_position(pConverter->channelsOut, pConverter->pChannelMapOut, MA_CHANNEL_LFE, &iChannelOutLFE)) {
const float weightForLFE = 1.0f / spatialChannelCount;
for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
const ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn);
const ma_channel channelPosIn = ma_channel_map_get_channel(pConverter->pChannelMapIn, pConverter->channelsIn, iChannelIn);
if (ma_is_spatial_channel_position(channelPosIn)) {
if (ma_is_spatial_channel_position(channelPosIn)) {
...
@@ -53807,20 +53812,29 @@ MA_API ma_bool32 ma_channel_map_is_blank(const ma_channel* pChannelMap, ma_uint3
...
@@ -53807,20 +53812,29 @@ MA_API ma_bool32 ma_channel_map_is_blank(const ma_channel* pChannelMap, ma_uint3
MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition)
MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition)
{
{
return ma_channel_map_find_channel_position(channels, pChannelMap, channelPosition
) != -1 ? MA_TRUE : MA_FALSE
;
return ma_channel_map_find_channel_position(channels, pChannelMap, channelPosition
, NULL)
;
}
}
MA_API ma_
int32 ma_channel_map_find_channel_position(ma_uint32 channels, const ma_channel *pChannelMap, ma_channel channelPosition
)
MA_API ma_
bool32 ma_channel_map_find_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition, ma_uint32* pChannelIndex
)
{
{
ma_int32 iChannel;
ma_uint32 iChannel;
if (pChannelIndex != NULL) {
*pChannelIndex = (ma_uint32)-1;
}
for (iChannel = 0; iChannel < channels; ++iChannel) {
for (iChannel = 0; iChannel < channels; ++iChannel) {
if (ma_channel_map_get_channel(pChannelMap, channels, iChannel) == channelPosition) {
if (ma_channel_map_get_channel(pChannelMap, channels, iChannel) == channelPosition) {
return iChannel;
if (pChannelIndex != NULL) {
*pChannelIndex = iChannel;
}
return MA_TRUE;
}
}
}
}
return -1;
/* Getting here means the channel position was not found. */
return MA_FALSE;
}
}
MA_API size_t ma_channel_map_to_string(const ma_channel* pChannelMap, ma_uint32 channels, char* pBufferOut, size_t bufferCap)
MA_API size_t ma_channel_map_to_string(const ma_channel* pChannelMap, ma_uint32 channels, char* pBufferOut, size_t bufferCap)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment