OLD | NEW |
1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
2 | 2 |
3 <section id="audio"> | 3 <section id="audio"> |
4 <span id="devguide-coding-audio"></span><h1 id="audio"><span id="devguide-coding
-audio"></span>Audio</h1> | 4 <span id="devguide-coding-audio"></span><h1 id="audio"><span id="devguide-coding
-audio"></span>Audio</h1> |
5 <div class="contents local" id="contents" style="display: none"> | 5 <div class="contents local" id="contents" style="display: none"> |
6 <ul class="small-gap"> | 6 <ul class="small-gap"> |
7 <li><a class="reference internal" href="#reference-information" id="id1">Referen
ce information</a></li> | 7 <li><a class="reference internal" href="#reference-information" id="id1">Referen
ce information</a></li> |
8 <li><a class="reference internal" href="#about-the-pepper-audio-api" id="id2">Ab
out the Pepper audio API</a></li> | 8 <li><a class="reference internal" href="#about-the-pepper-audio-api" id="id2">Ab
out the Pepper audio API</a></li> |
9 <li><a class="reference internal" href="#digital-audio-concepts" id="id3">Digita
l audio concepts</a></li> | 9 <li><a class="reference internal" href="#digital-audio-concepts" id="id3">Digita
l audio concepts</a></li> |
10 <li><a class="reference internal" href="#setting-up-the-module" id="id4">Setting
up the module</a></li> | 10 <li><a class="reference internal" href="#setting-up-the-module" id="id4">Setting
up the module</a></li> |
11 <li><p class="first"><a class="reference internal" href="#creating-an-audio-conf
iguration-resource" id="id5">Creating an audio configuration resource</a></p> | 11 <li><p class="first"><a class="reference internal" href="#creating-an-audio-conf
iguration-resource" id="id5">Creating an audio configuration resource</a></p> |
12 <ul class="small-gap"> | 12 <ul class="small-gap"> |
13 <li><a class="reference internal" href="#resources" id="id6">Resources</a></li> | 13 <li><a class="reference internal" href="#resources" id="id6">Resources</a></li> |
14 <li><a class="reference internal" href="#sample-frame-count" id="id7">Sample fra
me count</a></li> | 14 <li><a class="reference internal" href="#sample-frame-count" id="id7">Sample fra
me count</a></li> |
15 <li><a class="reference internal" href="#supported-audio-configurations" id="id8
">Supported audio configurations</a></li> | 15 <li><a class="reference internal" href="#supported-audio-configurations" id="id8
">Supported audio configurations</a></li> |
16 </ul> | 16 </ul> |
17 </li> | 17 </li> |
18 <li><a class="reference internal" href="#creating-an-audio-resource" id="id9">Cr
eating an audio resource</a></li> | 18 <li><a class="reference internal" href="#creating-an-audio-resource" id="id9">Cr
eating an audio resource</a></li> |
19 <li><p class="first"><a class="reference internal" href="#implementing-a-callbac
k-function" id="id10">Implementing a callback function</a></p> | 19 <li><p class="first"><a class="reference internal" href="#implementing-a-callbac
k-function" id="id10">Implementing a callback function</a></p> |
20 <ul class="small-gap"> | 20 <ul class="small-gap"> |
21 <li><a class="reference internal" href="#application-threads-and-real-time-requi
rements" id="id11">Application threads and real-time requirements</a></li> | 21 <li><a class="reference internal" href="#application-threads-and-real-time-requi
rements" id="id11">Application threads and real-time requirements</a></li> |
22 </ul> | 22 </ul> |
23 </li> | 23 </li> |
24 <li><a class="reference internal" href="#starting-and-stopping-playback" id="id1
2">Starting and stopping playback</a></li> | 24 <li><a class="reference internal" href="#starting-and-stopping-playback" id="id1
2">Starting and stopping playback</a></li> |
25 </ul> | 25 </ul> |
26 | 26 |
27 </div><p>This chapter describes how to use the Pepper audio API to play an audio | 27 </div><p>This section describes how to use the Pepper audio API to play an audio |
28 stream. The Pepper audio API provides a low-level means of playing a stream of | 28 stream. The Pepper audio API provides a low-level means of playing a stream of |
29 audio samples generated by a Native Client module. The API generally works as | 29 audio samples generated by a Native Client module. The API generally works as |
30 follows: A Native Client module creates an audio resource that represents an | 30 follows: A Native Client module creates an audio resource that represents an |
31 audio stream, and tells the browser to start or stop playing the audio | 31 audio stream, and tells the browser to start or stop playing the audio |
32 resource. The browser calls a function in the Native Client module to fill a | 32 resource. The browser calls a function in the Native Client module to fill a |
33 buffer with audio samples every time it needs data to play from the audio | 33 buffer with audio samples every time it needs data to play from the audio |
34 stream.</p> | 34 stream.</p> |
35 <p>The code examples in this chapter describe a simple Native Client module that | 35 <p>The code examples in this section describe a simple Native Client module that |
36 generates audio samples using a sine wave with a frequency of 440 Hz. The module | 36 generates audio samples using a sine wave with a frequency of 440 Hz. The module |
37 starts playing the audio samples as soon as it is loaded into the browser. For a | 37 starts playing the audio samples as soon as it is loaded into the browser. For a |
38 slightly more sophisticated example, see the <code>audio</code> example (source
code in | 38 slightly more sophisticated example, see the <code>audio</code> example (source
code in |
39 the SDK directory <code>examples/api/audio</code>), which lets users specify a f
requency | 39 the SDK directory <code>examples/api/audio</code>), which lets users specify a f
requency |
40 for the sine wave and click buttons to start and stop audio playback.</p> | 40 for the sine wave and click buttons to start and stop audio playback.</p> |
41 <h2 id="reference-information">Reference information</h2> | 41 <h2 id="reference-information">Reference information</h2> |
42 <p>For reference information related to the Pepper audio API, see the following | 42 <p>For reference information related to the Pepper audio API, see the following |
43 documentation:</p> | 43 documentation:</p> |
44 <ul class="small-gap"> | 44 <ul class="small-gap"> |
45 <li><a class="reference external" href="/native-client/pepper_stable/cpp/classpp
_1_1_audio_config">pp::AudioConfig class</a></li> | 45 <li><a class="reference external" href="/native-client/pepper_stable/cpp/classpp
_1_1_audio_config">pp::AudioConfig class</a></li> |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } else if (message == kStopSoundId) { | 331 } else if (message == kStopSoundId) { |
332 audio_.StopPlayback(); | 332 audio_.StopPlayback(); |
333 } else if (...) { | 333 } else if (...) { |
334 ... | 334 ... |
335 } | 335 } |
336 } | 336 } |
337 </pre> | 337 </pre> |
338 </section> | 338 </section> |
339 | 339 |
340 {{/partials.standard_nacl_article}} | 340 {{/partials.standard_nacl_article}} |
OLD | NEW |