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
d72e7b1f
Commit
d72e7b1f
authored
Mar 06, 2019
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"mini_al" to "miniaudio".
parent
af1c305d
Changes
23
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
151 additions
and
151 deletions
+151
-151
README.md
README.md
+10
-10
examples/advanced_config.c
examples/advanced_config.c
+9
-9
examples/simple_capture.c
examples/simple_capture.c
+1
-1
examples/simple_enumeration.c
examples/simple_enumeration.c
+1
-1
examples/simple_playback.c
examples/simple_playback.c
+1
-1
examples/simple_playback_emscripten.c
examples/simple_playback_emscripten.c
+1
-1
mini_al.h
mini_al.h
+107
-107
research/README.txt
research/README.txt
+1
-1
research/mal_resampler.h
research/mal_resampler.h
+2
-2
research/mal_ring_buffer.h
research/mal_ring_buffer.h
+1
-1
research/tests/mal_resampler_test_0.c
research/tests/mal_resampler_test_0.c
+1
-1
tests/mal_debug_playback.c
tests/mal_debug_playback.c
+1
-1
tests/mal_dithering.c
tests/mal_dithering.c
+1
-1
tests/mal_duplex.c
tests/mal_duplex.c
+1
-1
tests/mal_no_device_io.c
tests/mal_no_device_io.c
+1
-1
tests/mal_profiling.c
tests/mal_profiling.c
+1
-1
tests/mal_resampling.c
tests/mal_resampling.c
+4
-4
tests/mal_stop.c
tests/mal_stop.c
+1
-1
tests/mal_test_0.c
tests/mal_test_0.c
+1
-1
tests/mal_test_0.vcxproj
tests/mal_test_0.vcxproj
+1
-1
tests/mal_test_0.vcxproj.filters
tests/mal_test_0.vcxproj.filters
+1
-1
tests/mal_webaudio_test_0.html
tests/mal_webaudio_test_0.html
+1
-1
tools/mini_sigvis/mini_sigvis.h
tools/mini_sigvis/mini_sigvis.h
+2
-2
No files found.
README.md
View file @
d72e7b1f


