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
cf024cb7
Commit
cf024cb7
authored
Jan 01, 2022
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix an error in the simple_mixing example.
Public issue
https://github.com/mackron/miniaudio/issues/388
parent
42abbbea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
examples/simple_mixing.c
examples/simple_mixing.c
+7
-6
No files found.
examples/simple_mixing.c
View file @
cf024cb7
...
@@ -48,21 +48,22 @@ ma_uint32 read_and_mix_pcm_frames_f32(ma_decoder* pDecoder, float* pOutputF32, m
...
@@ -48,21 +48,22 @@ ma_uint32 read_and_mix_pcm_frames_f32(ma_decoder* pDecoder, float* pOutputF32, m
contents of the output buffer by simply adding the samples together. You could also clip the samples to -1..+1, but I'm not
contents of the output buffer by simply adding the samples together. You could also clip the samples to -1..+1, but I'm not
doing that in this example.
doing that in this example.
*/
*/
ma_result
result
;
float
temp
[
4096
];
float
temp
[
4096
];
ma_uint32
tempCapInFrames
=
ma_countof
(
temp
)
/
CHANNEL_COUNT
;
ma_uint32
tempCapInFrames
=
ma_countof
(
temp
)
/
CHANNEL_COUNT
;
ma_uint32
totalFramesRead
=
0
;
ma_uint32
totalFramesRead
=
0
;
while
(
totalFramesRead
<
frameCount
)
{
while
(
totalFramesRead
<
frameCount
)
{
ma_uint
32
iSample
;
ma_uint
64
iSample
;
ma_uint
32
framesReadThisIteration
;
ma_uint
64
framesReadThisIteration
;
ma_uint32
totalFramesRemaining
=
frameCount
-
totalFramesRead
;
ma_uint32
totalFramesRemaining
=
frameCount
-
totalFramesRead
;
ma_uint32
framesToReadThisIteration
=
tempCapInFrames
;
ma_uint32
framesToReadThisIteration
=
tempCapInFrames
;
if
(
framesToReadThisIteration
>
totalFramesRemaining
)
{
if
(
framesToReadThisIteration
>
totalFramesRemaining
)
{
framesToReadThisIteration
=
totalFramesRemaining
;
framesToReadThisIteration
=
totalFramesRemaining
;
}
}
framesReadThisIteration
=
(
ma_uint32
)
ma_decoder_read_pcm_frames
(
pDecoder
,
temp
,
framesToReadThisIteration
,
NULL
);
result
=
ma_decoder_read_pcm_frames
(
pDecoder
,
temp
,
framesToReadThisIteration
,
&
framesReadThisIteration
);
if
(
framesReadThisIteration
==
0
)
{
if
(
result
!=
MA_SUCCESS
||
framesReadThisIteration
==
0
)
{
break
;
break
;
}
}
...
@@ -71,9 +72,9 @@ ma_uint32 read_and_mix_pcm_frames_f32(ma_decoder* pDecoder, float* pOutputF32, m
...
@@ -71,9 +72,9 @@ ma_uint32 read_and_mix_pcm_frames_f32(ma_decoder* pDecoder, float* pOutputF32, m
pOutputF32
[
totalFramesRead
*
CHANNEL_COUNT
+
iSample
]
+=
temp
[
iSample
];
pOutputF32
[
totalFramesRead
*
CHANNEL_COUNT
+
iSample
]
+=
temp
[
iSample
];
}
}
totalFramesRead
+=
framesReadThisIteration
;
totalFramesRead
+=
(
ma_uint32
)
framesReadThisIteration
;
if
(
framesReadThisIteration
<
framesToReadThisIteration
)
{
if
(
framesReadThisIteration
<
(
ma_uint32
)
framesToReadThisIteration
)
{
break
;
/* Reached EOF. */
break
;
/* Reached EOF. */
}
}
}
}
...
...
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