mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Update website.
This commit is contained in:
@@ -255,7 +255,7 @@ This example show how a custom backend can be implemented.
|
||||
<p>
|
||||
|
||||
This implements a full-featured SDL2 backend. It's intentionally built using the same paradigms as the built-in backends in order to make
|
||||
it suitable as a solid basis for a custom implementation. The SDL2 backend can be disabled with MA_NO_SDL, exactly like the build-in
|
||||
it suitable as a solid basis for a custom implementation. The SDL2 backend can be disabled with MA_NO_SDL, exactly like the built-in
|
||||
backends. It supports both runtime and compile-time linking and respects the MA_NO_RUNTIME_LINKING option. It also works on Emscripten
|
||||
which requires the <span style="font-family:monospace;">-s USE_SDL=2</span> option.
|
||||
</p>
|
||||
@@ -282,8 +282,7 @@ Custom backends are identified with the <span style="font-family:monospace;">ma_
|
||||
<span style="font-family:monospace;">ma_backend_custom</span> backend type because otherwise the built-in backends would always get chosen first and none of the code for the custom
|
||||
backends would actually get hit. By default, the <span style="font-family:monospace;">ma_backend_custom</span> backend is the lowest priority backend, except for <span style="font-family:monospace;">ma_backend_null</span>.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#ifdef</span> __EMSCRIPTEN__
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><emscripten.h></span>
|
||||
|
||||
@@ -313,7 +313,7 @@ MINIAUDIO_IMPLEMENTATION system. This will change from version 0.12.
|
||||
Add your custom backend vtables here. The order in the array defines the order of priority. The
|
||||
vtables will be passed in via the decoder config.
|
||||
*/</span>
|
||||
<span style="color:#0033ff">const</span> ma_decoding_backend_vtable* pCustomBackendVTables[] =
|
||||
ma_decoding_backend_vtable* pCustomBackendVTables[] =
|
||||
{
|
||||
ma_decoding_backend_libvorbis,
|
||||
ma_decoding_backend_libopus
|
||||
|
||||
@@ -281,7 +281,7 @@ MINIAUDIO_IMPLEMENTATION system. This will change from version 0.12.
|
||||
Add your custom backend vtables here. The order in the array defines the order of priority. The
|
||||
vtables will be passed in to the resource manager config.
|
||||
*/</span>
|
||||
<span style="color:#0033ff">const</span> ma_decoding_backend_vtable* pCustomBackendVTables[] =
|
||||
ma_decoding_backend_vtable* pCustomBackendVTables[] =
|
||||
{
|
||||
ma_decoding_backend_libvorbis,
|
||||
ma_decoding_backend_libopus
|
||||
|
||||
@@ -296,9 +296,7 @@ starting the chain from the start again. It is also seeking the head data source
|
||||
so that playback starts from the start as expected. You do not need to seek non-head items back to
|
||||
the start as miniaudio will do that for you internally.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MA_EXPERIMENTAL__DATA_LOOPING_AND_CHAINING
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
|
||||
@@ -259,8 +259,7 @@ called <span style="font-family:monospace;">ma_vocoder_node</span> is used to ac
|
||||
the miniaudio repository. The vocoder node uses <a href="https://github.com/blastbay/voclib">https://github.com/blastbay/voclib</a> to achieve the
|
||||
effect.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../extras/nodes/ma_vocoder_node/ma_vocoder_node.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
@@ -276,8 +276,7 @@ Using a shared resource manager, as we do in this example, is useful for when yo
|
||||
multiple engines so that you can output to multiple playback devices simultaneoulys. An example
|
||||
might be a local co-op multiplayer game where each player has their own headphones.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#define</span> MAX_DEVICES 2
|
||||
<span style="color:#666666">#define</span> MAX_SOUNDS 32
|
||||
|
||||
@@ -270,8 +270,7 @@ This example is playing only a single sound at a time which means only a single
|
||||
it being used. If you want to play multiple sounds at the same time, even if they're for the same
|
||||
sound file, you need multiple <span style="font-family:monospace;">ma_sound</span> objects.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#define</span> DELAY_IN_SECONDS 0.2f
|
||||
<span style="color:#666666">#define</span> DECAY 0.25f <span style="color:#009900">/* Volume falloff for each echo. */</span>
|
||||
|
||||
@@ -256,8 +256,7 @@ This example demonstrates how to initialize an audio engine and play a sound.
|
||||
|
||||
This will play the sound specified on the command line.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
|
||||
@@ -264,8 +264,7 @@ This example will load the sound specified on the command line and rotate it aro
|
||||
head.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MA_NO_DEVICE_IO <span style="color:#009900">/* <-- Disables the <span style="font-family:monospace;">ma_device</span> API. We don't need that in this example since SDL will be doing that part for us. */</span>
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#define</span> SDL_MAIN_HANDLED
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><SDL2/SDL.h></span> <span style="color:#009900">/* Change this to your include location. Might be <SDL.h>. */</span>
|
||||
|
||||
@@ -271,8 +271,7 @@ you specify in your IPLAudioSettings object. If for some reason you want the per
|
||||
engine to be different to that of your Steam Audio configuration, you'll need to implement a sort
|
||||
of buffering solution to your node.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdint.h></span> <span style="color:#009900">/* Required for uint32_t which is used by STEAMAUDIO_VERSION, and a random use of uint8_t. If there's a Steam Audio maintainer reading this, that needs to be fixed to use IPLuint32 and IPLuint8. */</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><phonon.h></span> <span style="color:#009900">/* Steam Audio */</span>
|
||||
|
||||
@@ -272,8 +272,7 @@ Instead you would probably want to do a custom data source that handles underrun
|
||||
the ring buffer and deals with desyncs between capture and playback. In the future this example
|
||||
may be updated to make use of a more advanced data source that handles all of this.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0099cc">ma_pcm_rb</span> rb;
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0099cc">ma_device</span> device;
|
||||
|
||||
@@ -321,8 +321,7 @@ pass and echo effects so that one of them becomes more obvious than the other.
|
||||
|
||||
When you want to read from the graph, you simply call <span style="font-family:monospace;">ma_node_graph_read_pcm_frames()</span>.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#009900">/* Data Format */</span>
|
||||
<span style="color:#666666">#define</span> FORMAT ma_format_f32 <span style="color:#009900">/* Must always be f32. */</span>
|
||||
|
||||
@@ -289,8 +289,7 @@ data from the data source. This means the resource manager will ensure all sound
|
||||
set, each sound will have their own formats and you'll need to do the necessary data conversion yourself.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MA_NO_ENGINE <span style="color:#009900">/* We're intentionally not using the ma_engine API here. */</span>
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#ifdef</span> __EMSCRIPTEN__
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><emscripten.h></span>
|
||||
|
||||
@@ -274,8 +274,7 @@ In this example we show how you can create a data source, mix them with other da
|
||||
threads to manage internally and how to implement your own custom job thread.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MA_NO_ENGINE <span style="color:#009900">/* We're intentionally not using the ma_engine API here. */</span>
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#0033ff">static</span> ma_resource_manager_data_source g_dataSources[16];
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0099cc">ma_uint32</span> g_dataSourceCount;
|
||||
|
||||
@@ -263,8 +263,7 @@ Capturing works in a very similar way to playback. The only difference is the di
|
||||
the application sending data to the device, the device will send data to the application. This example just writes the
|
||||
data received by the microphone straight to a WAV file.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdlib.h></span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
@@ -265,8 +265,7 @@ glitching which the backend may not be able to recover from. For this reason, mi
|
||||
sample rate for both capture and playback. If internally the native sample rates differ, miniaudio will perform the
|
||||
sample rate conversion for you automatically.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
|
||||
@@ -262,8 +262,7 @@ context sits above a device. You can have many devices to one context.
|
||||
If you use device enumeration, you should explicitly specify the same context you used for enumeration in the call to
|
||||
<span style="font-family:monospace;">ma_device_init()</span> when you initialize your devices.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
|
||||
@@ -267,8 +267,7 @@ used indirectly with PulseAudio by choosing the appropriate loopback device afte
|
||||
To use loopback mode you just need to set the device type to ma_device_type_loopback and set the capture device config
|
||||
properties. The output buffer in the callback will be null whereas the input buffer will be valid.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdlib.h></span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
@@ -258,8 +258,7 @@ This example uses a decoder as the data source. Decoders can be used with the <s
|
||||
supports looping via the <span style="font-family:monospace;">ma_data_source_read_pcm_frames()</span> API. To use it, all you need to do is pass a pointer to the
|
||||
decoder straight into <span style="font-family:monospace;">ma_data_source_read_pcm_frames()</span> and it will just work.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
|
||||
@@ -266,8 +266,7 @@ is when sample are clamped to their minimum and maximum range, which for floatin
|
||||
Usage: simple_mixing [input file 0] [input file 1] ... [input file n]
|
||||
Example: simple_mixing file1.wav file2.flac
|
||||
</pre></div><div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
|
||||
@@ -265,8 +265,7 @@ device and can be used independently of it. This example only plays back a singl
|
||||
back multiple files by simple loading multiple decoders and mixing them (do not create multiple devices to do this). See
|
||||
the simple_mixing example for how best to do this.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
|
||||
@@ -273,8 +273,7 @@ This example works with Emscripten.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MA_NO_DECODING
|
||||
<span style="color:#666666">#define</span> MA_NO_ENCODING
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
|
||||
@@ -273,8 +273,7 @@ To use this example, pass in the path of a sound as the first argument. The soun
|
||||
positioned in front of the listener, while the listener rotates on the the spot to create an
|
||||
orbiting effect. Terminate the program with Ctrl+C.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em; width:100%;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.c"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><math.h></span> <span style="color:#009900">/* For sinf() and cosf() */</span>
|
||||
|
||||
Reference in New Issue
Block a user