[android-developers] Re: how to decode bytes from mp3 to pcm ?

2013-01-07 Thread bhupinder jai mata di
use JLayer

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] is AudioTrack well suited for playing mp3 files as decoder taking too long to load (a portion of mp3 file)? Using JLayer

2013-01-07 Thread bhupinder jai mata di
I have used JLayer library to decode the mp3 file . A function which 
returns byte[] by decoding file picked from sdcard.
so means i get bytes(array of bytes from that decoder function).
here is some code i m using.

>
>  int minSize =AudioTrack.getMinBufferSize( 8000, 
> AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT ); 
>
> mySong = new AudioTrack( AudioManager.STREAM_MUSIC, 
> 8000,AudioFormat.CHANNEL_CONFIGURATION_STEREO, 
> AudioFormat.ENCODING_PCM_16BIT, minSize, AudioTrack.MODE_STREAM);


Eg:

> buffer = decode(Environment.getExternalStorageDirectory()+"/cm.mp3", 
> 0,1500);
> mySong.play();
> mySong.write(buffer, 0, buffer.length);




and code for decode is:

 public static byte[] decode(String path, int startMs, int maxMs)  throws 
> IOException, DecoderException 
> {
> ByteArrayOutputStream outStream = new ByteArrayOutputStream(1024);
> float totalMs = 0;
> boolean seeking = true;
> File file = new File(path);
> InputStream inputStream = new BufferedInputStream(new 
> FileInputStream(file), 8 * 1024);
> try
> {
> Bitstream bitstream = new Bitstream(inputStream);
> Decoder decoder = new Decoder();
> boolean done = false;
> while (! done)
> {
>   javazoom.jl.decoder.Header frameHeader = bitstream.readFrame();
>   if (frameHeader == null)
> done = true;
>   else
>   {
> totalMs += frameHeader.ms_per_frame();
> if (totalMs >= startMs)
>  seeking = false;
> if (! seeking)
> {
>   SampleBuffer output = (SampleBuffer) 
> decoder.decodeFrame(frameHeader, bitstream);
>  if (output.getSampleFrequency() != 44100 || 
> output.getChannelCount() != 2)
> throw new DecoderException("mono or non-44100 MP3 not 
> supported", null);
>   short[] pcm = output.getBuffer();
>   for (short s : pcm)
>   {
> outStream.write(s & 0xff);
> outStream.write((s >> 8 ) & 0xff);
>   }
> }
> if (totalMs >= (startMs + maxMs))
>   done = true;
>   }
>   bitstream.closeFrame();
> }
> return outStream.toByteArray();
>}
>catch (BitstreamException e)
>{
> throw new IOException("Bitstream error: " + e);
>} 
>catch (DecoderException e) 
>{
>Log.w("error is:", "Decoder error", e);
>}
> return null;
> }


if i give maxMs(maximum number of seconds >15) it takes way to long. 
   and for song of 28-30 seconds it takes more than 1 min to load and 
decode. is there any other library or way.
I just want to play large mp3 files but importantly want to modify the 
pitch. means user can change the speed 1x ,2x,3x etc.
SoundPool and AudioTrack do this. SoundPool cant play  large files.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] AudioTrack mp3 decoder takes too long to load mp3 file and decode? Is there any alternative for that?

2013-01-07 Thread bhupinder jai mata di
I am using AudioTrack class to play large mp3 files. Actually i want to 
manipulate voice on fly like changing the pitch or speed 1x 2x etc.
As soundtrack works only for short files. So i found AudioTrack the only 
option. 

I am using JLayer to decode my mp3 file (stored on sdcard) to PCM byte 
array. 
Following is the code for Decoder function:

 public static byte[] decode(String path, int startMs, int maxMs)  throws 
