mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-21 15:56:58 +02:00
Update website.
This commit is contained in:
@@ -245,7 +245,7 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Custom Backend</h1><p>
|
||||
This example show how a custom backend can be implemented.
|
||||
</p>
|
||||
@@ -293,9 +293,12 @@ backends would actually get hit. By default, the <span style="font-family:monosp
|
||||
<span style="color:#009900">/* Support SDL on everything. */</span>
|
||||
<span style="color:#666666">#define</span> MA_SUPPORT_SDL
|
||||
|
||||
<span style="color:#009900">/* Only enable SDL if it's hasn't been explicitly disabled (MA_NO_SDL) and it's supported at compile time (MA_SUPPORT_SDL). */</span>
|
||||
<span style="color:#666666">#if</span> !defined(MA_NO_SDL) && defined(MA_SUPPORT_SDL)
|
||||
<span style="color:#666666">#define</span> MA_ENABLE_SDL
|
||||
<span style="color:#009900">/*
|
||||
Only enable SDL if it's hasn't been explicitly disabled (MA_NO_SDL) or enabled (MA_ENABLE_SDL with
|
||||
MA_ENABLE_ONLY_SPECIFIC_BACKENDS) and it's supported at compile time (MA_SUPPORT_SDL).
|
||||
*/</span>
|
||||
<span style="color:#666666">#if</span> defined(MA_SUPPORT_SDL) && !defined(MA_NO_SDL) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_SDL))
|
||||
<span style="color:#666666">#define</span> MA_HAS_SDL
|
||||
<span style="color:#666666">#endif</span>
|
||||
|
||||
|
||||
@@ -331,9 +334,7 @@ backends would actually get hit. By default, the <span style="font-family:monosp
|
||||
|
||||
|
||||
|
||||
<span style="color:#666666">#if</span> defined(MA_ENABLE_SDL)
|
||||
<span style="color:#666666">#define</span> MA_HAS_SDL
|
||||
|
||||
<span style="color:#666666">#if</span> defined(MA_HAS_SDL)
|
||||
<span style="color:#009900">/* SDL headers are necessary if using compile-time linking. */</span>
|
||||
<span style="color:#666666">#ifdef</span> MA_NO_RUNTIME_LINKING
|
||||
<span style="color:#666666">#ifdef</span> __has_include
|
||||
@@ -587,7 +588,7 @@ ma_format ma_format_from_sdl(MA_SDL_AudioFormat format)
|
||||
|
||||
MA_ASSERT(pDeviceEx != NULL);
|
||||
|
||||
ma_device_handle_backend_data_callback((<span style="color:#0099cc">ma_device</span>*)pDeviceEx, pBuffer, NULL, (<span style="color:#0099cc">ma_uint32</span>)bufferSizeInBytes / ma_get_bytes_per_frame(pDeviceEx->device.capture.internalFormat, pDeviceEx->device.capture.internalChannels));
|
||||
ma_device_handle_backend_data_callback((<span style="color:#0099cc">ma_device</span>*)pDeviceEx, pBuffer, NULL, (<span style="color:#0099cc">ma_uint32</span>)bufferSizeInBytes / ma_get_bytes_per_frame(pDeviceEx->device.playback.internalFormat, pDeviceEx->device.playback.internalChannels));
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0099cc">ma_result</span> ma_device_init_internal__sdl(ma_device_ex* pDeviceEx, <span style="color:#0033ff">const</span> <span style="color:#0099cc">ma_device_config</span>* pConfig, ma_device_descriptor* pDescriptor)
|
||||
@@ -622,22 +623,11 @@ ma_format ma_format_from_sdl(MA_SDL_AudioFormat format)
|
||||
|
||||
Note that options 2 and 3 require knowledge of the sample rate in order to convert it to a frame count. You should try to keep the
|
||||
calculation of the period size as accurate as possible, but sometimes it's just not practical so just use whatever you can.
|
||||
|
||||
A helper function called ma_calculate_buffer_size_in_frames_from_descriptor() is available to do all of this for you which is what
|
||||
we'll be using here.
|
||||
*/</span>
|
||||
<span style="color:#0033ff">if</span> (pDescriptor->periodSizeInFrames == 0) {
|
||||
<span style="color:#0033ff">if</span> (pDescriptor->periodSizeInMilliseconds == 0) {
|
||||
<span style="color:#009900">/* The default period size has been requested. I don't think SDL has an API to retrieve this, so just using defaults defined by miniaudio. */</span>
|
||||
<span style="color:#0033ff">if</span> (pConfig->performanceProfile == ma_performance_profile_low_latency) {
|
||||
pDescriptor->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, pDescriptor->sampleRate);
|
||||
} <span style="color:#0033ff">else</span> {
|
||||
pDescriptor->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, pDescriptor->sampleRate);
|
||||
}
|
||||
} <span style="color:#0033ff">else</span> {
|
||||
<span style="color:#009900">/* An explicit period size in milliseconds was specified. */</span>
|
||||
pDescriptor->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptor->periodSizeInMilliseconds, pDescriptor->sampleRate);
|
||||
}
|
||||
} <span style="color:#0033ff">else</span> {
|
||||
<span style="color:#009900">/* Nothing to do here. An explicit period size in frames was specified. */</span>
|
||||
}
|
||||
pDescriptor->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, pDescriptor->sampleRate, pConfig->performanceProfile);
|
||||
|
||||
<span style="color:#009900">/* SDL wants the buffer size to be a power of 2 for some reason. */</span>
|
||||
<span style="color:#0033ff">if</span> (pDescriptor->periodSizeInFrames > 32768) {
|
||||
|
||||
@@ -0,0 +1,549 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>miniaudio - A single file audio playback and capture library.</title>
|
||||
<meta name="description" content="miniaudio is a single file audio playback and capture library written in C.">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="icon" href="../../img/favicon.png">
|
||||
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-81135233-2"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-81135233-2');
|
||||
</script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family:sans-serif;
|
||||
font-size:11pt;
|
||||
line-height:18pt;
|
||||
background-color:#003800;
|
||||
}
|
||||
|
||||
h1,h2 {
|
||||
color:#333;
|
||||
line-height:0.2em;
|
||||
margin-bottom:0;
|
||||
padding:0;
|
||||
}
|
||||
h1.man {
|
||||
margin-top:2em;
|
||||
}
|
||||
h2.man {
|
||||
margin-top:1.5em;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration:none;
|
||||
color:#28f;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration:underline;
|
||||
color:#26d;
|
||||
}
|
||||
|
||||
.a-download {
|
||||
text-decoration:none;
|
||||
color:#ddd;
|
||||
border:solid 1px #000;
|
||||
border-radius:4px;
|
||||
padding:16px 32px;
|
||||
background-color:#003800;
|
||||
}
|
||||
.a-download:hover {
|
||||
background-color:#003000;
|
||||
text-decoration:none;
|
||||
color:#ddd;
|
||||
}
|
||||
|
||||
.a-sublink {
|
||||
font-size:11pt;
|
||||
}
|
||||
|
||||
#preview {
|
||||
font-family:monospace;
|
||||
font-size:10pt;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
.footer-links {
|
||||
margin: 0px;
|
||||
margin-bottom: 10px;
|
||||
padding: 0px;
|
||||
}
|
||||
.footer-links li {
|
||||
display: inline;
|
||||
padding: 0 2px;
|
||||
}
|
||||
.footer-links li:first-child {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.feature-header {
|
||||
color:#666;
|
||||
font-size: 24pt;
|
||||
font-weight:bold;
|
||||
}
|
||||
.feature-header2 {
|
||||
color:#444;
|
||||
font-size: 1.5em;
|
||||
font-weight:bold;
|
||||
/*margin-bottom:1em;*/
|
||||
line-height: 1em;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
.header-link-table {
|
||||
}
|
||||
.header-link-table td {
|
||||
padding-right:1em;
|
||||
vertical-align:center;
|
||||
line-height:0;
|
||||
/*border:solid 1px #f00;*/
|
||||
}
|
||||
.header-link-table a {
|
||||
/*color:#e0d7cf;*/
|
||||
color:#dddddd;
|
||||
text-decoration:none;
|
||||
}
|
||||
.header-link-table a:hover {
|
||||
color:#ffffff;
|
||||
}
|
||||
|
||||
.footer-link {
|
||||
color:#e0d7cf;
|
||||
text-decoration:none;
|
||||
}
|
||||
.footer-link:hover {
|
||||
color:#ffffff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.mobile-main-link {
|
||||
text-align:left;
|
||||
background-color:#e0d7cf;
|
||||
color:#036;
|
||||
border-bottom:solid 1px #333;
|
||||
padding-left:16px;
|
||||
}
|
||||
.mobile-main-link a {
|
||||
display:block;
|
||||
padding-top:8px;
|
||||
padding-bottom:8px;
|
||||
color:#036;
|
||||
width:100%;
|
||||
height:100%;
|
||||
max-width:100%;
|
||||
}
|
||||
|
||||
|
||||
table.doc {
|
||||
border:solid 0px #333;
|
||||
border-collapse:collapse;
|
||||
}
|
||||
|
||||
th.doc, td.doc {
|
||||
padding:0.5em;
|
||||
}
|
||||
|
||||
th.doc {
|
||||
border:solid 1px #003800;
|
||||
background-color:#003800;
|
||||
color:#FFF;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
td.doc {
|
||||
border:solid 1px #666;
|
||||
}
|
||||
|
||||
td.doc p, th.doc p {
|
||||
padding:0;
|
||||
margin:0;
|
||||
}
|
||||
|
||||
a.doc-navigation {
|
||||
display:block;
|
||||
padding:0.5em;
|
||||
color:#003800;
|
||||
border-bottom:solid 1px #bbbbbb;
|
||||
}
|
||||
|
||||
a.doc-navigation:hover {
|
||||
color:#fff;
|
||||
background-color:#003800;
|
||||
text-decoration:none;
|
||||
/*border-bottom:solid 1px #003800;*/
|
||||
}
|
||||
|
||||
/*
|
||||
a.doc-navigation:hover {
|
||||
background-color:#c5ecc5;
|
||||
text-decoration:none;
|
||||
}
|
||||
*/
|
||||
|
||||
a.doc-navigation-active {
|
||||
background-color:#cccccc;
|
||||
}
|
||||
a.doc-navigation-active:hover {
|
||||
color:#003800;
|
||||
background-color:#cccccc;
|
||||
}
|
||||
|
||||
a.doc-navigation-l1 {
|
||||
padding:0.1em;
|
||||
padding-left:1.5em;
|
||||
}
|
||||
a.doc-navigation-l2 {
|
||||
padding:0.1em;
|
||||
padding-left:3em;
|
||||
}
|
||||
a.doc-navigation-l3 {
|
||||
padding:0.1em;
|
||||
padding-left:4em;
|
||||
}
|
||||
a.doc-navigation-l4 {
|
||||
padding:0.1em;
|
||||
padding-left:5em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body style="margin:0; padding:0">
|
||||
<div style="background-color:#003800; color:#bfa792;">
|
||||
<div style="max-width:100%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="border-collapse:collapse; border-spacing:0; padding:0; padding-right:1em;">
|
||||
<tr>
|
||||
<td style="padding:0.75em; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="border-collapse:collapse; margin:0; padding:0">
|
||||
<tr>
|
||||
<td style="vertical-align:bottom; padding:0em; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
<td><a href="../manual/index.html">Documentation</a></td>
|
||||
<td><a href="index.html">Examples</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td style="padding:0.1em; width:25%; text-align:right; vertical-align:center;">
|
||||
<a href="https://discord.gg/9vpqbjU"><img src="../../img/Discord-Logo-White.svg" style="margin:0; padding:0; height:32px; width:32px;"></a>
|
||||
</td>
|
||||
<td style="padding:0.1em; width:25%; text-align:right; vertical-align:center;">
|
||||
<a href="https://twitter.com/mackron"><img src="../../img/twitter_white.png" style="margin:0; padding:0; height:32px; width:32px;"></a>
|
||||
</td>
|
||||
<td style="padding:0.1em; padding-right:1em; width:25%; text-align:right; vertical-align:center;">
|
||||
<a href="https://github.com/mackron/miniaudio"><img src="../../img/github_white.png" style="margin:0; padding:0; height:24px; width:24px;"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Custom Decoder</h1><p>
|
||||
Demonstrates how to implement a custom decoder.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
This example implements two custom decoders:
|
||||
</p>
|
||||
<ul style="overflow:hidden;">
|
||||
<li>
|
||||
</li>
|
||||
</ul>
|
||||
<ul style="overflow:hidden;">
|
||||
<li>
|
||||
Vorbis via libvorbis
|
||||
</li>
|
||||
<li>
|
||||
Opus via libopus
|
||||
|
||||
A </li>
|
||||
</ul>
|
||||
<p>
|
||||
A custom decoder must implement a data source. In this example, the libvorbis data source is called
|
||||
<span style="font-family:monospace;">ma_libvorbis</span> and the Opus data source is called <span style="font-family:monospace;">ma_libopus</span>. These two objects are compatible
|
||||
with the <span style="font-family:monospace;">ma_data_source</span> APIs and can be taken straight from this example and used in real code.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
The custom decoding data sources (<span style="font-family:monospace;">ma_libvorbis</span> and <span style="font-family:monospace;">ma_libopus</span> in this example) are connected to
|
||||
the decoder via the decoder config (<span style="font-family:monospace;">ma_decoder_config</span>). You need to implement a vtable for each
|
||||
of your custom decoders. See <span style="font-family:monospace;">ma_decoding_backend_vtable</span> for the functions you need to implement.
|
||||
The <span style="font-family:monospace;">onInitFile</span>, <span style="font-family:monospace;">onInitFileW</span> and <span style="font-family:monospace;">onInitMemory</span> functions are optional.</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_VORBIS <span style="color:#009900">/* Disable the built-in Vorbis decoder to ensure the libvorbis decoder is picked. */</span>
|
||||
<span style="color:#666666">#define</span> MA_NO_OPUS <span style="color:#009900">/* Disable the (not yet implemented) built-in Opus decoder to ensure the libopus decoder is picked. */</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">"../extras/miniaudio_libvorbis.h"</span>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../extras/miniaudio_libopus.h"</span>
|
||||
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0099cc">ma_result</span> ma_decoding_backend_init__libvorbis(<span style="color:#0033ff">void</span>* pUserData, ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, <span style="color:#0033ff">void</span>* pReadSeekTellUserData, <span style="color:#0033ff">const</span> ma_decoding_backend_config* pConfig, <span style="color:#0033ff">const</span> ma_allocation_callbacks* pAllocationCallbacks, <span style="color:#0099cc">ma_data_source</span>** ppBackend)
|
||||
{
|
||||
<span style="color:#0099cc">ma_result</span> result;
|
||||
ma_libvorbis* pVorbis;
|
||||
|
||||
(<span style="color:#0033ff">void</span>)pUserData;
|
||||
|
||||
pVorbis = (ma_libvorbis*)ma_malloc(<span style="color:#0033ff">sizeof</span>(*pVorbis), pAllocationCallbacks);
|
||||
<span style="color:#0033ff">if</span> (pVorbis == NULL) {
|
||||
<span style="color:#0033ff">return</span> MA_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
result = ma_libvorbis_init(onRead, onSeek, onTell, pReadSeekTellUserData, pConfig, pAllocationCallbacks, pVorbis);
|
||||
<span style="color:#0033ff">if</span> (result != MA_SUCCESS) {
|
||||
ma_free(pVorbis, pAllocationCallbacks);
|
||||
<span style="color:#0033ff">return</span> result;
|
||||
}
|
||||
|
||||
*ppBackend = pVorbis;
|
||||
|
||||
<span style="color:#0033ff">return</span> MA_SUCCESS;
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0099cc">ma_result</span> ma_decoding_backend_init_file__libvorbis(<span style="color:#0033ff">void</span>* pUserData, <span style="color:#0033ff">const</span> <span style="color:#0033ff">char</span>* pFilePath, <span style="color:#0033ff">const</span> ma_decoding_backend_config* pConfig, <span style="color:#0033ff">const</span> ma_allocation_callbacks* pAllocationCallbacks, <span style="color:#0099cc">ma_data_source</span>** ppBackend)
|
||||
{
|
||||
<span style="color:#0099cc">ma_result</span> result;
|
||||
ma_libvorbis* pVorbis;
|
||||
|
||||
(<span style="color:#0033ff">void</span>)pUserData;
|
||||
|
||||
pVorbis = (ma_libvorbis*)ma_malloc(<span style="color:#0033ff">sizeof</span>(*pVorbis), pAllocationCallbacks);
|
||||
<span style="color:#0033ff">if</span> (pVorbis == NULL) {
|
||||
<span style="color:#0033ff">return</span> MA_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
result = ma_libvorbis_init_file(pFilePath, pConfig, pAllocationCallbacks, pVorbis);
|
||||
<span style="color:#0033ff">if</span> (result != MA_SUCCESS) {
|
||||
ma_free(pVorbis, pAllocationCallbacks);
|
||||
<span style="color:#0033ff">return</span> result;
|
||||
}
|
||||
|
||||
*ppBackend = pVorbis;
|
||||
|
||||
<span style="color:#0033ff">return</span> MA_SUCCESS;
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0033ff">void</span> ma_decoding_backend_uninit__libvorbis(<span style="color:#0033ff">void</span>* pUserData, <span style="color:#0099cc">ma_data_source</span>* pBackend, <span style="color:#0033ff">const</span> ma_allocation_callbacks* pAllocationCallbacks)
|
||||
{
|
||||
ma_libvorbis* pVorbis = (ma_libvorbis*)pBackend;
|
||||
|
||||
(<span style="color:#0033ff">void</span>)pUserData;
|
||||
|
||||
ma_libvorbis_uninit(pVorbis, pAllocationCallbacks);
|
||||
ma_free(pVorbis, pAllocationCallbacks);
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0099cc">ma_result</span> ma_decoding_backend_get_channel_map__libvorbis(<span style="color:#0033ff">void</span>* pUserData, <span style="color:#0099cc">ma_data_source</span>* pBackend, <span style="color:#0099cc">ma_channel</span>* pChannelMap, size_t channelMapCap)
|
||||
{
|
||||
ma_libvorbis* pVorbis = (ma_libvorbis*)pBackend;
|
||||
|
||||
(<span style="color:#0033ff">void</span>)pUserData;
|
||||
|
||||
<span style="color:#0033ff">return</span> ma_libvorbis_get_data_format(pVorbis, NULL, NULL, NULL, pChannelMap, channelMapCap);
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">static</span> ma_decoding_backend_vtable g_ma_decoding_backend_vtable_libvorbis =
|
||||
{
|
||||
ma_decoding_backend_init__libvorbis,
|
||||
ma_decoding_backend_init_file__libvorbis,
|
||||
NULL, <span style="color:#009900">/* onInitFileW() */</span>
|
||||
NULL, <span style="color:#009900">/* onInitMemory() */</span>
|
||||
ma_decoding_backend_uninit__libvorbis,
|
||||
ma_decoding_backend_get_channel_map__libvorbis
|
||||
};
|
||||
|
||||
|
||||
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0099cc">ma_result</span> ma_decoding_backend_init__libopus(<span style="color:#0033ff">void</span>* pUserData, ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, <span style="color:#0033ff">void</span>* pReadSeekTellUserData, <span style="color:#0033ff">const</span> ma_decoding_backend_config* pConfig, <span style="color:#0033ff">const</span> ma_allocation_callbacks* pAllocationCallbacks, <span style="color:#0099cc">ma_data_source</span>** ppBackend)
|
||||
{
|
||||
<span style="color:#0099cc">ma_result</span> result;
|
||||
ma_libopus* pOpus;
|
||||
|
||||
(<span style="color:#0033ff">void</span>)pUserData;
|
||||
|
||||
pOpus = (ma_libopus*)ma_malloc(<span style="color:#0033ff">sizeof</span>(*pOpus), pAllocationCallbacks);
|
||||
<span style="color:#0033ff">if</span> (pOpus == NULL) {
|
||||
<span style="color:#0033ff">return</span> MA_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
result = ma_libopus_init(onRead, onSeek, onTell, pReadSeekTellUserData, pConfig, pAllocationCallbacks, pOpus);
|
||||
<span style="color:#0033ff">if</span> (result != MA_SUCCESS) {
|
||||
ma_free(pOpus, pAllocationCallbacks);
|
||||
<span style="color:#0033ff">return</span> result;
|
||||
}
|
||||
|
||||
*ppBackend = pOpus;
|
||||
|
||||
<span style="color:#0033ff">return</span> MA_SUCCESS;
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0099cc">ma_result</span> ma_decoding_backend_init_file__libopus(<span style="color:#0033ff">void</span>* pUserData, <span style="color:#0033ff">const</span> <span style="color:#0033ff">char</span>* pFilePath, <span style="color:#0033ff">const</span> ma_decoding_backend_config* pConfig, <span style="color:#0033ff">const</span> ma_allocation_callbacks* pAllocationCallbacks, <span style="color:#0099cc">ma_data_source</span>** ppBackend)
|
||||
{
|
||||
<span style="color:#0099cc">ma_result</span> result;
|
||||
ma_libopus* pOpus;
|
||||
|
||||
(<span style="color:#0033ff">void</span>)pUserData;
|
||||
|
||||
pOpus = (ma_libopus*)ma_malloc(<span style="color:#0033ff">sizeof</span>(*pOpus), pAllocationCallbacks);
|
||||
<span style="color:#0033ff">if</span> (pOpus == NULL) {
|
||||
<span style="color:#0033ff">return</span> MA_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
result = ma_libopus_init_file(pFilePath, pConfig, pAllocationCallbacks, pOpus);
|
||||
<span style="color:#0033ff">if</span> (result != MA_SUCCESS) {
|
||||
ma_free(pOpus, pAllocationCallbacks);
|
||||
<span style="color:#0033ff">return</span> result;
|
||||
}
|
||||
|
||||
*ppBackend = pOpus;
|
||||
|
||||
<span style="color:#0033ff">return</span> MA_SUCCESS;
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0033ff">void</span> ma_decoding_backend_uninit__libopus(<span style="color:#0033ff">void</span>* pUserData, <span style="color:#0099cc">ma_data_source</span>* pBackend, <span style="color:#0033ff">const</span> ma_allocation_callbacks* pAllocationCallbacks)
|
||||
{
|
||||
ma_libopus* pOpus = (ma_libopus*)pBackend;
|
||||
|
||||
(<span style="color:#0033ff">void</span>)pUserData;
|
||||
|
||||
ma_libopus_uninit(pOpus, pAllocationCallbacks);
|
||||
ma_free(pOpus, pAllocationCallbacks);
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0099cc">ma_result</span> ma_decoding_backend_get_channel_map__libopus(<span style="color:#0033ff">void</span>* pUserData, <span style="color:#0099cc">ma_data_source</span>* pBackend, <span style="color:#0099cc">ma_channel</span>* pChannelMap, size_t channelMapCap)
|
||||
{
|
||||
ma_libopus* pOpus = (ma_libopus*)pBackend;
|
||||
|
||||
(<span style="color:#0033ff">void</span>)pUserData;
|
||||
|
||||
<span style="color:#0033ff">return</span> ma_libopus_get_data_format(pOpus, NULL, NULL, NULL, pChannelMap, channelMapCap);
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">static</span> ma_decoding_backend_vtable g_ma_decoding_backend_vtable_libopus =
|
||||
{
|
||||
ma_decoding_backend_init__libopus,
|
||||
ma_decoding_backend_init_file__libopus,
|
||||
NULL, <span style="color:#009900">/* onInitFileW() */</span>
|
||||
NULL, <span style="color:#009900">/* onInitMemory() */</span>
|
||||
ma_decoding_backend_uninit__libopus,
|
||||
ma_decoding_backend_get_channel_map__libopus
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
<span style="color:#0033ff">void</span> data_callback(<span style="color:#0099cc">ma_device</span>* pDevice, <span style="color:#0033ff">void</span>* pOutput, <span style="color:#0033ff">const</span> <span style="color:#0033ff">void</span>* pInput, <span style="color:#0099cc">ma_uint32</span> frameCount)
|
||||
{
|
||||
<span style="color:#0099cc">ma_data_source</span>* pDataSource = (<span style="color:#0099cc">ma_data_source</span>*)pDevice->pUserData;
|
||||
<span style="color:#0033ff">if</span> (pDataSource == NULL) {
|
||||
<span style="color:#0033ff">return</span>;
|
||||
}
|
||||
|
||||
ma_data_source_read_pcm_frames(pDataSource, pOutput, frameCount, NULL, MA_TRUE);
|
||||
|
||||
(<span style="color:#0033ff">void</span>)pInput;
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">int</span> main(<span style="color:#0033ff">int</span> argc, <span style="color:#0033ff">char</span>** argv)
|
||||
{
|
||||
<span style="color:#0099cc">ma_result</span> result;
|
||||
<span style="color:#0099cc">ma_decoder_config</span> decoderConfig;
|
||||
<span style="color:#0099cc">ma_decoder</span> decoder;
|
||||
<span style="color:#0099cc">ma_device_config</span> deviceConfig;
|
||||
<span style="color:#0099cc">ma_device</span> device;
|
||||
ma_format format;
|
||||
<span style="color:#0099cc">ma_uint32</span> channels;
|
||||
<span style="color:#0099cc">ma_uint32</span> sampleRate;
|
||||
|
||||
<span style="color:#009900">/*
|
||||
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>
|
||||
ma_decoding_backend_vtable* pCustomBackendVTables[] =
|
||||
{
|
||||
&g_ma_decoding_backend_vtable_libvorbis,
|
||||
&g_ma_decoding_backend_vtable_libopus
|
||||
};
|
||||
|
||||
|
||||
<span style="color:#0033ff">if</span> (argc < 2) {
|
||||
printf(<span style="color:#cc3300">"No input file.\n"</span>);
|
||||
<span style="color:#0033ff">return</span> -1;
|
||||
}
|
||||
|
||||
|
||||
<span style="color:#009900">/* Initialize the decoder. */</span>
|
||||
decoderConfig = ma_decoder_config_init_default();
|
||||
decoderConfig.pCustomBackendUserData = NULL; <span style="color:#009900">/* In this example our backend objects are contained within a ma_decoder_ex object to avoid a malloc. Our vtables need to know about this. */</span>
|
||||
decoderConfig.ppCustomBackendVTables = pCustomBackendVTables;
|
||||
decoderConfig.customBackendCount = <span style="color:#0033ff">sizeof</span>(pCustomBackendVTables) / <span style="color:#0033ff">sizeof</span>(pCustomBackendVTables[0]);
|
||||
|
||||
result = ma_decoder_init_file(argv[1], &decoderConfig, &decoder);
|
||||
<span style="color:#0033ff">if</span> (result != MA_SUCCESS) {
|
||||
printf(<span style="color:#cc3300">"Failed to initialize decoder."</span>);
|
||||
<span style="color:#0033ff">return</span> -1;
|
||||
}
|
||||
|
||||
|
||||
<span style="color:#009900">/* Initialize the device. */</span>
|
||||
result = ma_data_source_get_data_format(&decoder, &format, &channels, &sampleRate);
|
||||
<span style="color:#0033ff">if</span> (result != MA_SUCCESS) {
|
||||
printf(<span style="color:#cc3300">"Failed to retrieve decoder data format."</span>);
|
||||
ma_decoder_uninit(&decoder);
|
||||
<span style="color:#0033ff">return</span> -1;
|
||||
}
|
||||
|
||||
deviceConfig = ma_device_config_init(ma_device_type_playback);
|
||||
deviceConfig.playback.format = format;
|
||||
deviceConfig.playback.channels = channels;
|
||||
deviceConfig.sampleRate = sampleRate;
|
||||
deviceConfig.dataCallback = data_callback;
|
||||
deviceConfig.pUserData = &decoder;
|
||||
|
||||
<span style="color:#0033ff">if</span> (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) {
|
||||
printf(<span style="color:#cc3300">"Failed to open playback device.\n"</span>);
|
||||
ma_decoder_uninit(&decoder);
|
||||
<span style="color:#0033ff">return</span> -1;
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">if</span> (ma_device_start(&device) != MA_SUCCESS) {
|
||||
printf(<span style="color:#cc3300">"Failed to start playback device.\n"</span>);
|
||||
ma_device_uninit(&device);
|
||||
ma_decoder_uninit(&decoder);
|
||||
<span style="color:#0033ff">return</span> -1;
|
||||
}
|
||||
|
||||
printf(<span style="color:#cc3300">"Press Enter to quit..."</span>);
|
||||
getchar();
|
||||
|
||||
ma_device_uninit(&device);
|
||||
ma_decoder_uninit(&decoder);
|
||||
|
||||
<span style="color:#0033ff">return</span> 0;
|
||||
}</pre></div></td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<table style="margin:0 auto; padding:1em 0px; text-align:center;">
|
||||
<tr>
|
||||
<td style="vertical-align:center;"><a style="padding:0;" href="https://discord.gg/9vpqbjU"><img src="../../img/Discord-Logo-White.svg" style="padding:0; height:32px; width:32px;"></a></td>
|
||||
<td style="vertical-align:center;"><a style="padding:0;" href="https://twitter.com/mackron"><img src="../../img/twitter_white.png" style="padding:0; height:32px; width:32px;"></a></td>
|
||||
<td style="vertical-align:center;"><a style="padding:0;" href="https://github.com/mackron/miniaudio"><img src="../../img/github_white.png" style="padding:0; height:24px; width:24px;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div style="color:#e0d7cf; font-size:9pt; padding:2em 0px; text-align:center;">
|
||||
Copyright © 2021 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:mackron@gmail.com">mackron@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -245,7 +245,7 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Fixed Size Callback</h1><p>
|
||||
Shows one way to implement a data callback that is called with a fixed frame count.
|
||||
</p>
|
||||
|
||||
@@ -245,9 +245,10 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation doc-navigation-active">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation doc-navigation-active">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<div style="text-align:center; padding:1em; padding-bottom:2em;"><div style="text-align:center; overflow:hidden;"><img src="../../img/logo1_large.png" style="width:auto; height:auto; min-height:70px; overflow:hidden;"></div><div style="padding-top:1em; font-weight:bold; font-size:2em; color:#444;">Examples</div><div style="padding-top:0.75em; text-align:center;"><a href="../manual/index.html">Programming Manual</a> - <a href="../api/index.html">API Reference</a> - <a href="https://github.com/mackron/miniaudio">Source Code</a></div></div>
|
||||
<table style="border:none;"><tr><td style="padding-right:2em;"><a href="custom_backend.html">Custom Backend</a></td><td>This example show how a custom backend can be implemented.</td></tr><tr><td style="padding-right:2em;"><a href="fixed_size_callback.html">Fixed Size Callback</a></td><td>Shows one way to implement a data callback that is called with a fixed frame count.</td></tr><tr><td style="padding-right:2em;"><a href="simple_capture.html">Simple Capture</a></td><td>Demonstrates how to capture data from a microphone using the low-level API.</td></tr><tr><td style="padding-right:2em;"><a href="simple_duplex.html">Simple Duplex</a></td><td>Demonstrates duplex mode which is where data is captured from a microphone and then output to a speaker device.</td></tr><tr><td style="padding-right:2em;"><a href="simple_enumeration.html">Simple Enumeration</a></td><td>Demonstrates how to enumerate over devices.</td></tr><tr><td style="padding-right:2em;"><a href="simple_loopback.html">Simple Loopback</a></td><td>Demonstrates how to implement loopback recording.</td></tr><tr><td style="padding-right:2em;"><a href="simple_looping.html">Simple Looping</a></td><td>Shows one way to handle looping of a sound.</td></tr><tr><td style="padding-right:2em;"><a href="simple_mixing.html">Simple Mixing</a></td><td>Demonstrates one way to load multiple files and play them all back at the same time.</td></tr><tr><td style="padding-right:2em;"><a href="simple_playback.html">Simple Playback</a></td><td>Demonstrates how to load a sound file and play it back using the low-level API.</td></tr><tr><td style="padding-right:2em;"><a href="simple_playback_sine.html">Simple Playback Sine</a></td><td>Demonstrates playback of a sine wave.</td></tr></table></td>
|
||||
<table style="border:none;"><tr><td style="padding-right:2em;"><a href="custom_backend.html">Custom Backend</a></td><td>This example show how a custom backend can be implemented.</td></tr><tr><td style="padding-right:2em;"><a href="custom_decoder.html">Custom Decoder</a></td><td>Demonstrates how to implement a custom decoder.</td></tr><tr><td style="padding-right:2em;"><a href="data_source_chaining.html">Data Source Chaining</a></td><td>Demonstrates one way to chain together a number of data sources so they play back seamlessly
|
||||
without gaps.</td></tr><tr><td style="padding-right:2em;"><a href="fixed_size_callback.html">Fixed Size Callback</a></td><td>Shows one way to implement a data callback that is called with a fixed frame count.</td></tr><tr><td style="padding-right:2em;"><a href="simple_capture.html">Simple Capture</a></td><td>Demonstrates how to capture data from a microphone using the low-level API.</td></tr><tr><td style="padding-right:2em;"><a href="simple_duplex.html">Simple Duplex</a></td><td>Demonstrates duplex mode which is where data is captured from a microphone and then output to a speaker device.</td></tr><tr><td style="padding-right:2em;"><a href="simple_enumeration.html">Simple Enumeration</a></td><td>Demonstrates how to enumerate over devices.</td></tr><tr><td style="padding-right:2em;"><a href="simple_loopback.html">Simple Loopback</a></td><td>Demonstrates how to implement loopback recording.</td></tr><tr><td style="padding-right:2em;"><a href="simple_looping.html">Simple Looping</a></td><td>Shows one way to handle looping of a sound.</td></tr><tr><td style="padding-right:2em;"><a href="simple_mixing.html">Simple Mixing</a></td><td>Demonstrates one way to load multiple files and play them all back at the same time.</td></tr><tr><td style="padding-right:2em;"><a href="simple_playback.html">Simple Playback</a></td><td>Demonstrates how to load a sound file and play it back using the low-level API.</td></tr><tr><td style="padding-right:2em;"><a href="simple_playback_sine.html">Simple Playback Sine</a></td><td>Demonstrates playback of a sine wave.</td></tr></table></td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<table style="margin:0 auto; padding:1em 0px; text-align:center;">
|
||||
|
||||
@@ -245,7 +245,7 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Simple Capture</h1><p>
|
||||
Demonstrates how to capture data from a microphone using the low-level API.
|
||||
</p>
|
||||
@@ -285,7 +285,7 @@ data received by the microphone straight to a WAV file.</p>
|
||||
<span style="color:#0099cc">ma_device</span> device;
|
||||
|
||||
<span style="color:#0033ff">if</span> (argc < 2) {
|
||||
printf(<span style="color:#cc3300">"No input file.\n"</span>);
|
||||
printf(<span style="color:#cc3300">"No output file.\n"</span>);
|
||||
<span style="color:#0033ff">return</span> -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Simple Duplex</h1><p>
|
||||
Demonstrates duplex mode which is where data is captured from a microphone and then output to a speaker device.
|
||||
</p>
|
||||
|
||||
@@ -245,7 +245,7 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Simple Enumeration</h1><p>
|
||||
Demonstrates how to enumerate over devices.
|
||||
</p>
|
||||
|
||||
@@ -245,7 +245,7 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Simple Loopback</h1><p>
|
||||
Demonstrates how to implement loopback recording.
|
||||
</p>
|
||||
@@ -294,7 +294,7 @@ properties. The output buffer in the callback will be null whereas the input buf
|
||||
};
|
||||
|
||||
<span style="color:#0033ff">if</span> (argc < 2) {
|
||||
printf(<span style="color:#cc3300">"No input file.\n"</span>);
|
||||
printf(<span style="color:#cc3300">"No output file.\n"</span>);
|
||||
<span style="color:#0033ff">return</span> -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Simple Looping</h1><p>
|
||||
Shows one way to handle looping of a sound.
|
||||
</p>
|
||||
|
||||
@@ -245,7 +245,7 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Simple Mixing</h1><p>
|
||||
Demonstrates one way to load multiple files and play them all back at the same time.
|
||||
</p>
|
||||
|
||||
@@ -245,7 +245,7 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Simple Playback</h1><p>
|
||||
Demonstrates how to load a sound file and play it back using the low-level API.
|
||||
</p>
|
||||
@@ -293,6 +293,7 @@ the simple_mixing example for how best to do this.</p>
|
||||
|
||||
result = ma_decoder_init_file(argv[1], NULL, &decoder);
|
||||
<span style="color:#0033ff">if</span> (result != MA_SUCCESS) {
|
||||
printf(<span style="color:#cc3300">"Could not load file: %s\n"</span>, argv[1]);
|
||||
<span style="color:#0033ff">return</span> -2;
|
||||
}
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 ">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Simple Playback Sine</h1><p>
|
||||
Demonstrates playback of a sine wave.
|
||||
</p>
|
||||
|
||||
+9
-37
@@ -1126,38 +1126,12 @@ runtime linking via <span style="font-family:monospace;">dlopen()</span>.</p>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="doc" valign="top"><p>
|
||||
MA_LOG_LEVEL [level]
|
||||
|
||||
</p>
|
||||
<p>
|
||||
|
||||
|
||||
</p>
|
||||
<p>
|
||||
|
||||
|
||||
</p>
|
||||
<p>
|
||||
|
||||
MA_DEBUG_OUTPUT
|
||||
</p>
|
||||
</td>
|
||||
<td class="doc" valign="top"><p>
|
||||
Sets the logging level. Set <span style="font-family:monospace;">level</span> to one of the following:
|
||||
|
||||
</p>
|
||||
<div style="font-family:monospace; margin:1em 0em;"><pre style="margin:0.5em 1em; padding:0; line-height:125%; overflow-x:auto;">
|
||||
MA_LOG_LEVEL_VERBOSE
|
||||
MA_LOG_LEVEL_INFO
|
||||
MA_LOG_LEVEL_WARNING
|
||||
MA_LOG_LEVEL_ERROR
|
||||
</pre></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="doc" valign="top"><p>
|
||||
MA_DEBUG_OUTPUT</p>
|
||||
</td>
|
||||
<td class="doc" valign="top"><p>
|
||||
Enable <span style="font-family:monospace;">printf()</span> debug output.</p>
|
||||
Enable processing of MA_LOG_LEVEL_DEBUG messages and <span style="font-family:monospace;">printf()</span>
|
||||
output.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -1493,21 +1467,19 @@ ma_decoder_seek_to_pcm_frame(pDecoder, 0);
|
||||
</pre></div><p>
|
||||
|
||||
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 <span style="font-family:monospace;">_wav</span>, <span style="font-family:monospace;">_mp3</span>, etc. varients of the aforementioned initialization APIs:
|
||||
is already known. In this case you can use <span style="font-family:monospace;">encodingFormat</span> variable in the device config to specify a specific encoding format you want to decode:
|
||||
</p>
|
||||
<p>
|
||||
|
||||
</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;">
|
||||
ma_decoder_init_wav()
|
||||
ma_decoder_init_mp3()
|
||||
ma_decoder_init_memory_wav()
|
||||
ma_decoder_init_memory_mp3()
|
||||
ma_decoder_init_file_wav()
|
||||
ma_decoder_init_file_mp3()
|
||||
etc.
|
||||
decoderConfig.encodingFormat = ma_encoding_format_wav;
|
||||
</pre></div><p>
|
||||
|
||||
See the <span style="font-family:monospace;">ma_encoding_format</span> enum for possible encoding formats.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
The <span style="font-family:monospace;">ma_decoder_init_file()</span> API will try using the file extension to determine which decoding backend to prefer.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user