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
86a0e65d
Commit
86a0e65d
authored
Feb 09, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update examples.
parent
7aac6949
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
11 deletions
+24
-11
examples/README.md
examples/README.md
+14
-1
examples/fixed_size_callback.c
examples/fixed_size_callback.c
+5
-5
examples/simple_loopback.c
examples/simple_loopback.c
+1
-1
tests/ma_duplex.c
tests/ma_duplex.c
+4
-4
No files found.
examples/README.md
View file @
86a0e65d
...
...
@@ -6,4 +6,17 @@ will be placed in the "bin" directory.
Then you can run executables like this:
../bin/simple_playback my_sound.wav
\ No newline at end of file
../bin/simple_playback my_sound.wav
Emscripten
----------
On Windows, you need to move into the build and run emsdk_env.bat from a command prompt using an absolute
path like "C:
\e
msdk
\e
msdk_env.bat". Note that PowerShell doesn't work for me for some reason. Then, run the
relevant batch file:
ma_build_examples_emscripten.bat
The output will be placed in the bin folder. If you have output WASM it may not work when running the web
page locally. To test you can run with something like this:
emrun ../bin/simple_playback_emscripten.html
\ No newline at end of file
examples/fixed_size_callback.c
View file @
86a0e65d
...
...
@@ -33,7 +33,7 @@ void data_callback_fixed(ma_device* pDevice, void* pOutput, const void* pInput,
*/
printf
(
"frameCount=%d
\n
"
,
frameCount
);
ma_sine_wave_read_
f32
(
&
g_sineWave
,
frameCount
,
(
float
*
)
pOutput
);
ma_sine_wave_read_
pcm_frames
(
&
g_sineWave
,
pOutput
,
frameCount
,
ma_format_f32
,
pDevice
->
playback
.
channels
);
/* Unused in this example. */
(
void
)
pDevice
;
...
...
@@ -48,9 +48,9 @@ void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uin
*/
ma_uint32
pcmFramesAvailableInRB
;
ma_uint32
pcmFramesProcessed
=
0
;
ma_uint8
*
pRunningOutput
=
pOutput
;
ma_uint8
*
pRunningOutput
=
(
ma_uint8
*
)
pOutput
;
ma_assert
(
pDevice
->
playback
.
channels
==
DEVICE_CHANNELS
);
MA_ASSERT
(
pDevice
->
playback
.
channels
==
DEVICE_CHANNELS
);
/*
The first thing to do is check if there's enough data available in the ring buffer. If so we can read from it. Otherwise we need to keep filling
...
...
@@ -85,7 +85,7 @@ void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uin
ma_pcm_rb_reset
(
&
g_rb
);
ma_pcm_rb_acquire_write
(
&
g_rb
,
&
framesToWrite
,
&
pWriteBuffer
);
{
ma_assert
(
framesToWrite
==
PCM_FRAME_CHUNK_SIZE
);
/* <-- This should always work in this example because we just reset the ring buffer. */
MA_ASSERT
(
framesToWrite
==
PCM_FRAME_CHUNK_SIZE
);
/* <-- This should always work in this example because we just reset the ring buffer. */
data_callback_fixed
(
pDevice
,
pWriteBuffer
,
NULL
,
framesToWrite
);
}
ma_pcm_rb_commit_write
(
&
g_rb
,
framesToWrite
,
pWriteBuffer
);
...
...
@@ -102,7 +102,7 @@ int main(int argc, char** argv)
ma_device
device
;
ma_sine_wave_init
(
0
.
2
,
400
,
DEVICE_SAMPLE_RATE
,
&
g_sineWave
);
ma_pcm_rb_init
(
DEVICE_FORMAT
,
DEVICE_CHANNELS
,
PCM_FRAME_CHUNK_SIZE
,
NULL
,
&
g_rb
);
ma_pcm_rb_init
(
DEVICE_FORMAT
,
DEVICE_CHANNELS
,
PCM_FRAME_CHUNK_SIZE
,
NULL
,
NULL
,
&
g_rb
);
deviceConfig
=
ma_device_config_init
(
ma_device_type_playback
);
deviceConfig
.
playback
.
format
=
DEVICE_FORMAT
;
...
...
examples/simple_loopback.c
View file @
86a0e65d
...
...
@@ -18,7 +18,7 @@ properties. The output buffer in the callback will be null whereas the input buf
void
data_callback
(
ma_device
*
pDevice
,
void
*
pOutput
,
const
void
*
pInput
,
ma_uint32
frameCount
)
{
drwav
*
pWav
=
(
drwav
*
)
pDevice
->
pUserData
;
ma_assert
(
pWav
!=
NULL
);
MA_ASSERT
(
pWav
!=
NULL
);
drwav_write_pcm_frames
(
pWav
,
frameCount
,
pInput
);
...
...
tests/ma_duplex.c
View file @
86a0e65d
...
...
@@ -112,8 +112,8 @@ int main(int argc, char** argv)
deviceConfig
.
playback
.
channels
=
2
;
deviceConfig
.
playback
.
shareMode
=
ma_share_mode_shared
;
deviceConfig
.
sampleRate
=
0
;
deviceConfig
.
buffer
SizeInFrames
=
0
;
deviceConfig
.
bufferSizeInMilliseconds
=
6
0
;
deviceConfig
.
period
SizeInFrames
=
0
;
deviceConfig
.
periodSizeInMilliseconds
=
1
0
;
deviceConfig
.
periods
=
3
;
deviceConfig
.
dataCallback
=
data_callback
;
deviceConfig
.
stopCallback
=
stop_callback
;
...
...
@@ -129,9 +129,9 @@ int main(int argc, char** argv)
}
/* For debugging. */
printf
(
"device.playback.internal
BufferSizeInFrames = %d
\n
"
,
device
.
playback
.
internalBuffer
SizeInFrames
);
printf
(
"device.playback.internal
PeriodSizeInFrames = %d
\n
"
,
device
.
playback
.
internalPeriod
SizeInFrames
);
printf
(
"device.playback.internalPeriods = %d
\n
"
,
device
.
playback
.
internalPeriods
);
printf
(
"device.capture.internal
BufferSizeInFrames = %d
\n
"
,
device
.
capture
.
internalBuffer
SizeInFrames
);
printf
(
"device.capture.internal
PeriodSizeInFrames = %d
\n
"
,
device
.
capture
.
internalPeriod
SizeInFrames
);
printf
(
"device.capture.internalPeriods = %d
\n
"
,
device
.
capture
.
internalPeriods
);
...
...
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