> IOException, DecoderException 
> {
> ByteArrayOutputStream outStream = new ByteArrayOutputStream(1024);
> float totalMs = 0;
> boolean seeking = true;
> File file = new File(path);
> InputStream inputStream = new BufferedInputStream(new 
> FileInputStream(file), 8 * 1024);
> try
> {
> Bitstream bitstream = new Bitstream(inputStream);
> Decoder decoder = new Decoder();
> boolean done = false;
> while (! done)
> {
>   javazoom.jl.decoder.Header frameHeader = bitstream.readFrame();
>   if (frameHeader == null)
> done = true;
>   else
>   {
> totalMs += frameHeader.ms_per_frame();
> if (totalMs >= startMs)
>  seeking = false;
> if (! seeking)
> {
>   SampleBuffer output = (SampleBuffer) 
> decoder.decodeFrame(frameHeader, bitstream);
>   if (output.getSampleFrequency() != 44100 || 
> output.getChannelCount() != 2)
> throw new DecoderException("mono or non-44100 MP3 not 
> supported", null);
>   short[] pcm = output.getBuffer();
>   for (short s : pcm)
>   {
> outStream.write(s & 0xff);
> outStream.write((s >> 8 ) & 0xff);
>   }
> }
> if (totalMs >= (startMs + maxMs))
>   done = true;
>   }
>   bitstream.closeFrame();
> }
> return outStream.toByteArray();
>}
>catch (BitstreamException e)
>{
> throw new IOException("Bitstream error: " + e);
>} 
>catch (DecoderException e) 
>{
>Log.w("error is:", "Decoder error", e);
>}
> return null;
> }


So i pass like this

buffer = decode(Environment.getExternalStorageDirectory()+"/cm.mp3", 
> i,i+1000);


But this is taking so long. Even if i pass max size to 15 seconds. it takes 
about 1 min to load into buffer. Is there any other mp3 decoder 
avaialable.? faster than this.

What are other ways? can i just stream large audio file to SOUNDPOOL?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] AudioTrack mp3 codec taking too long to load. using JLayer.?

2013-01-07 Thread bhupinder jai mata di
I am using AudioTrack class to play large mp3 files. Actually i want to 
manipulate voice on fly like changing the pitch or speed 1x 2x etc.
As soundtrack works only for short files. So i found AudioTrack the only 
option. 

I am using JLayer to decode my mp3 file (stored on sdcard) to PCM byte 
array. 
Following is the code for Decoder function:

 public static byte[] decode(String path, int startMs, int maxMs)  throws 
> IOException, DecoderException 
> {
> ByteArrayOutputStream outStream = new ByteArrayOutputStream(1024);
> float totalMs = 0;
> boolean seeking = true;
> File file = new File(path);
> InputStream inputStream = new BufferedInputStream(new 
> FileInputStream(file), 8 * 1024);
> try
> {
> Bitstream bitstream = new Bitstream(inputStream);
> Decoder decoder = new Decoder();
> boolean done = false;
> while (! done)
> {
>   javazoom.jl.decoder.Header frameHeader = bitstream.readFrame();
>   if (frameHeader == null)
> done = true;
>   else
>   {
> totalMs += frameHeader.ms_per_frame();
> if (totalMs >= startMs)
>  seeking = false;
> if (! seeking)
> {
>   SampleBuffer output = (SampleBuffer) 
> decoder.decodeFrame(frameHeader, bitstream);
>  if (output.getSampleFrequency() != 44100 || 
> output.getChannelCount() != 2)
> throw new DecoderException("mono or non-44100 MP3 not 
> supported", null);
>   short[] pcm = output.getBuffer();
>   for (short s : pcm)
>   {
> outStream.write(s & 0xff);
> outStream.write((s >> 8 ) & 0xff);
>   }
> }
> if (totalMs >= (startMs + maxMs))
>   done = true;
>   }
>   bitstream.closeFrame();
> }
> return outStream.toByteArray();
>}
>catch (BitstreamException e)
>{
> throw new IOException("Bitstream error: " + e);
>} 
>catch (DecoderException e) 
>{
>Log.w("error is:", "Decoder error", e);
>}
> return null;
> }


So i pass like this

buffer = decode(Environment.getExternalStorageDirectory()+"/cm.mp3", 
> i,i+1000);


But this is taking so long. Even if i pass max size to 15 seconds. it takes 
about 1 min to load into buffer. Is there any other mp3 decoder 
avaialable.? faster than this.

What are other ways? can i just stream large audio file to SOUNDPOOL?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Getting an App for Read an RFID Reader Device.

2012-04-12 Thread jai
Hi Android experts,

I Would like to develop an app which can read the RFID Reader Device
through the USB
is it possible to do it please give me support

Thanks in advance



Regards,
jai

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] if condition not working in intent activity

