2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
サンプルレート変換
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
この記事では、リサンプリングとも呼ばれる Android のサンプルレート変換について説明します。サンプルレート変換関連の用語については、用語をご覧ください。
サンプルレート変換とは、サンプル ストリームを特定のサンプルレートから別のサンプルレートに変更するプロセスです。サンプルレート変換を行うモジュールを、サンプルレート コンバーター(あるいはリサンプラー)と呼びます。リサンプラーでは、元のストリームはソース信号と呼ばれ、リサンプリングされたストリームはシンク信号と呼ばれます。
リサンプラーは、Android のさまざまな場所で使用されます。たとえば、MP3 ファイルは 44.1 kHz のサンプルレートでエンコードされますが、内部で 48 kHz の音声をサポートする Android デバイスで再生する必要があります。この場合リサンプラーは、MP3 出力オーディオを、44.1 kHz のソース サンプルレートから Android デバイス内で使用される 48 kHz のシンク サンプルレートにアップサンプルします。
リサンプラーの特性は、次のような指標で表すことができます。
- 信号の全体的な振幅の保持度
- シンク サンプルレートの制限を受ける信号の周波数帯域幅の保持度
- リサンプラーを通じた全体的なレイテンシ
- 周波数に対する一貫した位相と群遅延
- CPU サイクルまたは電力消費量で表される計算複雑性
- サンプルレートのソースとシンクの許容比率
- サンプルレート比率を動的に変更する機能
- サポートされているデジタル オーディオ サンプル フォーマット
ソース信号の振幅と周波数帯域幅を正確に保持(シンク サンプルレートの制限に従う)し、遅延が最小限で一貫しており、計算複雑性が最小で、任意の動的な変換率を受け入れ、すべての一般的なデジタル オーディオ サンプル形式をサポートするリサンプラーが理想です。実際はこういったリサンプラーは存在せず、これらの特性の中で妥協することになります。たとえば、品質目標の理想値は、短い遅延や低い複雑性といった特性に相反します。
Android にはさまざまなオーディオ リサンプラーが含まれているため、アプリのユースケースと負荷に応じて適切なものを利用できます。利用可能なリサンプラーについては、リサンプラーの実装をご覧ください。
リサンプラーの実装
利用可能なリサンプラーの実装は頻繁に変更され、また OEM によりカスタマイズされることもあります。デフォルトのリサンプラーを次に示します(信号歪みで降順、計算複雑性で昇順)。
- リニア
- キュービック
- 元の係数による sinc
- 係数を修正した sinc
通常、高品質の音楽を再生するには sinc リサンプラーが適しており、品質が重要でない場合(キーのクリック音など)は他のリサンプラーを使用します。
特定のリサンプラーを選択した場合の実装は、ユースケース、負荷、システム プロパティ af.resampler.quality
の値に応じて異なります。詳細については、AudioFlinger のオーディオ リサンプラーのソースコードをご覧ください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-03-26 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-26 UTC。"],[],[],null,["# Sample rate conversion\n\nThis article describes sample rate conversion, also known as *resampling* , within Android.\nFor terminology related to sample rate conversion, see\n[Terminology](/docs/core/audio/terminology#srcTerms).\n\n\nSample rate conversion is the process of changing a stream of discrete samples\nfrom one sample rate to another stream at a different sample rate.\nA sample rate converter, or resampler, is a module that implements sample rate\nconversion. With respect to the resampler, the original stream is called the\nsource signal, and the resampled stream is called the sink signal.\n\n\nResamplers are used in several places in Android. For example, an MP3 file may\nbe encoded at 44.1 kHz sample rate but needs to be played back on an Android\ndevice supporting 48 kHz audio internally. In that case, a resampler would be\nused to upsample the MP3 output audio from 44.1 kHz source sample rate to a\n48 kHz sink sample rate used within the Android device.\n\n\nThe characteristics of a resampler can be expressed using metrics, including:\n\n- degree of preservation of the overall amplitude of the signal\n- degree of preservation of the frequency bandwidth of the signal, subject to limitations of the sink sample rate\n- overall latency through the resampler\n- consistent phase and group delay with respect to frequency\n- computational complexity, expressed in CPU cycles or power draw\n- permitted ratios of source and sink sample rates\n- ability to dynamically change sample rate ratios\n- which digital audio sample formats are supported\n\n\nThe ideal resampler would exactly preserve the source signal's amplitude\nand frequency bandwidth (subject to limitations of the sink\nsample rate), have minimal and consistent delay, have minimal\ncomputational complexity, permit arbitrary and dynamic conversion ratios,\nand support all common digital audio sample formats. In practice, ideal\nresamplers do not exist as actual resamplers are a compromise among these\ncharacteristics. For example, goals of ideal quality conflict with short delay\nand low complexity.\n\n\nAndroid includes a variety of audio resamplers, so that appropriate\ncompromises can be made depending on the application use case and load. The\navailable resamplers are explained in [Resampler implementation.](#srcResamplers)\n\nResampler implementations\n-------------------------\n\n\nAvailable resampler implementations change frequently,\nand may be customized by OEMs.\nThe default resamplers, in descending order of signal distortion and ascending order of\ncomputational complexity, include:\n\n- linear\n- cubic\n- sinc with original coefficients\n- sinc with revised coefficients\n\n\nIn general, the sinc resamplers are more appropriate for higher-quality\nmusic playback, and the other resamplers should be reserved for cases\nwhere quality is less important (an example might be \"key clicks\" or similar).\n\n\nThe specific resampler implementation selected depends on\nthe use case, load, and the value of system property\n`af.resampler.quality`. For details,\nconsult the audio resampler source code in\n[AudioFlinger](https://android.googlesource.com/platform/frameworks/av/+/39ec5a7accf61d89a41908999bc789d5c8d0e3d3/services/audioflinger/)."]]