62 lines
8.5 KiB
HTML
62 lines
8.5 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Game Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheGameKit_Overview.html" title="The Game Kit" /><link rel="prev" href="BGameSound_Overview.html" title="BGameSound" /><link rel="next" href="BSimpleGameSound_Overview.html" title="BSimpleGameSound" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BGameSound_Overview.html" title="BGameSound"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheGameKit_Overview.html" title="The Game Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BSimpleGameSound_Overview.html" title="BSimpleGameSound"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Game Kit</div></div><div id="headerB">Prev: <a href="BGameSound_Overview.html">BGameSound</a> Up: <a href="TheGameKit_Overview.html">The Game Kit</a> Next: <a href="BSimpleGameSound_Overview.html">BSimpleGameSound</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_Overview"></a>BPushGameSound</h2></div></div></div><a id="id529947" class="indexterm"></a><p>
|
||
The <a class="link" href="BPushGameSound.html" title="BPushGameSound"><code class="classname">BPushGameSound</code></a>
|
||
class lets you push buffers of audio data, instead of
|
||
waiting to be asked for them.
|
||
</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_Overview_How_It_Works"></a>How It Works</h3></div></div></div><p>
|
||
The <a class="link" href="BPushGameSound.html" title="BPushGameSound"><code class="classname">BPushGameSound</code></a>
|
||
class uses a single sound buffer, consisting of
|
||
multiple pages, which play continuously in a loop. Each page is used to
|
||
construct an audio
|
||
<a class="link" href="BBuffer.html" title="BBuffer"><code class="classname">BBuffer</code></a>
|
||
that eventually gets played, and is then recycled and reused again later.
|
||
</p><p>
|
||
For example, if the sound buffer is 256 kilobytes, and each page is 4
|
||
kilobytes, there are 64 pages of audio. When you start the
|
||
<a class="link" href="BPushGameSound.html" title="BPushGameSound"><code class="classname">BPushGameSound</code></a>
|
||
object, playback begins with the first page. A
|
||
<a class="link" href="BBuffer.html" title="BBuffer"><code class="classname">BBuffer</code></a> is constructed
|
||
using that page, then played, and then the buffer is recycled, and the
|
||
next page is used to create another
|
||
<a class="link" href="BBuffer.html" title="BBuffer"><code class="classname">BBuffer</code></a>, and so forth. This continues
|
||
to the 64th page. Once that page is played, playback loops back to the
|
||
first page again.
|
||
</p><p>
|
||
Your code pushes audio data into these audio pages. There are two ways
|
||
you can do this.
|
||
</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_Overview_Exclusive_Access"></a>Exclusive Access</h4></div></div></div><p>
|
||
The first way is to ask the
|
||
<a class="link" href="BPushGameSound.html" title="BPushGameSound"><code class="classname">BPushGameSound</code></a> class to give you a page to
|
||
fill with audio data. This is done by calling
|
||
<a class="link" href="BPushGameSound.html#BPushGameSound_LockNextPage" title="LockNextPage(), UnlockPage()"><code class="methodname">LockNextPage()</code></a>. This gives
|
||
you exclusive access to the next audio page that needs to be filled; you
|
||
can fill it with whatever sound you want to push, then call
|
||
<a class="link" href="BPushGameSound.html#BPushGameSound_UnlockPage"><code class="methodname">UnlockPage()</code></a>
|
||
to release it. It won't be played while it's locked, so you need to stuff
|
||
your sound into it and release it as quickly as possible.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BPushGameSound_Overview_The_Neverending_Story"></a>The Neverending Story</h4></div></div></div><p>
|
||
The second way takes better planning, but can give you lower overhead.
|
||
Call
|
||
<a class="link" href="BPushGameSound.html#BPushGameSound_LockForCyclic" title="LockForCyclic(), UnlockCyclic(), CurrentPosition()"><code class="methodname">LockForCyclic()</code></a>
|
||
to request access to the entire sound buffer area.
|
||
This doesn't give you exclusive access, so playback never stops—it
|
||
keeps looping the entire time, while you write into it. The
|
||
<a class="link" href="BPushGameSound.html#BPushGameSound_CurrentPosition"><code class="methodname">CurrentPosition()</code></a>
|
||
function tells you where in the buffer area playback is
|
||
currently occurring.
|
||
</p><p>
|
||
Your mission (should you choose to accept it) is to stuff audio into the
|
||
buffer, keeping ahead of this position far enough that playback never
|
||
catches up to you. As a general rule, you should try to stay at least a
|
||
page ahead of the current playback position. Keep in mind that when you
|
||
reach the end of the buffer area, you need to wrap back to the beginning.
|
||
</p><p>
|
||
This takes more careful effort on your part, but once you have your code
|
||
properly tuned, you can get very low overhead audio playback this way.
|
||
</p></div></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BGameSound_Overview.html">BGameSound</a> Up: <a href="TheGameKit_Overview.html">The Game Kit</a> Next: <a href="BSimpleGameSound_Overview.html">BSimpleGameSound</a> </div><div id="footerB"><div id="footerBL"><a href="BGameSound_Overview.html" title="BGameSound"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheGameKit_Overview.html" title="The Game Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BSimpleGameSound_Overview.html" title="BSimpleGameSound"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|