播放音频倒退 [英] Playing audio backwards

查看:398
本文介绍了播放音频倒退的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想在Android的倒退播放音频。我如何做到的呢?任何指针将AP preciated。谢谢你。

Hi I'd like to play audio backwards in Android. How do I accomplish it? Any pointers will be appreciated. Thanks.

推荐答案

有可能不是在API来这样的功能。

there probably isn't a functionality in the apis for this.

但是,它很容易向后播放PCM音频数据。

however, it's quite easy to play pcm audio data backwards.

用c ++风格的伪code进行演示:

a demonstration using c++ style pseudo-code:

/* 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];
}

这篇关于播放音频倒退的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