从跑步声音剪辑中剪辑声音

发布于 2024-12-08 05:50:15 字数 89 浏览 2 评论 0原文

有人知道如何从运行的声音文件中剪切声音片段吗?我正在开发一个黑莓应用程序,有人有任何示例代码或链接吗?请给我。

谢谢

问候 V·辛格

Does anybody know how to cut a sound clip from running sound file? I am working on one blackberry application, Is anybody have any sample code or link please give me that.

Thanks

Regards
V Singh

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

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

发布评论

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

评论(2

愛上了 2024-12-15 05:50:15

可以剪切声音文件的一部分。您必须研究声音文件格式并处理声音文件二进制结构。

不,我没有示例代码,但您可以在研究声音文件格式后自己编写。

It is possible to cut a part of sound file. You have to study sound file formats and deal with sound file binary structure.

No, I don't have sample code, but you can write it by yourself, after studying sound file formats.

瀞厅☆埖开 2024-12-15 05:50:15

//剪切声音文件的示例代码(AMR)

long startTime =player.getMediaTime();
长结束时间=player.getMediaTime();

    private void cutByTimeDuration(long startTime, long endTime) {
    // TODO Auto-generated method stub
    byte[] byte1 = readDSoundFile("hello.amr"); //custom method original file 
    int noFramesStart = (int) (startTime / 20000);
    long noBytesStart = (noFramesStart * 32) + 6;
    int noFramesEnd = (int) (endTime / 20000);
    long noBytesEnd = (noFramesEnd * 32) + 6;
    byte[] byte2 = new byte[(int) (noBytesEnd - noBytesStart + 6)];
    System.arraycopy(byte1, 0, byte2, 0, 6);
    System.arraycopy(byte1, (int) noBytesStart, byte2, 6,
            (int) (noBytesEnd - noBytesStart));

    try {

        FileConnection file = (FileConnection) Connector.open(filePath
                + "/" + "xyz.amr", Connector.READ_WRITE);
        if (file.exists())
            file.delete();

        // if (!file.exists() )
        {
            file.create();
            OutputStream out = file.openOutputStream();
            int length = byte2.length;// -1;
            out.write(byte2, 0, length);
            Thread.yield();

            out.flush();
            out.close();
            file.close();

        }
    } catch (Exception e) {
    }

}

//Sample code to cut a sound file(AMR)

long startTime = player.getMediaTime();
long endTime = player.getMediaTime();

    private void cutByTimeDuration(long startTime, long endTime) {
    // TODO Auto-generated method stub
    byte[] byte1 = readDSoundFile("hello.amr"); //custom method original file 
    int noFramesStart = (int) (startTime / 20000);
    long noBytesStart = (noFramesStart * 32) + 6;
    int noFramesEnd = (int) (endTime / 20000);
    long noBytesEnd = (noFramesEnd * 32) + 6;
    byte[] byte2 = new byte[(int) (noBytesEnd - noBytesStart + 6)];
    System.arraycopy(byte1, 0, byte2, 0, 6);
    System.arraycopy(byte1, (int) noBytesStart, byte2, 6,
            (int) (noBytesEnd - noBytesStart));

    try {

        FileConnection file = (FileConnection) Connector.open(filePath
                + "/" + "xyz.amr", Connector.READ_WRITE);
        if (file.exists())
            file.delete();

        // if (!file.exists() )
        {
            file.create();
            OutputStream out = file.openOutputStream();
            int length = byte2.length;// -1;
            out.write(byte2, 0, length);
            Thread.yield();

            out.flush();
            out.close();
            file.close();

        }
    } catch (Exception e) {
    }

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