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
56a785e2
Commit
56a785e2
authored
May 21, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Decoding and add Documentation section to readme.
parent
169132de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
84 deletions
+11
-84
README.md
README.md
+11
-84
No files found.
README.md
View file @
56a785e2
...
@@ -14,13 +14,13 @@
...
@@ -14,13 +14,13 @@
<a
href=
"#supported-platforms"
>
Supported Platforms
</a>
-
<a
href=
"#supported-platforms"
>
Supported Platforms
</a>
-
<a
href=
"#backends"
>
Backends
</a>
-
<a
href=
"#backends"
>
Backends
</a>
-
<a
href=
"#building"
>
Building
</a>
-
<a
href=
"#building"
>
Building
</a>
-
<a
href=
"#example"
>
Example
</a>
-
<a
href=
"#example"
>
Example
s
</a>
-
<a
href=
"#d
ecoding"
>
Decoding
</a>
-
<a
href=
"#d
ocumentation"
>
Documentation
</a>
-
<a
href=
"#unofficial-bindings"
>
Unofficial Bindings
</a>
<a
href=
"#unofficial-bindings"
>
Unofficial Bindings
</a>
</p>
</p>
#
Features
Features
========
-
Liberally licensed, with your choice of either public domain or MIT No Attribution for those regions who don't
-
Liberally licensed, with your choice of either public domain or MIT No Attribution for those regions who don't
recognize public domain.
recognize public domain.
-
Everything is implemented in a single file for easy integration into your source tree.
-
Everything is implemented in a single file for easy integration into your source tree.
...
@@ -108,8 +108,8 @@ to anything. On Linux just link to -lpthread, -lm and -ldl. On BSD just link to
...
@@ -108,8 +108,8 @@ to anything. On Linux just link to -lpthread, -lm and -ldl. On BSD just link to
need to compile as Objective-C.
need to compile as Objective-C.
Example
Example
s
=======
=======
=
This example shows how to decode and play a sound.
This example shows how to decode and play a sound.
```
c
```
c
...
@@ -184,87 +184,14 @@ int main(int argc, char** argv)
...
@@ -184,87 +184,14 @@ int main(int argc, char** argv)
}
}
```
```
More examples can be found in the
[
examples
](
examples
)
folder.
Decoding
========
miniaudio includes a decoding API which supports the following backends:
-
FLAC via
[
dr_flac
](
https://github.com/mackron/dr_libs/blob/master/dr_flac.h
)
-
MP3 via
[
dr_mp3
](
https://github.com/mackron/dr_libs/blob/master/dr_mp3.h
)
-
WAV via
[
dr_wav
](
https://github.com/mackron/dr_libs/blob/master/dr_wav.h
)
-
Vorbis via
[
stb_vorbis
](
https://github.com/nothings/stb/blob/master/stb_vorbis.c
)
Copies of these libraries can be found in the "extras" folder.
To enable support for a decoding backend, all you need to do is #include the header section of the
relevant backend library before the implementation of miniaudio, like so:
```
c
#include "dr_flac.h" // Enables FLAC decoding.
#include "dr_mp3.h" // Enables MP3 decoding.
#include "dr_wav.h" // Enables WAV decoding.
#define MINIAUDIO_IMPLEMENTATION
#include "miniaudio.h"
```
A decoder can be initialized from a file with
`ma_decoder_init_file()`
, a block of memory with
`ma_decoder_init_memory()`
, or from data delivered via callbacks with
`ma_decoder_init()`
. Here
is an example for loading a decoder from a file:
```
c
ma_decoder
decoder
;
ma_result
result
=
ma_decoder_init_file
(
"MySong.mp3"
,
NULL
,
&
decoder
);
if
(
result
!=
MA_SUCCESS
)
{
return
false
;
// An error occurred.
}
...
ma_decoder_uninit
(
&
decoder
);
```
When initializing a decoder, you can optionally pass in a pointer to a
`ma_decoder_config`
object
(the
`NULL`
argument in the example above) which allows you to configure the output format, channel
count, sample rate and channel map:
```
c
ma_decoder_config
config
=
ma_decoder_config_init
(
ma_format_f32
,
2
,
48000
);
```
When passing in NULL for this parameter, the output format will be the same as that defined by the
decoding backend.
Data is read from the decoder as PCM frames:
```
c
ma_uint64
framesRead
=
ma_decoder_read_pcm_frames
(
pDecoder
,
pFrames
,
framesToRead
);
```
You can also seek to a specific frame like so:
```
c
ma_result
result
=
ma_decoder_seek_to_pcm_frame
(
pDecoder
,
targetFrame
);
if
(
result
!=
MA_SUCCESS
)
{
return
false
;
// An error occurred.
}
```
When loading a decoder, miniaudio uses a trial and error technique to find the appropriate decoding
backend. This can be unnecessarily inefficient if the type is already known. In this case you can
use the
`_wav`
,
`_mp3`
, etc. varients of the aforementioned initialization APIs:
```
Documentation
ma_decoder_init_wav()
=============
ma_decoder_init_mp3()
Documentation can be found at the top of
[
miniaudio.h
](
https://raw.githubusercontent.com/dr-soft/miniaudio/master/miniaudio.h
)
ma_decoder_init_memory_wav()
which is always the most up-to-date and authoritive source of information on how to use miniaudio.
ma_decoder_init_memory_mp3()
ma_decoder_init_file_wav()
ma_decoder_init_file_mp3()
etc.
```
The
`ma_decoder_init_file()`
API will try using the file extension to determine which decoding
backend to prefer.
Unofficial Bindings
Unofficial Bindings
...
...
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