OLD | NEW |
1 .. _devguide-coding-audio: | 1 .. _devguide-coding-audio: |
2 | 2 |
3 ##### | 3 ##### |
4 Audio | 4 Audio |
5 ##### | 5 ##### |
6 | 6 |
7 .. contents:: | 7 .. contents:: |
8 :local: | 8 :local: |
9 :backlinks: none | 9 :backlinks: none |
10 :depth: 2 | 10 :depth: 2 |
11 | 11 |
12 This chapter describes how to use the Pepper audio API to play an audio | 12 This section describes how to use the Pepper audio API to play an audio |
13 stream. The Pepper audio API provides a low-level means of playing a stream of | 13 stream. The Pepper audio API provides a low-level means of playing a stream of |
14 audio samples generated by a Native Client module. The API generally works as | 14 audio samples generated by a Native Client module. The API generally works as |
15 follows: A Native Client module creates an audio resource that represents an | 15 follows: A Native Client module creates an audio resource that represents an |
16 audio stream, and tells the browser to start or stop playing the audio | 16 audio stream, and tells the browser to start or stop playing the audio |
17 resource. The browser calls a function in the Native Client module to fill a | 17 resource. The browser calls a function in the Native Client module to fill a |
18 buffer with audio samples every time it needs data to play from the audio | 18 buffer with audio samples every time it needs data to play from the audio |
19 stream. | 19 stream. |
20 | 20 |
21 The code examples in this chapter describe a simple Native Client module that | 21 The code examples in this section describe a simple Native Client module that |
22 generates audio samples using a sine wave with a frequency of 440 Hz. The module | 22 generates audio samples using a sine wave with a frequency of 440 Hz. The module |
23 starts playing the audio samples as soon as it is loaded into the browser. For a | 23 starts playing the audio samples as soon as it is loaded into the browser. For a |
24 slightly more sophisticated example, see the ``audio`` example (source code in | 24 slightly more sophisticated example, see the ``audio`` example (source code in |
25 the SDK directory ``examples/api/audio``), which lets users specify a frequency | 25 the SDK directory ``examples/api/audio``), which lets users specify a frequency |
26 for the sine wave and click buttons to start and stop audio playback. | 26 for the sine wave and click buttons to start and stop audio playback. |
27 | 27 |
28 Reference information | 28 Reference information |
29 ===================== | 29 ===================== |
30 | 30 |
31 For reference information related to the Pepper audio API, see the following | 31 For reference information related to the Pepper audio API, see the following |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 } | 377 } |
378 std::string message = var_message.AsString(); | 378 std::string message = var_message.AsString(); |
379 if (message == kPlaySoundId) { | 379 if (message == kPlaySoundId) { |
380 audio_.StartPlayback(); | 380 audio_.StartPlayback(); |
381 } else if (message == kStopSoundId) { | 381 } else if (message == kStopSoundId) { |
382 audio_.StopPlayback(); | 382 audio_.StopPlayback(); |
383 } else if (...) { | 383 } else if (...) { |
384 ... | 384 ... |
385 } | 385 } |
386 } | 386 } |
OLD | NEW |