正确修剪 ByteArray 中的 PCM 数据

发布于 2024-09-03 11:01:31 字数 547 浏览 1 评论 0原文

我遇到一种情况,需要从录制剪辑的开头修剪少量音频(通常在 110-150 毫秒之间,这是一个不一致的量)。

我以 44100 频率和 16 比特率进行录制。这是我正在使用的代码:

public function get trimmedData():ByteArray {
        var ba:ByteArray = new ByteArray();
        var bitPosition:uint = 44100 * 16 * (recordGap / 1000);
        bitPosition -= int(bitPosition % 16); //should keep snapped to nearest sample, I hope
        ba.writeBytes(_rawData, (bitPosition / 8));
        return ba;
    }

这似乎在时间上有效,但所有录制的音频都变得静态和粗糙。我的四舍五入有问题吗?这是我第一次需要更改原始 PCM 数据,因此我不确定它的详细信息。

谢谢!

I have a situation where I need to trim a small amount of audio from the beginning of a recorded clip (generally somewhere between 110-150ms, it is an inconsistent amount).

I'm recording in 44100 frequency and 16 bitrate. This is the code I'm using:

public function get trimmedData():ByteArray {
        var ba:ByteArray = new ByteArray();
        var bitPosition:uint = 44100 * 16 * (recordGap / 1000);
        bitPosition -= int(bitPosition % 16); //should keep snapped to nearest sample, I hope
        ba.writeBytes(_rawData, (bitPosition / 8));
        return ba;
    }

This seems to work time-wise, but all the recorded audio gets staticy and gross. Is something off about my rounding? This is the first time I've needed to alter raw PCM data so I'm not sure about the finer details of it.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独﹏钓一江月 2024-09-10 11:01:31

静态问题似乎更多是体积和限制的问题,而不是这个装饰的问题!

The static issue seemed to be more a problem with volumes and limiting than with this trim!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文