mini
_al is a single file library for audio playback and capture. It's written in C (compilable as C++)
and released into the public domain.
mini
audio (formally mini_al) is a single file library for audio playback and capture. It's written
in C (compilable as C++)
and released into the public domain.
Features
...
...
@@ -52,7 +52,7 @@ Building
Do the following in one source file:
```
#define MINI_AL_IMPLEMENTATION
#include "mini
_al
.h"
#include "mini
audio
.h"
```
Then just compile. There's no need to install any dependencies. On Windows and macOS there's no need to link
to anything. On Linux and BSD, just link to -lpthread, -lm and -ldl.
...
...
@@ -70,7 +70,7 @@ Simple Playback Example
#include "../extras/dr_wav.h" // Enables WAV decoding.
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
#include <stdio.h>
...
...
@@ -133,21 +133,21 @@ int main(int argc, char** argv)
MP3/Vorbis/FLAC/WAV Decoding
============================
mini
_al
includes a decoding API which supports the following backends:
mini
audio
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. You may also want to look at the
libraries below, but they are not supported by the mini
_al
decoder API. If you know of any other
libraries below, but they are not supported by the mini
audio
decoder API. If you know of any other
single file libraries I can add to this list, let me know. Preferably public domain or MIT.
-
[
minimp3
](
https://github.com/lieff/minimp3
)
-
[
jar_mod
](
https://github.com/kd7tck/jar/blob/master/jar_mod.h
)
-
[
jar_xm
](
https://github.com/kd7tck/jar/blob/master/jar_xm.h
)
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 mini
_al
, like so:
relevant backend library before the implementation of mini
audio
, like so:
```
#include "dr_flac.h" // Enables FLAC decoding.
...
...
@@ -155,7 +155,7 @@ relevant backend library before the implementation of mini_al, like so:
#include "dr_wav.h" // Enables WAV decoding.
#define MINI_AL_IMPLEMENTATION
#include "mini
_al
.h"
#include "mini
audio
.h"
```
A decoder can be initialized from a file with
`mal_decoder_init_file()`
, a block of memory with
...
...
@@ -200,7 +200,7 @@ if (result != MAL_SUCCESS) {
}
```
When loading a decoder, mini
_al
uses a trial and error technique to find the appropriate decoding
When loading a decoder, mini
audio
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:
...
...
examples/advanced_config.c
View file @
d72e7b1f
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
#include <stdio.h>
...
...
@@ -7,7 +7,7 @@ void log_callback(mal_context* pContext, mal_device* pDevice, mal_uint32 logLeve
{
(
void
)
pContext
;
(
void
)
pDevice
;
printf
(
"mini
_al
: [%s] %s
\n
"
,
mal_log_level_to_string
(
logLevel
),
message
);
printf
(
"mini
audio
: [%s] %s
\n
"
,
mal_log_level_to_string
(
logLevel
),
message
);
}
void
data_callback
(
mal_device
*
pDevice
,
void
*
pOutput
,
const
void
*
pInput
,
mal_uint32
frameCount
)
...
...
@@ -44,7 +44,7 @@ int main(int argc, char** argv)
// PulseAudio
// ----------
// PulseAudio allows you to set the name of the application. mini
_al
exposes this through the following
// PulseAudio allows you to set the name of the application. mini
audio
exposes this through the following
// config.
contextConfig
.
pulse
.
pApplicationName
=
"My Application"
;
...
...
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
contextConfig
.
pulse
.
pServerName
=
"my_server"
;
// During initialization, PulseAudio can try to automatically start the PulseAudio daemon. This does not
// suit mini
_al
's trial and error backend initialization architecture so it's disabled by default, but you
// suit mini
audio
's trial and error backend initialization architecture so it's disabled by default, but you
// can enable it like so:
contextConfig
.
pulse
.
tryAutoSpawn
=
MAL_TRUE
;
...
...
@@ -62,7 +62,7 @@ int main(int argc, char** argv)
// ----
// Typically, ALSA enumerates many devices, which unfortunately is not very friendly for the end user. To
// combat this, mini
_al
will include only unique card/device pairs by default. The problem with this is that
// combat this, mini
audio
will include only unique card/device pairs by default. The problem with this is that
// you lose a bit of flexibility and control. Setting alsa.useVerboseDeviceEnumeration makes it so the ALSA
// backend includes all devices (and there's a lot of them!).
contextConfig
.
alsa
.
useVerboseDeviceEnumeration
=
MAL_TRUE
;
...
...
@@ -151,7 +151,7 @@ int main(int argc, char** argv)
// backends support this feature, so this is actually just a hint.
deviceConfig
.
playback
.
shareMode
=
mal_share_mode_exclusive
;
// mini
_al
allows applications to control the mapping of channels. The config below swaps the left and right
// mini
audio
allows applications to control the mapping of channels. The config below swaps the left and right
// channels. Normally in an interleaved audio stream, the left channel comes first, but we can change that
// like the following:
deviceConfig
.
playback
.
channelMap
[
0
]
=
MAL_CHANNEL_FRONT_RIGHT
;
...
...
@@ -164,7 +164,7 @@ int main(int argc, char** argv)
// here in case it might be useful for others. If you find a bug specific to mmap mode, please report it!
deviceConfig
.
alsa
.
noMMap
=
MAL_TRUE
;
// This is not used in this example, but mini
_al
allows you to directly control the device ID that's used
// This is not used in this example, but mini
audio
allows you to directly control the device ID that's used
// for device selection by mal_device_init(). Below is an example for ALSA. In this example it forces
// mal_device_init() to try opening the "hw:0,0" device. This is useful for debugging in case you have
// audio glitches or whatnot with specific devices.
...
...
@@ -173,8 +173,8 @@ int main(int argc, char** argv)
if
(
context
.
backend
==
mal_backend_alsa
)
{
strcpy
(
customDeviceID
.
alsa
,
"hw:0,0"
);
// The ALSA backend also supports a mini
_al
-specific format which looks like this: ":0,0". In this case,
// mini
_al
will try different plugins depending on the shareMode setting. When using shared mode it will
// The ALSA backend also supports a mini
audio
-specific format which looks like this: ":0,0". In this case,
// mini
audio
will try different plugins depending on the shareMode setting. When using shared mode it will
// convert ":0,0" to "dmix:0,0"/"dsnoop:0,0". For exclusive mode (or if dmix/dsnoop fails) it will convert
// it to "hw:0,0". This is how the ALSA backend honors the shareMode hint.
strcpy
(
customDeviceID
.
alsa
,
":0,0"
);
...
...
examples/simple_capture.c
View file @
d72e7b1f
// This example simply captures data from your default microphone until you press Enter. The output is saved to the file specified on the command line.
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
#define DR_WAV_IMPLEMENTATION
#include "../extras/dr_wav.h"
...
...
examples/simple_enumeration.c
View file @
d72e7b1f
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
#include <stdio.h>
...
...
examples/simple_playback.c
View file @
d72e7b1f
...
...
@@ -6,7 +6,7 @@
#include "../extras/dr_wav.h" // Enables WAV decoding.
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
#include <stdio.h>
...
...
examples/simple_playback_emscripten.c
View file @
d72e7b1f
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
#include <stdio.h>
...
...
mini_al.h
View file @
d72e7b1f
This diff is collapsed.
Click to expand it.
research/README.txt
View file @
d72e7b1f
This folder contains code that I'm experimenting with outside of the main mini
_al
library. It's just for
This folder contains code that I'm experimenting with outside of the main mini
audio
library. It's just for
my own research and experimenting which I'm putting into the repository for version control purposes and
to get feedback from the community. You should not consider any of this code to be production quality.
\ No newline at end of file
research/mal_resampler.h
View file @
d72e7b1f
/*
Consider this code public domain.
This is research into a new resampler for mini
_al
. Not yet complete.
This is research into a new resampler for mini
audio
. Not yet complete.
Requirements:
- Selection of different algorithms. The following at a minimum:
...
...
@@ -46,7 +46,7 @@ Random Notes:
- You cannot change the algorithm after initialization.
- It is recommended to keep the mal_resampler object aligned to MAL_SIMD_ALIGNMENT, though it is not necessary.
- Ratios need to be in the range of MAL_RESAMPLER_MIN_RATIO and MAL_RESAMPLER_MAX_RATIO. This is enough to convert
to and from 8000 and 384000, which is the smallest and largest standard rates supported by mini
_al
. If you need
to and from 8000 and 384000, which is the smallest and largest standard rates supported by mini
audio
. If you need
extreme ratios then you will need to chain resamplers together.
*/
#ifndef mal_resampler_h
...
...
research/mal_ring_buffer.h
View file @
d72e7b1f
...
...
@@ -56,7 +56,7 @@ typedef struct
mal_uint32
subbufferStrideInBytes
;
volatile
mal_uint32
encodedReadOffset
;
/* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. */
volatile
mal_uint32
encodedWriteOffset
;
/* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. */
mal_bool32
ownsBuffer
:
1
;
/* Used to know whether or not mini
_al
is responsible for free()-ing the buffer. */
mal_bool32
ownsBuffer
:
1
;
/* Used to know whether or not mini
audio
is responsible for free()-ing the buffer. */
mal_bool32
clearOnWriteAcquire
:
1
;
/* When set, clears the acquired write buffer before returning from mal_rb_acquire_write(). */
}
mal_rb
;
...
...
research/tests/mal_resampler_test_0.c
View file @
d72e7b1f
...
...
@@ -3,7 +3,7 @@
#define MAL_DEBUG_OUTPUT
#define MINI_AL_IMPLEMENTATION
#include "../../mini
_al
.h"
#include "../../mini
audio
.h"
#include "../mal_resampler.h"
#define SAMPLE_RATE_IN 44100
...
...
tests/mal_debug_playback.c
View file @
d72e7b1f
...
...
@@ -2,7 +2,7 @@
#define MAL_LOG_LEVEL MAL_LOG_LEVEL_VERBOSE
#define MAL_DEBUG_OUTPUT
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
int
print_context_info
(
mal_context
*
pContext
)
{
...
...
tests/mal_dithering.c
View file @
d72e7b1f
#define MAL_DEBUG_OUTPUT
#define MAL_USE_REFERENCE_CONVERSION_APIS
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
// Two converters are needed here. One for converting f32 samples from the sine wave generator to the input format,
// and another for converting the input format to the output format for device output.
...
...
tests/mal_duplex.c
View file @
d72e7b1f
...
...
@@ -2,7 +2,7 @@
#define MAL_DEBUG_OUTPUT
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
#define DR_WAV_IMPLEMENTATION
#include "../extras/dr_wav.h"
...
...
tests/mal_no_device_io.c
View file @
d72e7b1f
...
...
@@ -6,7 +6,7 @@
#define MAL_NO_DEVICE_IO
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
int
main
(
int
argc
,
char
**
argv
)
{
...
...
tests/mal_profiling.c
View file @
d72e7b1f
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
typedef
enum
{
...
...
tests/mal_resampling.c
View file @
d72e7b1f
// We're using sigvis for visualizations. This will include mini
_al for us, so no need to include mini_al
in this file.
// We're using sigvis for visualizations. This will include mini
audio for us, so no need to include miniaudio
in this file.
#define NO_SIGVIS
#define MAL_NO_SSE2
...
...
@@ -6,13 +6,13 @@
#ifdef NO_SIGVIS
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
#else
#define MINI_SIGVIS_IMPLEMENTATION
#include "../tools/mini_sigvis/mini_sigvis.h" // <-- Includes mini
_al
.
#include "../tools/mini_sigvis/mini_sigvis.h" // <-- Includes mini
audio
.
#endif
// There is a usage pattern for resampling that mini
_al
does not properly support which is where the client continuously
// There is a usage pattern for resampling that mini
audio
does not properly support which is where the client continuously
// reads samples until mal_src_read() returns 0. The problem with this pattern is that is consumes the samples sitting
// in the window which are needed to compute the next samples in future calls to mal_src_read() (assuming the client
// has re-filled the resampler's input data).
...
...
tests/mal_stop.c
View file @
d72e7b1f
#include <stdio.h>
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
mal_sine_wave
sineWave
;
mal_uint32
framesWritten
;
...
...
tests/mal_test_0.c
View file @
d72e7b1f
...
...
@@ -12,7 +12,7 @@
//#define MAL_DEBUG_OUTPUT
#define MINI_AL_IMPLEMENTATION
#include "../mini
_al
.h"
#include "../mini
audio
.h"
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
...
...
tests/mal_test_0.vcxproj
View file @
d72e7b1f
...
...
@@ -376,7 +376,7 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\mini
_al
.h"
/>
<ClInclude
Include=
"..\mini
audio
.h"
/>
<ClInclude
Include=
"..\research\mal_resampler.h"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
...
...
tests/mal_test_0.vcxproj.filters
View file @
d72e7b1f
...
...
@@ -59,7 +59,7 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\mini
_al
.h"
>
<ClInclude
Include=
"..\mini
audio
.h"
>
<Filter>
Source Files
</Filter>
</ClInclude>
<ClInclude
Include=
"..\research\mal_resampler.h"
>
...
...
tests/mal_webaudio_test_0.html
View file @
d72e7b1f
...
...
@@ -95,7 +95,7 @@
latencyHint
:
'
interactive
'
,
sampleRate
:
sampleRate
,
});
device
.
webaudioContext
.
suspend
();
// mini
_al
always starts it's devices in a stopped state.
device
.
webaudioContext
.
suspend
();
// mini
audio
always starts it's devices in a stopped state.
console
.
log
(
"
Sample Rate:
"
+
device
.
webaudioContext
.
sampleRate
);
device
.
intermediaryBufferSizeInBytes
=
channelCount
*
bufferSizeInFrames
*
4
;
...
...
tools/mini_sigvis/mini_sigvis.h
View file @
d72e7b1f
...
...
@@ -6,7 +6,7 @@
#ifndef mini_sigvis_h
#define mini_sigvis_h
#include "../../mini
_al
.h"
#include "../../mini
audio
.h"
#include "../external/dred/source/dred/dtk/dtk.h"
#ifdef __cplusplus
...
...
@@ -83,7 +83,7 @@ float msigvis_channel_get_sample_f32(msigvis_channel* pChannel, mal_uint32 iSamp
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef MINI_SIGVIS_IMPLEMENTATION
#define MINI_AL_IMPLEMENTATION
#include "../../mini
_al
.h"
#include "../../mini
audio
.h"
#include "../external/dred/source/dred/dtk/dtk.c"
mal_result
msigvis_result_from_dtk
(
dtk_result
resultDTK
)
...
...
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