转换的PCM-16型,使用AmrInputStream AMRPCM、AMR、AmrInputStream

由网友(陌上浅笑)分享简介:我使用AmrInputStream做从PCM-16转换为AMR。详细的AmrInputStream可以在这里发现HTTP:// HI-机器人。信息/ src目录/安卓/媒体/ AmrInputStream.java.html I'm doing a conversion from PCM-16 to AMR usi...

我使用AmrInputStream做从PCM-16转换为AMR。详细的AmrInputStream可以在这里发现HTTP:// HI-机器人。信息/ src目录/安卓/媒体/ AmrInputStream.java.html

I'm doing a conversion from PCM-16 to AMR using AmrInputStream. The details for the AmrInputStream can be found here http://hi-android.info/src/android/media/AmrInputStream.java.html

我是相当新的编程,同时它谈论使用JNI和东西,我不知道什么JNI是,我不认为这是需要这种讨论。上述AmrInputStream也显然没有在SDK中也没有发现NDK,但我已经能够使用它。

I'm quite new to programming to while it talks about using JNI and stuff, I have no idea what JNI is and I don't think it is required for this discussion. The AmrInputStream above is also apparently not found in the SDK nor the NDK, but I have been able to use it.

我一直在寻找在互联网附近为如何使用流,但没有发现任何实例。最后我试验,发现它是相似的,只是任何的InputStream。这里有一个code段

I've been searching around the internet for how to use the stream, but have not found any examples. In the end I experimented and found it to be similar to just any InputStream. Here's a code snippet

InputStream inStream;
    inStream = new FileInputStream("abc.wav");
    AmrInputStream aStream = new AmrInputStream(inStream);

    File file = new File("xyz.amr");        
    file.createNewFile();
    OutputStream out = new FileOutputStream(file); 

    byte[] x = new byte[1024];
    int len;
    while ((len=aStream.read(x)) > 0) {
        out.write(x,0,len);
    }

    out.close();

我已经测试了这一点,它曾(需要添加#AMR ñ标签播放输出文件!)(编辑:AMR的标签必须是#AMR n)的。

I have tested this and it has worked (requiring adding the #!AMRn tag to the output file for playing.) ( The AMR tag must be #!AMRn).

我的问题是关于我只设法得到这个工作对采样的8000Hz的一个PCM-16文件。任何频率(较高)的用于原始的PCM-16文件会产生一个(欠)输出。有一个在我曾尝试摆弄AmrInputStream.java文件SAMPLES_PER_FRAME变量,但它似乎并没有造成任何影响。

My question pertains to that I have only managed to get this to work on a PCM-16 file sampled at 8000Hz. Any (higher) frequency used for the original PCM-16 file results in an (undersampled) output. There is a SAMPLES_PER_FRAME variable in the AmrInputStream.java file which I have tried playing with but it does not seem to affect anything.

任何建议或相关讨论,欢迎!

Any advise or related discussion is welcomed!

推荐答案

SAMPLES_PER_FRAME是数据的amren codeR一气呵成(它被映射到20毫秒音频)。

SAMPLES_PER_FRAME is the block of data the amrencoder acts on in one go(which is mapped to 20 msec of audio).

从AMR的签名EN codeR功能(在的 http://hi-android.info/src/android/media/AmrInputStream.java.html )

from the signatures of the amr encoder functions (at the bottom of http://hi-android.info/src/android/media/AmrInputStream.java.html)

private static native int GsmAmrEncoderNew();

private static native void GsmAmrEncoderInitialize(int gae);

private static native int GsmAmrEncoderEncode(int gae,
        byte[] pcm, int pcmOffset, byte[] amr, int amrOffset) throws IOException;

private static native void GsmAmrEncoderCleanup(int gae);

private static native void GsmAmrEncoderDelete(int gae);

目前似乎没有一种方式来传递采样率的EN codeR(GAE是原生手柄) 采样率是很难coded到这个API ATLEAST 8K

There doesnt seem to be a way to pass samplerate to the encoder.(gae is native handle) the sample rate is hardcoded to 8k atleast with this api

阅读全文

相关推荐

最新文章