<script type="text/javascript" src="../../scripts/core.js" charset="utf-8"></script>
<script type="text/javascript" src="../../scripts/search.js" charset="utf-8"></script>
<title>Audio I/O</title>
- </head>
- <body onload="prettyPrint()" style="overflow: auto;">
+</head>
+<body onload="prettyPrint()" style="overflow: auto;">
- <div id="toc-navigation">
+<div id="toc-navigation">
<div id="profile">
<p><img alt="Mobile native" src="../../images/mn_icon.png"/> <img alt="Wearable native" src="../../images/wn_icon.png"/></p>
</div>
<div id="toc_border"><div id="toc">
- <p class="toc-title">Content</p>
- <ul class="toc">
- <li><a href="#record_pcm">Recording Uncompressed Audio</a></li>
- <li><a href="#play_pcm">Playing Uncompressed Audio</a></li>
+ <p class="toc-title">Content</p>
+ <ul class="toc">
+ <li><a href="#record_pcm">Recording Uncompressed Audio</a></li>
+ <li><a href="#play_pcm">Playing Uncompressed Audio</a></li>
</ul>
<p class="toc-title">Related Info</p>
<ul class="toc">
<li><a href="../../../../org.tizen.tutorials/html/native/multimedia/audio_io_tutorial_n.htm">Audio I/O Tutorial</a></li>
- <li><a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__MEDIA__AUDIO__IO__MODULE.html">Audio I/O API for Mobile Native</a></li>
- <li><a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__MEDIA__AUDIO__IO__MODULE.html">Audio I/O API for Wearable Native</a></li>
+ <li><a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__MEDIA__AUDIO__IO__MODULE.html">Audio I/O API for Mobile Native</a></li>
+ <li><a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__MEDIA__AUDIO__IO__MODULE.html">Audio I/O API for Wearable Native</a></li>
</ul>
</div></div>
</div>
<div id="container"><div id="contents"><div class="content">
<h1>Audio I/O</h1>
- <p>Audio I/O enables your application to manage various media handles.</p>
- <p>The main features of the Audio I/O API include:</p>
- <ul>
- <li><a href="#record_pcm">Recording uncompressed audio</a>
- <p>Enables you to capture uncompressed PCM data from audio device.</p></li>
+ <p>Audio I/O enables your application to manage various media handles.</p>
+ <p>The main features of the Audio I/O API include:</p>
+ <ul>
+ <li><a href="#record_pcm">Recording uncompressed audio</a>
+ <p>Enables you to capture uncompressed PCM data from audio device.</p></li>
<li><a href="#play_pcm">Playing uncompressed audio</a>
- <p>Enables you to create a multimedia application to play uncompressed PCM data.</p></li>
- </ul>
-
+ <p>Enables you to create a multimedia application to play uncompressed PCM data.</p></li>
+ </ul>
+
<h2 id="record_pcm" name="record_pcm">Recording Uncompressed Audio</h2>
-<p>The Pulse Code Modulated (PCM) data contains non-compressed audio. The Audio Input API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__MEDIA__AUDIO__IN__MODULE.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__MEDIA__AUDIO__IN__MODULE.html">wearable</a> applications) enables your application to record such data from a microphone type input device.</p>
- <p>Audio data is captured periodically, so to receive the audio PCM data from the input device, you must implement the audio input interface to notify the application of audio data events, such as the end of filling audio data.</p>
- <p>Before recording audio, you must define the following PCM data settings:</p>
- <ul>
- <li>Input device type:
- <ul class="indent">
- <li>Microphone</li>
- </ul> </li>
- <li>Audio channels:
- <ul class="indent">
- <li>Mono (1 channel)</li>
- <li>Stereo (2 channels)</li>
- </ul> </li>
- <li>Audio sample type:
- <ul class="indent">
- <li>Unsigned 8-bit PCM</li>
- <li>Signed 16-bit little endian PCM</li>
- </ul> </li>
- <li>Audio sample rate:
- <ul class="indent">
- <li>8000 ~ 48000 Hz</li>
- </ul></li>
- </ul>
- <p>To minimize the overhead of the audio input API, use the optimal channel type, sample type and sampling rate, which can be retrieved using the <span style="font-family: Courier New,Courier,monospace">audio_in_get_channel()</span>, <span style="font-family: Courier New,Courier,monospace">audio_in_get_sample_type()</span> and <span style="font-family: Courier New,Courier,monospace">audio_in_get_sample_rate()</span> functions, respectively.</p>
+<p>The Pulse Code Modulated (PCM) data contains non-compressed audio. The Audio Input API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__MEDIA__AUDIO__IN__MODULE.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__MEDIA__AUDIO__IN__MODULE.html">wearable</a> applications) enables your application to record such data from a microphone type input device.</p>
+ <p>Audio data is captured periodically, so to receive the audio PCM data from the input device, you must implement the audio input interface to notify the application of audio data events, such as the end of filling audio data.</p>
+ <p>Before recording audio, you must define the following PCM data settings:</p>
+ <ul>
+ <li>Input device type:
+ <ul class="indent">
+ <li>Microphone</li>
+ </ul> </li>
+ <li>Audio channels:
+ <ul class="indent">
+ <li>Mono (1 channel)</li>
+ <li>Stereo (2 channels)</li>
+ </ul> </li>
+ <li>Audio sample type:
+ <ul class="indent">
+ <li>Unsigned 8-bit PCM</li>
+ <li>Signed 16-bit little endian PCM</li>
+ </ul> </li>
+ <li>Audio sample rate:
+ <ul class="indent">
+ <li>8000 ~ 48000 Hz</li>
+ </ul></li>
+ </ul>
+ <p>To minimize the overhead of the audio input API, use the optimal channel type, sample type and sampling rate, which can be retrieved using the <span style="font-family: Courier New,Courier,monospace">audio_in_get_channel()</span>, <span style="font-family: Courier New,Courier,monospace">audio_in_get_sample_type()</span> and <span style="font-family: Courier New,Courier,monospace">audio_in_get_sample_rate()</span> functions, respectively.</p>
- <p>The following figures illustrate the general audio input states, and how the state changes when the audio input is interrupted by the system.</p>
- <p class="figure">Figure: Audio input states</p>
- <p align="center"><img src="../../images/audio_input.png" alt="Audio input states" /></p>
- <p class="figure">Figure: Audio input states when interrupted by system</p>
+ <p>The following figures illustrate the general audio input states, and how the state changes when the audio input is interrupted by the system.</p>
+ <p class="figure">Figure: Audio input states</p>
+ <p align="center"><img src="../../images/audio_input.png" alt="Audio input states" /></p>
+ <p class="figure">Figure: Audio input states when interrupted by system</p>
<p align="center"><img src="../../images/audio_input_interrupt_state.png" alt="Audio input states when interrupted by system" /></p>
-
+
<h2 id="play_pcm" name="play_pcm">Playing Uncompressed Audio</h2>
-<p>The Pulse Code Modulated (PCM) data contains non-compressed audio. The Audio Output API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__MEDIA__AUDIO__OUT__MODULE.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__MEDIA__AUDIO__OUT__MODULE.html">wearable</a> applications) enables your application to play such data using output devices.</p>
- <p>To play the audio PCM data, the application must call the <span style="font-family: Courier New,Courier,monospace">audio_out_create()</span> function to initialize the audio output handle.</p>
- <p>Before playing audio, your application must define the following PCM data settings:</p>
- <ul>
- <li>Audio channels:
- <ul class="indent">
- <li>Mono (1 channel)</li>
- <li>Stereo (2 channels)</li>
- </ul> </li>
- <li>Audio sample type:
- <ul class="indent">
- <li>Unsigned 8-bit PCM</li>
- <li>Signed 16-bit little endian PCM</li>
- </ul> </li>
- <li>Audio sample rate:
- <ul class="indent">
- <li>8000 ~ 48000 Hz</li>
+<p>The Pulse Code Modulated (PCM) data contains non-compressed audio. The Audio Output API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__MEDIA__AUDIO__OUT__MODULE.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__MEDIA__AUDIO__OUT__MODULE.html">wearable</a> applications) enables your application to play such data using output devices.</p>
+ <p>To play the audio PCM data, the application must call the <span style="font-family: Courier New,Courier,monospace">audio_out_create()</span> function to initialize the audio output handle.</p>
+ <p>Before playing audio, your application must define the following PCM data settings:</p>
+ <ul>
+ <li>Audio channels:
+ <ul class="indent">
+ <li>Mono (1 channel)</li>
+ <li>Stereo (2 channels)</li>
+ </ul> </li>
+ <li>Audio sample type:
+ <ul class="indent">
+ <li>Unsigned 8-bit PCM</li>
+ <li>Signed 16-bit little endian PCM</li>
+ </ul> </li>
+ <li>Audio sample rate:
+ <ul class="indent">
+ <li>8000 ~ 48000 Hz</li>
</ul> </li>
- </ul>
-
- <p>The following figures illustrate the general audio output states, and how the state changes when the audio output is interrupted by the system.</p>
- <p class="figure">Figure: Audio output states</p>
- <p align="center"><img src="../../images/audio_output.png" alt="Audio output states" /></p>
- <p class="figure">Figure: Audio output states when interrupted by system</p>
- <p align="center"><img src="../../images/audio_output_interrupt_state.png" alt="Audio output states when interrupted by system" /></p>
- <h3 id="use" name="use">Using Audio Output</h3>
- <p>For supporting various low-end Tizen devices, the application must follow certain guidelines:</p>
- <ul>
- <li>Do not use multiple instances of the <span style="font-family: Courier New,Courier,monospace">Audio_Out</span> excessively.
- <p>Using excessive multiple instances of the <span style="font-family: Courier New,Courier,monospace">Audio_Out</span> has a negative effect on the application, because the audio data processing for re-sampling and mixing imposes a heavy burden on the system. </p> </li>
+ </ul>
+
+ <p>The following figures illustrate the general audio output states, and how the state changes when the audio output is interrupted by the system.</p>
+ <p class="figure">Figure: Audio output states</p>
+ <p align="center"><img src="../../images/audio_output.png" alt="Audio output states" /></p>
+ <p class="figure">Figure: Audio output states when interrupted by system</p>
+ <p align="center"><img src="../../images/audio_output_interrupt_state.png" alt="Audio output states when interrupted by system" /></p>
+ <h3 id="use" name="use">Using Audio Output</h3>
+ <p>For supporting various low-end Tizen devices, the application must follow certain guidelines:</p>
+ <ul>
+ <li>Do not use multiple instances of the Audio Output excessively.
+ <p>Using excessive multiple instances of the Audio Output has a negative effect on the application, because the audio data processing for re-sampling and mixing imposes a heavy burden on the system. </p> </li>
<li>Use device-preferred PCM format.
- <ul>
- <li><p>To reduce the processing overhead, use the target device-preferred PCM format (for example, use 16-bit little endian, 44.1 kHz, stereo for Wave and Wave M).</p></li>
- <li><p>Using the preferred format reduces internal operations, such as converting audio samples from mono to stereo or re-sampling audio frequency to fit the target device's input sample rate.</p></li>
- </ul> </li>
- <li>Do not call the <span style="font-family: Courier New,Courier,monospace">Audio_Out</span> functions too frequently.
- <ul>
- <li><p>The <span style="font-family: Courier New,Courier,monospace">Audio_Out</span> functions require more processing time in the order of write > prepare > reset > unprepare > start > stop. Therefore, keep the frequency of calling these functions to a minimum.</p></li>
+ <ul>
+ <li><p>To reduce the processing overhead, use the target device-preferred PCM format (for example, use 16-bit little endian, 44.1 kHz, stereo for Wave and Wave M).</p></li>
+ <li><p>Using the preferred format reduces internal operations, such as converting audio samples from mono to stereo or re-sampling audio frequency to fit the target device's input sample rate.</p></li>
+ </ul> </li>
+ <li>Do not call the Audio Output functions too frequently.
+ <ul>
+ <li><p>The Audio Output functions require more time while repeate in the order of <span style="font-family: Courier New,Courier,monospace">audio_out_create</span> > <span style="font-family: Courier New,Courier,monospace">audio_out_prepare</span> > <span style="font-family: Courier New,Courier,monospace">audio_out_unprepare</span> > <span style="font-family: Courier New,Courier,monospace">audio_out_destroy</span>. Therefore, keep the frequency of calling these functions to a minimum. Please note that <span style="font-family: Courier New,Courier,monospace">audio_out_prepare</span>, <span style="font-family: Courier New,Courier,monospace">audio_out_unprepare</span> are much fast than <span style="font-family: Courier New,Courier,monospace">audio_out_create</span>, <span style="font-family: Courier New,Courier,monospace">audio_out_destroy</span>.</p></li>
</ul> </li>
<li>Reduce event delay and remove glitches.
- <ul>
- <li><p>The Audio Output API works recursively with events. The smaller the buffer size, the more often are events generated. If you use the Audio Output API with the smallest buffer and other resources (for example, a timer or sensor), the application is negatively influenced by the delay of the event. To prevent problems, set the write buffer size properly based on the other resources you need.</p></li>
- <li><p>To guarantee the working events of the Audio Output API independently, an instance of the Audio Output API needs to be created and worked on the event thread.</p></li>
- </ul> </li>
+ <ul>
+ <li><p>The Audio Output API works recursively with events. The smaller the buffer size, the more often are events generated. If you use the Audio Output API with the smallest buffer and other resources (for example, a timer or sensor), the application is negatively influenced by the delay of the event. To prevent problems, set the write buffer size properly based on the other resources you need.</p></li>
+ <li><p>To guarantee the working events of the Audio Output API independently, an instance of the Audio Output API needs to be created and worked on the event thread.</p></li>
+ </ul> </li>
<li>Use double-buffering.
- <ul>
- <li><p>Use the double buffering mechanism to reduce latency. The mechanism works by first writing data twice before starting. After starting, whenever the listener (event) is called, you can write additional data.</p></li>
- </ul> </li>
- </ul>
+ <ul>
+ <li><p>Use the double buffering mechanism to reduce latency. The mechanism works by first writing data twice before starting. After starting, whenever the listener (event) is called, you can write additional data.</p></li>
+ </ul> </li>
+ </ul>
<script type="text/javascript" src="../../scripts/jquery.zclip.min.js"></script>