2012-03-08 Thread ~JAI~
hi friends,

i'm new to android. i'm using the code below to create a new intent
activity based on if condition validation.. but it doesn't work... pls
help me..



CODE


package com.example.helloandroid;

public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


ImageButton next2 = (ImageButton)
findViewById(R.id.imageButton1);
next2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {

EditText pin =
(EditText)findViewById(R.id.editText1); //value from edit text

 Log.v("EditText", pin.getText().toString()); //
this works in log

if (pin.equals()){
Intent myIntent = new Intent(view.getContext(),
home.class);
startActivityForResult(myIntent, 1);
 }
}
});
}
@Override
public void onBackPressed() {
return;

}
}


the log file gets the value from text box, but the if condition does
not work.. pls help me.. thanks in advance...

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Live wallpaper not showing up on Samsung Captivate 2.1 update 1 while shows up fine on Droid1 Froyo

2010-10-08 Thread Jai
Dan Yes I do. Still!!

Thanks Jeremy is it all wallpapers or newly published ones, because I
can see others.

On Oct 7, 12:24 pm, dan raaka  wrote:
> Do you specify the the uses-feature string "android.software.live_wallpaper"
> on you manifest ?
>
> -Dan
>
>
>
> On Wed, Oct 6, 2010 at 7:41 AM, Jai  wrote:
> > I have a live wallpaper published in the market called "Painter ants
> > live", it shows up fine on my Droid1 froyo but not on Samsung
> > Captivate 2.1 update 1. Any inputs will be helpful. Thanks.
>
> > The minSDKVersion and targetSDKVersion are both 7. The only problem
> > that I can see is that the first version was built with targetsdk8 but
> > was rectified later (twice) with targetsdk7.
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com > cr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Live wallpaper not showing up on Samsung Captivate 2.1 update 1 while shows up fine on Droid1 Froyo

2010-10-06 Thread Jai
I have a live wallpaper published in the market called "Painter ants
live", it shows up fine on my Droid1 froyo but not on Samsung
Captivate 2.1 update 1. Any inputs will be helpful. Thanks.

The minSDKVersion and targetSDKVersion are both 7. The only problem
that I can see is that the first version was built with targetsdk8 but
was rectified later (twice) with targetsdk7.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Live wallpaper not showing up on Samsung Captivate 2.1 update 1 while shows up fine on Droid1 Froyo

2010-10-06 Thread Jai
I have a live wallpaper published in the market called "Painter ants
live", it shows up fine on my Droid1 froyo but not on Samsung
Captivate 2.1 update 1. Any inputs will be helpful. Thanks.

The minSDKVersion and targetSDKVersion are both 7. The only problem
that I can see is that the first version was built with targetsdk8 but
was rectified later (twice) with targetsdk7.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Configuring the Dev Phone

2009-02-11 Thread jai

Hello all ,

I got the Device from USA. Right now i am in India. Trying to setup
the Dev phone.I setup the APN settings of my service provider. After
giving my user id and password, the device is trying to reach Google
server for validation it seems. But the device couldn't communicate
with google server.

I would like to know - is there any setting I need to change to
activate my phone. I was trying to contact customer sevrice but
couldn't get in internet.

If anyone knows please help me to setup

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---