Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using liblame in another android project #1

Open
mdaymard opened this issue Jan 22, 2016 · 1 comment
Open

Using liblame in another android project #1

mdaymard opened this issue Jan 22, 2016 · 1 comment

Comments

@mdaymard
Copy link

Hello,

I would like to use liblame in another android project.
I've already generated the .so file with the NDK.
Right now I've just copied the .so in my /armeabi-, and I load the library with :

static {
System.loadLibrary("lame");
System.loadLibrary("another_library");
}

But I'm not sure if I need to add other files in the project to make lame work.
Any help would be very nice, thanks in advance.

@gqb
Copy link

gqb commented Apr 28, 2016

hello,
I using this project in android platform .
Lame.decodeFrame(headIn, pcmLeft, pcmRight),this method returns a value bigger than pcmLeft or pcmRight array length.
if it is bigger , how can i dill with the data decoded.

My code is below:

protected void decode(String file) throws Exception{

    InputStream headIn = getAssets().open(file);
    Lame.initializeDecoder();
    int config = Lame.configureDecoder(headIn);
    if(config != -1){
        Log.i(this.getClass().getName(), Lame.getDecoderBitrate() + "");
        Log.i(this.getClass().getName(), Lame.getDecoderChannels() + "");

        Log.i(this.getClass().getName(), Lame.getDecoderSampleRate() + "");

        Log.i(this.getClass().getName(), Lame.getDecoderDelay() + "");

        Log.i(this.getClass().getName(), Lame.getDecoderFrameSize() + "");

        int frameSize = Lame.getDecoderFrameSize();
        int decodedSize = 0;
        short[] pcmLeft = new short[1024];
        short[] pcmRight = new short[1024];
        File left = new File(Environment.getExternalStorageDirectory() + "/" + file + "_left.pcm");
        File right = new File(Environment.getExternalStorageDirectory() + "/" + file + "_right.pcm");

        OutputStream leftOut = new FileOutputStream(left);
        OutputStream rightOut = new FileOutputStream(right);

        while(decodedSize < frameSize){


            int currentSize = Lame.decodeFrame(headIn, pcmLeft, pcmRight);
            decodedSize  = decodedSize + currentSize;
            for(int index = 0; index < currentSize; index++){

                leftOut.write(pcmLeft[index]);
                rightOut.write(pcmRight[index]);
            }
        }

        leftOut.flush();
        rightOut.flush();
        leftOut.close();
        rightOut.close();
    }
    Lame.closeDecoder();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants