Blackberry 从跑步声音剪辑剪辑声音

Blackberry 从跑步声音剪辑剪辑声音,blackberry,java-me,Blackberry,Java Me,有人知道如何从运行的声音文件中剪切声音片段吗?我在一个黑莓应用程序的工作,是任何人有任何样本代码或链接请给我 谢谢 问候 V Singh可以剪切声音文件的一部分。你必须学习声音文件格式和处理声音文件二进制结构 不,我没有示例代码,但您可以在研究声音文件格式后自己编写。//剪切声音文件的示例代码(AMR) long startTime=player.getMediaTime(); long-endTime=player.getMediaTime() 嗨,Rafael,谢谢你的回复,但我有一个问题,

有人知道如何从运行的声音文件中剪切声音片段吗?我在一个黑莓应用程序的工作,是任何人有任何样本代码或链接请给我

谢谢

问候
V Singh

可以剪切声音文件的一部分。你必须学习声音文件格式和处理声音文件二进制结构


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

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

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


嗨,Rafael,谢谢你的回复,但我有一个问题,我们如何从运行的声音文件的时间基础上削减剪辑,假设我有一个60秒的声音剪辑,我想从现有的剪辑20秒到35秒的剪辑。正如我前面所说,你需要知道声音(mp3,ogg等)文件的格式。当你知道文件头的格式后,你可以解析文件头,提取声音流,剪切声音文件中必要的二进制部分,然后用新的头和新的(较短的)声音流组成一个新的声音文件。要查找关于声音文件格式的信息,请使用谷歌。关于这个主题有很多信息。
    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) {
    }

}