【问题标题】:Playing audio backwards向后播放音频
【发布时间】:2011-02-04 13:41:50
【问题描述】:

您好,我想在 Android 中向后播放音频。我该如何完成它?任何指针将不胜感激。谢谢。

【问题讨论】:

  • 您是否尝试将负采样率传递给 AudioTrack.setPlaybackRate? :)
  • @kusma,还没试过。将在此更新您。
  • 使用 C 代码然后尝试用 Android 编译它会怎样? C/C++ 代码可以让您以数组的形式访问音频文件。

标签: android audio playback


【解决方案1】:

api 中可能没有此功能。

但是,向后播放 pcm 音频数据非常容易。

使用 c++ 风格伪代码的演示:

/* assuming 1 channel (mono), 16 bit LPCM */
const int16_t* const audioFileBuffer = audioFile.audioBuffer();

/* forward */
for (int idx = 0, sampleCount = audioFile.sampleCount(); idx < sampleCount; ++idx) {
    outputBuffer[idx] = audioFileBuffer[idx];
}

/* reverse */
for (int idx = 0, sampleCount = audioFile.sampleCount(), read = audioFile.sampleCount() - 1; idx < sampleCount; ++idx, --read) {
    outputBuffer[idx] = audioFileBuffer[read];
}

【讨论】:

    【解决方案2】:

    我不确定是否有本地方法可以做到这一点(我自己还是 Android 开发领域的新手),但如果归根结底,您总是可以尝试自己反向解码文件,而不是依赖在现有 API 上。

    【讨论】:

      猜你喜欢
      • 2012-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 2015-05-27
      • 1970-01-01
      相关资源
      最近更新 更多