mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Update website.
This commit is contained in:
+86
-1
@@ -1,10 +1,23 @@
|
||||
body{
|
||||
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;
|
||||
@@ -105,4 +118,76 @@ a:hover {
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; 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="../examples/index.html" class="doc-navigation">Examples</a><a href="index.html" class="doc-navigation doc-navigation-active">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;"><img src="../../img/logo1_large.png" style="width:auto; height:auto; min-height:70px;"></div><div style="padding-top:1em; font-weight:bold; font-size:2em; color:#444;">API Reference</div><div style="padding-top:0.75em; text-align:center;"><a href="../manual/index.html">Programming Manual</a> - <a href="../examples/index.html">Examples</a> - <a href="https://github.com/dr-soft/miniaudio">Source Code</a></div></div>
|
||||
Coming soon...</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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,260 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href=".." class="doc-navigation">Documentation Home</a><a href="../guide" class="doc-navigation">Programming Guide</a><a href="" class="doc-navigation doc-navigation-active">Examples</a><a href="../api" class="doc-navigation">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
</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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,409 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; 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="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>
|
||||
<p>
|
||||
|
||||
miniaudio does not have built-in support for firing the data callback with fixed sized buffers. In order to support
|
||||
this you need to implement a layer that sits on top of the normal data callback. This example demonstrates one way of
|
||||
doing this.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
This example uses a ring buffer to act as the intermediary buffer between the low-level device callback and the fixed
|
||||
sized callback. You do not need to use a ring buffer here, but it's a good opportunity to demonstrate how to use
|
||||
miniaudio's ring buffer API. The ring buffer in this example is in global scope for simplicity, but you can pass it
|
||||
around as user data for the device (device.pUserData).
|
||||
</p>
|
||||
<p>
|
||||
|
||||
This example only works for output devices, but can be implemented for input devices by simply swapping the direction
|
||||
of data movement.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em;"><pre style="margin:0.5em 1em; padding:0; line-height:125%">
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define DEVICE_FORMAT ma_format_f32
|
||||
#define DEVICE_CHANNELS 1
|
||||
#define DEVICE_SAMPLE_RATE 48000
|
||||
|
||||
#define PCM_FRAME_CHUNK_SIZE 1234 /* <-- Play around with this to control your fixed sized buffer. */
|
||||
|
||||
ma_waveform g_sineWave;
|
||||
ma_pcm_rb g_rb; /* The ring buffer. */
|
||||
|
||||
void data_callback_fixed(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
|
||||
{
|
||||
/*
|
||||
This callback will have a guaranteed and consistent size for frameCount. In this example we just fill the output buffer with a sine wave. This
|
||||
is where you would handle the callback just like normal, only now you can assume frameCount is a fixed size.
|
||||
*/
|
||||
printf("frameCount=%d\n", frameCount);
|
||||
|
||||
ma_waveform_read_pcm_frames(&g_sineWave, pOutput, frameCount);
|
||||
|
||||
/* Unused in this example. */
|
||||
(void)pDevice;
|
||||
(void)pInput;
|
||||
}
|
||||
|
||||
void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
|
||||
{
|
||||
/*
|
||||
This is the device's main data callback. This will handle all of the fixed sized buffer management for you and will call data_callback_fixed()
|
||||
for you. You should do all of your normal callback stuff in data_callback_fixed().
|
||||
*/
|
||||
ma_uint32 pcmFramesAvailableInRB;
|
||||
ma_uint32 pcmFramesProcessed = 0;
|
||||
ma_uint8* pRunningOutput = (ma_uint8*)pOutput;
|
||||
|
||||
MA_ASSERT(pDevice->playback.channels == DEVICE_CHANNELS);
|
||||
|
||||
/*
|
||||
The first thing to do is check if there's enough data available in the ring buffer. If so we can read from it. Otherwise we need to keep filling
|
||||
the ring buffer until there's enough, making sure we only fill the ring buffer in chunks of PCM_FRAME_CHUNK_SIZE.
|
||||
*/
|
||||
while (pcmFramesProcessed < frameCount) { /* Keep going until we've filled the output buffer. */
|
||||
ma_uint32 framesRemaining = frameCount - pcmFramesProcessed;
|
||||
|
||||
pcmFramesAvailableInRB = ma_pcm_rb_available_read(&g_rb);
|
||||
if (pcmFramesAvailableInRB > 0) {
|
||||
ma_uint32 framesToRead = (framesRemaining < pcmFramesAvailableInRB) ? framesRemaining : pcmFramesAvailableInRB;
|
||||
void* pReadBuffer;
|
||||
|
||||
ma_pcm_rb_acquire_read(&g_rb, &framesToRead, &pReadBuffer);
|
||||
{
|
||||
memcpy(pRunningOutput, pReadBuffer, framesToRead * ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels));
|
||||
}
|
||||
ma_pcm_rb_commit_read(&g_rb, framesToRead, pReadBuffer);
|
||||
|
||||
pRunningOutput += framesToRead * ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
|
||||
pcmFramesProcessed += framesToRead;
|
||||
} else {
|
||||
/*
|
||||
There's nothing in the buffer. Fill it with more data from the callback. We reset the buffer first so that the read and write pointers
|
||||
are reset back to the start so we can fill the ring buffer in chunks of PCM_FRAME_CHUNK_SIZE which is what we initialized it with. Note
|
||||
that this is not how you would want to do it in a multi-threaded environment. In this case you would want to seek the write pointer
|
||||
forward via the producer thread and the read pointer forward via the consumer thread (this thread).
|
||||
*/
|
||||
ma_uint32 framesToWrite = PCM_FRAME_CHUNK_SIZE;
|
||||
void* pWriteBuffer;
|
||||
|
||||
ma_pcm_rb_reset(&g_rb);
|
||||
ma_pcm_rb_acquire_write(&g_rb, &framesToWrite, &pWriteBuffer);
|
||||
{
|
||||
MA_ASSERT(framesToWrite == PCM_FRAME_CHUNK_SIZE); /* <-- This should always work in this example because we just reset the ring buffer. */
|
||||
data_callback_fixed(pDevice, pWriteBuffer, NULL, framesToWrite);
|
||||
}
|
||||
ma_pcm_rb_commit_write(&g_rb, framesToWrite, pWriteBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
/* Unused in this example. */
|
||||
(void)pInput;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ma_waveform_config waveformConfig;
|
||||
ma_device_config deviceConfig;
|
||||
ma_device device;
|
||||
|
||||
waveformConfig = ma_waveform_config_init(DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, ma_waveform_type_sine, 0.1, 220);
|
||||
ma_waveform_init(&waveformConfig, &g_sineWave);
|
||||
|
||||
ma_pcm_rb_init(DEVICE_FORMAT, DEVICE_CHANNELS, PCM_FRAME_CHUNK_SIZE, NULL, NULL, &g_rb);
|
||||
|
||||
deviceConfig = ma_device_config_init(ma_device_type_playback);
|
||||
deviceConfig.playback.format = DEVICE_FORMAT;
|
||||
deviceConfig.playback.channels = DEVICE_CHANNELS;
|
||||
deviceConfig.sampleRate = DEVICE_SAMPLE_RATE;
|
||||
deviceConfig.dataCallback = data_callback;
|
||||
deviceConfig.pUserData = NULL; /* <-- Set this to a pointer to the ring buffer if you don't want it in global scope. */
|
||||
|
||||
if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) {
|
||||
printf("Failed to open playback device.\n");
|
||||
ma_pcm_rb_uninit(&g_rb);
|
||||
return -4;
|
||||
}
|
||||
|
||||
printf("Device Name: %s\n", device.playback.name);
|
||||
|
||||
if (ma_device_start(&device) != MA_SUCCESS) {
|
||||
printf("Failed to start playback device.\n");
|
||||
ma_pcm_rb_uninit(&g_rb);
|
||||
ma_device_uninit(&device);
|
||||
return -5;
|
||||
}
|
||||
|
||||
printf("Press Enter to quit...\n");
|
||||
getchar();
|
||||
|
||||
ma_device_uninit(&device);
|
||||
ma_pcm_rb_uninit(&g_rb);
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
return 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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,261 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; 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="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;"><img src="../../img/logo1_large.png" style="width:auto; height:auto; min-height:70px;"></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/dr-soft/miniaudio">Source Code</a></div></div>
|
||||
<table style="border:none;"><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 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;">
|
||||
<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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,338 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; 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="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>
|
||||
<p>
|
||||
|
||||
This example simply captures data from your default microphone until you press Enter. The output is saved to the file
|
||||
specified on the command line.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
Capturing works in a very similar way to playback. The only difference is the direction of data movement. Instead of
|
||||
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;"><pre style="margin:0.5em 1em; padding:0; line-height:125%">
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
|
||||
{
|
||||
ma_encoder* pEncoder = (ma_encoder*)pDevice->pUserData;
|
||||
MA_ASSERT(pEncoder != NULL);
|
||||
|
||||
ma_encoder_write_pcm_frames(pEncoder, pInput, frameCount);
|
||||
|
||||
(void)pOutput;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ma_result result;
|
||||
ma_encoder_config encoderConfig;
|
||||
ma_encoder encoder;
|
||||
ma_device_config deviceConfig;
|
||||
ma_device device;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("No input file.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
encoderConfig = ma_encoder_config_init(ma_resource_format_wav, ma_format_f32, 2, 44100);
|
||||
|
||||
if (ma_encoder_init_file(argv[1], &encoderConfig, &encoder) != MA_SUCCESS) {
|
||||
printf("Failed to initialize output file.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
deviceConfig = ma_device_config_init(ma_device_type_capture);
|
||||
deviceConfig.capture.format = encoder.config.format;
|
||||
deviceConfig.capture.channels = encoder.config.channels;
|
||||
deviceConfig.sampleRate = encoder.config.sampleRate;
|
||||
deviceConfig.dataCallback = data_callback;
|
||||
deviceConfig.pUserData = &encoder;
|
||||
|
||||
result = ma_device_init(NULL, &deviceConfig, &device);
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize capture device.\n");
|
||||
return -2;
|
||||
}
|
||||
|
||||
result = ma_device_start(&device);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_device_uninit(&device);
|
||||
printf("Failed to start device.\n");
|
||||
return -3;
|
||||
}
|
||||
|
||||
printf("Press Enter to stop recording...\n");
|
||||
getchar();
|
||||
|
||||
ma_device_uninit(&device);
|
||||
ma_encoder_uninit(&encoder);
|
||||
|
||||
return 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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,335 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; 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="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 device.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
This example captures audio from the default microphone and then outputs it straight to the default playback device
|
||||
without any kind of modification. If you wanted to, you could also apply filters and effects to the input stream
|
||||
before outputting to the playback device.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
Note that the microphone and playback device must run in lockstep. Any kind of timing deviation will result in audible
|
||||
glitching which the backend may not be able to recover from. For this reason, miniaudio forces you to use the same
|
||||
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;"><pre style="margin:0.5em 1em; padding:0; line-height:125%">
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
void main_loop__em()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
|
||||
{
|
||||
MA_ASSERT(pDevice->capture.format == pDevice->playback.format);
|
||||
MA_ASSERT(pDevice->capture.channels == pDevice->playback.channels);
|
||||
|
||||
/* In this example the format and channel count are the same for both input and output which means we can just memcpy(). */
|
||||
MA_COPY_MEMORY(pOutput, pInput, frameCount * ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels));
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ma_result result;
|
||||
ma_device_config deviceConfig;
|
||||
ma_device device;
|
||||
|
||||
deviceConfig = ma_device_config_init(ma_device_type_duplex);
|
||||
deviceConfig.capture.pDeviceID = NULL;
|
||||
deviceConfig.capture.format = ma_format_s16;
|
||||
deviceConfig.capture.channels = 2;
|
||||
deviceConfig.capture.shareMode = ma_share_mode_shared;
|
||||
deviceConfig.playback.pDeviceID = NULL;
|
||||
deviceConfig.playback.format = ma_format_s16;
|
||||
deviceConfig.playback.channels = 2;
|
||||
deviceConfig.dataCallback = data_callback;
|
||||
result = ma_device_init(NULL, &deviceConfig, &device);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
getchar();
|
||||
#endif
|
||||
|
||||
ma_device_start(&device);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(main_loop__em, 0, 1);
|
||||
#else
|
||||
printf("Press Enter to quit...\n");
|
||||
getchar();
|
||||
#endif
|
||||
|
||||
ma_device_uninit(&device);
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
return 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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,318 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; 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="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>
|
||||
<p>
|
||||
|
||||
Device enumaration requires a <span style="font-family:monospace;">ma_context</span> object which is initialized with <span style="font-family:monospace;">ma_context_init()</span>. Conceptually, the
|
||||
context sits above a device. You can have many devices to one context.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
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;"><pre style="margin:0.5em 1em; padding:0; line-height:125%">
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ma_result result;
|
||||
ma_context context;
|
||||
ma_device_info* pPlaybackDeviceInfos;
|
||||
ma_uint32 playbackDeviceCount;
|
||||
ma_device_info* pCaptureDeviceInfos;
|
||||
ma_uint32 captureDeviceCount;
|
||||
ma_uint32 iDevice;
|
||||
|
||||
if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) {
|
||||
printf("Failed to initialize context.\n");
|
||||
return -2;
|
||||
}
|
||||
|
||||
result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount);
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to retrieve device information.\n");
|
||||
return -3;
|
||||
}
|
||||
|
||||
printf("Playback Devices\n");
|
||||
for (iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) {
|
||||
printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
printf("Capture Devices\n");
|
||||
for (iDevice = 0; iDevice < captureDeviceCount; ++iDevice) {
|
||||
printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name);
|
||||
}
|
||||
|
||||
|
||||
ma_context_uninit(&context);
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
return 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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,348 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; 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="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>
|
||||
<p>
|
||||
|
||||
This example simply captures data from your default playback device until you press Enter. The output is saved to the
|
||||
file specified on the command line.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
Loopback mode is when you record audio that is played from a given speaker. It is only supported on WASAPI, but can be
|
||||
used indirectly with PulseAudio by choosing the appropriate loopback device after enumeration.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
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;"><pre style="margin:0.5em 1em; padding:0; line-height:125%">
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
|
||||
{
|
||||
ma_encoder* pEncoder = (ma_encoder*)pDevice->pUserData;
|
||||
MA_ASSERT(pEncoder != NULL);
|
||||
|
||||
ma_encoder_write_pcm_frames(pEncoder, pInput, frameCount);
|
||||
|
||||
(void)pOutput;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ma_result result;
|
||||
ma_encoder_config encoderConfig;
|
||||
ma_encoder encoder;
|
||||
ma_device_config deviceConfig;
|
||||
ma_device device;
|
||||
|
||||
/* Loopback mode is currently only supported on WASAPI. */
|
||||
ma_backend backends[] = {
|
||||
ma_backend_wasapi
|
||||
};
|
||||
|
||||
if (argc < 2) {
|
||||
printf("No input file.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
encoderConfig = ma_encoder_config_init(ma_resource_format_wav, ma_format_f32, 2, 44100);
|
||||
|
||||
if (ma_encoder_init_file(argv[1], &encoderConfig, &encoder) != MA_SUCCESS) {
|
||||
printf("Failed to initialize output file.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
deviceConfig = ma_device_config_init(ma_device_type_loopback);
|
||||
deviceConfig.capture.pDeviceID = NULL; /* Use default device for this example. Set this to the ID of a _playback_ device if you want to capture from a specific device. */
|
||||
deviceConfig.capture.format = encoder.config.format;
|
||||
deviceConfig.capture.channels = encoder.config.channels;
|
||||
deviceConfig.sampleRate = encoder.config.sampleRate;
|
||||
deviceConfig.dataCallback = data_callback;
|
||||
deviceConfig.pUserData = &encoder;
|
||||
|
||||
result = ma_device_init_ex(backends, sizeof(backends)/sizeof(backends[0]), NULL, &deviceConfig, &device);
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize loopback device.\n");
|
||||
return -2;
|
||||
}
|
||||
|
||||
result = ma_device_start(&device);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_device_uninit(&device);
|
||||
printf("Failed to start device.\n");
|
||||
return -3;
|
||||
}
|
||||
|
||||
printf("Press Enter to stop recording...\n");
|
||||
getchar();
|
||||
|
||||
ma_device_uninit(&device);
|
||||
ma_encoder_uninit(&encoder);
|
||||
|
||||
return 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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,337 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; 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="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>
|
||||
<p>
|
||||
|
||||
This example uses a decoder as the data source. Decoders can be used with the <span style="font-family:monospace;">ma_data_source</span> API which, conveniently,
|
||||
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;"><pre style="margin:0.5em 1em; padding:0; line-height:125%">
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
|
||||
{
|
||||
ma_bool32 isLooping = MA_TRUE;
|
||||
|
||||
ma_decoder* pDecoder = (ma_decoder*)pDevice->pUserData;
|
||||
if (pDecoder == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
A decoder is a data source which means you can seemlessly plug it into the ma_data_source API. We can therefore take advantage
|
||||
of the "loop" parameter of ma_data_source_read_pcm_frames() to handle looping for us.
|
||||
*/
|
||||
ma_data_source_read_pcm_frames(pDecoder, pOutput, frameCount, NULL, isLooping);
|
||||
|
||||
(void)pInput;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ma_result result;
|
||||
ma_decoder decoder;
|
||||
ma_device_config deviceConfig;
|
||||
ma_device device;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("No input file.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = ma_decoder_init_file(argv[1], NULL, &decoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
deviceConfig = ma_device_config_init(ma_device_type_playback);
|
||||
deviceConfig.playback.format = decoder.outputFormat;
|
||||
deviceConfig.playback.channels = decoder.outputChannels;
|
||||
deviceConfig.sampleRate = decoder.outputSampleRate;
|
||||
deviceConfig.dataCallback = data_callback;
|
||||
deviceConfig.pUserData = &decoder;
|
||||
|
||||
if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) {
|
||||
printf("Failed to open playback device.\n");
|
||||
ma_decoder_uninit(&decoder);
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (ma_device_start(&device) != MA_SUCCESS) {
|
||||
printf("Failed to start playback device.\n");
|
||||
ma_device_uninit(&device);
|
||||
ma_decoder_uninit(&decoder);
|
||||
return -4;
|
||||
}
|
||||
|
||||
printf("Press Enter to quit...");
|
||||
getchar();
|
||||
|
||||
ma_device_uninit(&device);
|
||||
ma_decoder_uninit(&decoder);
|
||||
|
||||
return 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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,462 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; 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="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>
|
||||
<p>
|
||||
|
||||
When mixing multiple sounds together, you should not create multiple devices. Instead you should create only a single
|
||||
device and then mix your sounds together which you can do by simply summing their samples together. The simplest way to
|
||||
do this is to use floating point samples and use miniaudio's built-in clipper to handling clipping for you. (Clipping
|
||||
is when sample are clampled to their minimum and maximum range, which for floating point is -1..1.)
|
||||
</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
<div style="font-family:monospace; margin:1em 0em;"><pre style="margin:0.5em 1em; padding:0; line-height:125%">
|
||||
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;"><pre style="margin:0.5em 1em; padding:0; line-height:125%">
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
For simplicity, this example requires the device to use floating point samples.
|
||||
*/
|
||||
#define SAMPLE_FORMAT ma_format_f32
|
||||
#define CHANNEL_COUNT 2
|
||||
#define SAMPLE_RATE 48000
|
||||
|
||||
ma_uint32 g_decoderCount;
|
||||
ma_decoder* g_pDecoders;
|
||||
ma_bool32* g_pDecodersAtEnd;
|
||||
|
||||
ma_event g_stopEvent; /* <-- Signaled by the audio thread, waited on by the main thread. */
|
||||
|
||||
ma_bool32 are_all_decoders_at_end()
|
||||
{
|
||||
ma_uint32 iDecoder;
|
||||
for (iDecoder = 0; iDecoder < g_decoderCount; ++iDecoder) {
|
||||
if (g_pDecodersAtEnd[iDecoder] == MA_FALSE) {
|
||||
return MA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return MA_TRUE;
|
||||
}
|
||||
|
||||
ma_uint32 read_and_mix_pcm_frames_f32(ma_decoder* pDecoder, float* pOutputF32, ma_uint32 frameCount)
|
||||
{
|
||||
/*
|
||||
The way mixing works is that we just read into a temporary buffer, then take the contents of that buffer and mix it with the
|
||||
contents of the output buffer by simply adding the samples together. You could also clip the samples to -1..+1, but I'm not
|
||||
doing that in this example.
|
||||
*/
|
||||
float temp[4096];
|
||||
ma_uint32 tempCapInFrames = ma_countof(temp) / CHANNEL_COUNT;
|
||||
ma_uint32 totalFramesRead = 0;
|
||||
|
||||
while (totalFramesRead < frameCount) {
|
||||
ma_uint32 iSample;
|
||||
ma_uint32 framesReadThisIteration;
|
||||
ma_uint32 totalFramesRemaining = frameCount - totalFramesRead;
|
||||
ma_uint32 framesToReadThisIteration = tempCapInFrames;
|
||||
if (framesToReadThisIteration > totalFramesRemaining) {
|
||||
framesToReadThisIteration = totalFramesRemaining;
|
||||
}
|
||||
|
||||
framesReadThisIteration = (ma_uint32)ma_decoder_read_pcm_frames(pDecoder, temp, framesToReadThisIteration);
|
||||
if (framesReadThisIteration == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Mix the frames together. */
|
||||
for (iSample = 0; iSample < framesReadThisIteration*CHANNEL_COUNT; ++iSample) {
|
||||
pOutputF32[totalFramesRead*CHANNEL_COUNT + iSample] += temp[iSample];
|
||||
}
|
||||
|
||||
totalFramesRead += framesReadThisIteration;
|
||||
|
||||
if (framesReadThisIteration < framesToReadThisIteration) {
|
||||
break; /* Reached EOF. */
|
||||
}
|
||||
}
|
||||
|
||||
return totalFramesRead;
|
||||
}
|
||||
|
||||
void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
|
||||
{
|
||||
float* pOutputF32 = (float*)pOutput;
|
||||
ma_uint32 iDecoder;
|
||||
|
||||
MA_ASSERT(pDevice->playback.format == SAMPLE_FORMAT); /* <-- Important for this example. */
|
||||
|
||||
for (iDecoder = 0; iDecoder < g_decoderCount; ++iDecoder) {
|
||||
if (!g_pDecodersAtEnd[iDecoder]) {
|
||||
ma_uint32 framesRead = read_and_mix_pcm_frames_f32(&g_pDecoders[iDecoder], pOutputF32, frameCount);
|
||||
if (framesRead < frameCount) {
|
||||
g_pDecodersAtEnd[iDecoder] = MA_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
If at the end all of our decoders are at the end we need to stop. We cannot stop the device in the callback. Instead we need to
|
||||
signal an event to indicate that it's stopped. The main thread will be waiting on the event, after which it will stop the device.
|
||||
*/
|
||||
if (are_all_decoders_at_end()) {
|
||||
ma_event_signal(&g_stopEvent);
|
||||
}
|
||||
|
||||
(void)pInput;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ma_result result;
|
||||
ma_decoder_config decoderConfig;
|
||||
ma_device_config deviceConfig;
|
||||
ma_device device;
|
||||
ma_uint32 iDecoder;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("No input files.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_decoderCount = argc-1;
|
||||
g_pDecoders = (ma_decoder*)malloc(sizeof(*g_pDecoders) * g_decoderCount);
|
||||
g_pDecodersAtEnd = (ma_bool32*) malloc(sizeof(*g_pDecodersAtEnd) * g_decoderCount);
|
||||
|
||||
/* In this example, all decoders need to have the same output format. */
|
||||
decoderConfig = ma_decoder_config_init(SAMPLE_FORMAT, CHANNEL_COUNT, SAMPLE_RATE);
|
||||
for (iDecoder = 0; iDecoder < g_decoderCount; ++iDecoder) {
|
||||
result = ma_decoder_init_file(argv[1+iDecoder], &decoderConfig, &g_pDecoders[iDecoder]);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_uint32 iDecoder2;
|
||||
for (iDecoder2 = 0; iDecoder2 < iDecoder; ++iDecoder2) {
|
||||
ma_decoder_uninit(&g_pDecoders[iDecoder2]);
|
||||
}
|
||||
free(g_pDecoders);
|
||||
free(g_pDecodersAtEnd);
|
||||
|
||||
printf("Failed to load %s.\n", argv[1+iDecoder]);
|
||||
return -3;
|
||||
}
|
||||
g_pDecodersAtEnd[iDecoder] = MA_FALSE;
|
||||
}
|
||||
|
||||
/* Create only a single device. The decoders will be mixed together in the callback. In this example the data format needs to be the same as the decoders. */
|
||||
deviceConfig = ma_device_config_init(ma_device_type_playback);
|
||||
deviceConfig.playback.format = SAMPLE_FORMAT;
|
||||
deviceConfig.playback.channels = CHANNEL_COUNT;
|
||||
deviceConfig.sampleRate = SAMPLE_RATE;
|
||||
deviceConfig.dataCallback = data_callback;
|
||||
deviceConfig.pUserData = NULL;
|
||||
|
||||
if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) {
|
||||
for (iDecoder = 0; iDecoder < g_decoderCount; ++iDecoder) {
|
||||
ma_decoder_uninit(&g_pDecoders[iDecoder]);
|
||||
}
|
||||
free(g_pDecoders);
|
||||
free(g_pDecodersAtEnd);
|
||||
|
||||
printf("Failed to open playback device.\n");
|
||||
return -3;
|
||||
}
|
||||
|
||||
/*
|
||||
We can't stop in the audio thread so we instead need to use an event. We wait on this thread in the main thread, and signal it in the audio thread. This
|
||||
needs to be done before starting the device. We need a context to initialize the event, which we can get from the device. Alternatively you can initialize
|
||||
a context separately, but we don't need to do that for this example.
|
||||
*/
|
||||
ma_event_init(&g_stopEvent);
|
||||
|
||||
/* Now we start playback and wait for the audio thread to tell us to stop. */
|
||||
if (ma_device_start(&device) != MA_SUCCESS) {
|
||||
ma_device_uninit(&device);
|
||||
for (iDecoder = 0; iDecoder < g_decoderCount; ++iDecoder) {
|
||||
ma_decoder_uninit(&g_pDecoders[iDecoder]);
|
||||
}
|
||||
free(g_pDecoders);
|
||||
free(g_pDecodersAtEnd);
|
||||
|
||||
printf("Failed to start playback device.\n");
|
||||
return -4;
|
||||
}
|
||||
|
||||
printf("Waiting for playback to complete...\n");
|
||||
ma_event_wait(&g_stopEvent);
|
||||
|
||||
/* Getting here means the audio thread has signaled that the device should be stopped. */
|
||||
ma_device_uninit(&device);
|
||||
|
||||
for (iDecoder = 0; iDecoder < g_decoderCount; ++iDecoder) {
|
||||
ma_decoder_uninit(&g_pDecoders[iDecoder]);
|
||||
}
|
||||
free(g_pDecoders);
|
||||
free(g_pDecodersAtEnd);
|
||||
|
||||
return 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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,338 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; 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="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>
|
||||
<p>
|
||||
|
||||
The low-level API uses a callback to deliver audio between the application and miniaudio for playback or recording. When
|
||||
in playback mode, as in this example, the application sends raw audio data to miniaudio which is then played back through
|
||||
the default playback device as defined by the operating system.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
This example uses the <span style="font-family:monospace;">ma_decoder</span> API to load a sound and play it back. The decoder is entirely decoupled from the
|
||||
device and can be used independently of it. This example only plays back a single sound file, but it's possible to play
|
||||
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;"><pre style="margin:0.5em 1em; padding:0; line-height:125%">
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
|
||||
{
|
||||
ma_decoder* pDecoder = (ma_decoder*)pDevice->pUserData;
|
||||
if (pDecoder == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
ma_decoder_read_pcm_frames(pDecoder, pOutput, frameCount);
|
||||
|
||||
(void)pInput;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ma_result result;
|
||||
ma_decoder decoder;
|
||||
ma_device_config deviceConfig;
|
||||
ma_device device;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("No input file.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = ma_decoder_init_file(argv[1], NULL, &decoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
deviceConfig = ma_device_config_init(ma_device_type_playback);
|
||||
deviceConfig.playback.format = decoder.outputFormat;
|
||||
deviceConfig.playback.channels = decoder.outputChannels;
|
||||
deviceConfig.sampleRate = decoder.outputSampleRate;
|
||||
deviceConfig.dataCallback = data_callback;
|
||||
deviceConfig.pUserData = &decoder;
|
||||
|
||||
if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) {
|
||||
printf("Failed to open playback device.\n");
|
||||
ma_decoder_uninit(&decoder);
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (ma_device_start(&device) != MA_SUCCESS) {
|
||||
printf("Failed to start playback device.\n");
|
||||
ma_device_uninit(&device);
|
||||
ma_decoder_uninit(&decoder);
|
||||
return -4;
|
||||
}
|
||||
|
||||
printf("Press Enter to quit...");
|
||||
getchar();
|
||||
|
||||
ma_device_uninit(&device);
|
||||
ma_decoder_uninit(&decoder);
|
||||
|
||||
return 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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,358 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../../index.html"><img src="../../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; 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="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>
|
||||
<p>
|
||||
|
||||
Since all this example is doing is playing back a sine wave, we can disable decoding (and encoding) which will slightly
|
||||
reduce the size of the executable. This is done with the <span style="font-family:monospace;">MA_NO_DECODING</span> and <span style="font-family:monospace;">MA_NO_ENCODING</span> options.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
The generation of sine wave is achieved via the <span style="font-family:monospace;">ma_waveform</span> API. A waveform is a data source which means it can be
|
||||
seamlessly plugged into the <span style="font-family:monospace;">ma_data_source_*()</span> family of APIs as well.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
A waveform is initialized using the standard config/init pattern used throughout all of miniaudio. Frames are read via
|
||||
the <span style="font-family:monospace;">ma_waveform_read_pcm_frames()</span> API.
|
||||
</p>
|
||||
<p>
|
||||
|
||||
This example works with Emscripten.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em;"><pre style="margin:0.5em 1em; padding:0; line-height:125%">
|
||||
#define MA_NO_DECODING
|
||||
#define MA_NO_ENCODING
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
|
||||
void main_loop__em()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#define DEVICE_FORMAT ma_format_f32
|
||||
#define DEVICE_CHANNELS 2
|
||||
#define DEVICE_SAMPLE_RATE 48000
|
||||
|
||||
void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
|
||||
{
|
||||
ma_waveform* pSineWave;
|
||||
|
||||
MA_ASSERT(pDevice->playback.channels == DEVICE_CHANNELS);
|
||||
|
||||
pSineWave = (ma_waveform*)pDevice->pUserData;
|
||||
MA_ASSERT(pSineWave != NULL);
|
||||
|
||||
ma_waveform_read_pcm_frames(pSineWave, pOutput, frameCount);
|
||||
|
||||
(void)pInput; /* Unused. */
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ma_waveform sineWave;
|
||||
ma_device_config deviceConfig;
|
||||
ma_device device;
|
||||
ma_waveform_config sineWaveConfig;
|
||||
|
||||
sineWaveConfig = ma_waveform_config_init(DEVICE_FORMAT, DEVICE_CHANNELS, DEVICE_SAMPLE_RATE, ma_waveform_type_sine, 0.2, 220);
|
||||
ma_waveform_init(&sineWaveConfig, &sineWave);
|
||||
|
||||
deviceConfig = ma_device_config_init(ma_device_type_playback);
|
||||
deviceConfig.playback.format = DEVICE_FORMAT;
|
||||
deviceConfig.playback.channels = DEVICE_CHANNELS;
|
||||
deviceConfig.sampleRate = DEVICE_SAMPLE_RATE;
|
||||
deviceConfig.dataCallback = data_callback;
|
||||
deviceConfig.pUserData = &sineWave;
|
||||
|
||||
if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) {
|
||||
printf("Failed to open playback device.\n");
|
||||
return -4;
|
||||
}
|
||||
|
||||
printf("Device Name: %s\n", device.playback.name);
|
||||
|
||||
if (ma_device_start(&device) != MA_SUCCESS) {
|
||||
printf("Failed to start playback device.\n");
|
||||
ma_device_uninit(&device);
|
||||
return -5;
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(main_loop__em, 0, 1);
|
||||
#else
|
||||
printf("Press Enter to quit...\n");
|
||||
getchar();
|
||||
#endif
|
||||
|
||||
ma_device_uninit(&device);
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
return 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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
<!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:0.5em 0;
|
||||
padding-right:2em;
|
||||
vertical-align:center;
|
||||
}
|
||||
.header-link-table a {
|
||||
color:#e0d7cf;
|
||||
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:75%; width:100%; margin:0 auto;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="padding:0; width:100%; text-align:left;">
|
||||
<table class="header-link-table" style="">
|
||||
<tr>
|
||||
<td style="vertical-align:center; padding-right:2em;"><a href="../index.html"><img src="../img/logo1_large_white.png" style="height:24px; min-width:100%;"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; 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="padding:0; width:25%; text-align:right; vertical-align:center;">
|
||||
<a style="padding:0;" href="https://github.com/dr-soft/miniaudio"><img src="../img/github_white.png" style="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;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:300px; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="index.html" class="doc-navigation doc-navigation-active">Documentation Home</a><a href="manual/index.html" class="doc-navigation">Programming Manual</a><a href="examples/index.html" class="doc-navigation">Examples</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;"><div style="text-align:center;"><img src="../img/logo1_large.png" style="width:auto; height:auto; min-height:70px;"></div><div style="padding-top:1em; font-weight:bold; font-size:2em; color:#444;">Documentation</div><div style="padding-top:0.75em; text-align:center;"><a href="manual/index.html">Programming Manual</a> - <a href="examples/index.html">Examples</a> - <a href="api/index.html">API Reference</a> - <a href="https://github.com/dr-soft/miniaudio">Source Code</a></div></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/dr-soft/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 © 2020 David Reid<br/>
|
||||
Developed by David Reid - <a class="footer-link" href="mailto:davidreidsoftware@gmail.com">davidreidsoftware@gmail.com</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
+88
-2
@@ -16,13 +16,26 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
body{
|
||||
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;
|
||||
@@ -124,6 +137,78 @@ a:hover {
|
||||
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>
|
||||
|
||||
@@ -152,6 +237,7 @@ a:hover {
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<!-- Mobile redirection -->
|
||||
<script>
|
||||
//(function(a,b){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))window.location=b})(navigator.userAgent||navigator.vendor||window.opera,'mobile/index.html');
|
||||
@@ -300,7 +386,7 @@ a:hover {
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</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>
|
||||
|
||||
Reference in New Issue
Block a user