[android-developers] Audio Transmission over Bluetooth.

2011-11-08 Thread Aditya Singal
Hi,
I wish to know how Audio data is transmitted over Bluetooth channel.
What I mean to ask is, if I have a stream of bytes of audio data, what
kind of conversion or encoding is required before transmission.
Aditya

-- 
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: Audio Transmission over Bluetooth.

2011-11-21 Thread Aditya Singal

Hi,

I'm using two methods to send audio to bluetooth headset:

1)
Thread thread = new Thread()
{
public boolean recording;
public int frequency;
@Override
public void run() {
Log.i("Audio", "Running Audio Thread");
AudioRecord recorder = null;
AudioTrack track = null;
short buffer[] = new short[160];
/*
 * Initialize buffer to hold continuously recorded audio
data, start recording, and start
 * playback.
 */
try
{
int N =
AudioRecord.getMinBufferSize(8000,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT);
recorder = new AudioRecord(AudioSource.MIC, 8000,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, N);
track = new AudioTrack(AudioManager.STREAM_MUSIC, 8000,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, N, AudioTrack.MODE_STREAM);
recorder.startRecording();
track.play();
/*
 * Loops until something outside of this thread stops it.
 * Reads the data from the recorder and writes it to the
audio track for playback.
 */
while(!stopped)
{
Log.i("Map", "Writing new data to buffer");
N = recorder.read(buffer,0,buffer.length);
track.write(buffer, 0, buffer.length);
}
}
catch(Throwable x)
{
Log.w("Audio", "Error reading voice audio", x);
}
/*
 * Frees the thread's resources after the loop completes so
that it can be run again
 */
finally
{
recorder.stop();
recorder.release();
track.stop();
track.release();
}

}
};
thread.start();


2) Using two threads to read and play data simultaneously:

class RecordThread implements Runnable {

Thread runner;
AudioRecord recorder;
int N;
short buffer[];
public RecordThread(int N) {
recorder = new AudioRecord(AudioSource.MIC, 8000,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, N);
recorder.startRecording();
runner = new Thread(this);
Log.v("mictmp", "Audio started");
runner.start(); // (2) Start the thread.
}
public void run() {
N = 
recorder.read(SharedMemory.buffer,0,SharedMemory.buffer.length);
}
}

class TrackThread implements Runnable {

Thread runner;
AudioTrack track;
int N;
short buffer[];
public TrackThread(int N) {
track = new AudioTrack(AudioManager.STREAM_MUSIC, 8000,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT, N, AudioTrack.MODE_STREAM);
track.play();
runner = new Thread(this);
Log.v("mictmp", "Track started");
runner.start(); // (2) Start the thread.
}
public void run() {
track.write(SharedMemory.buffer,0,SharedMemory.buffer.length);
}
}

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

try
{
int N =
AudioRecord.getMinBufferSize(8000,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT);
SharedMemory m = new SharedMemory();
RecordThread rt = new RecordThread(N);
rt.run();
TrackThread tt = new TrackThread(N);
tt.run();
}
catch(Throwable x)
{
Log.w("Audio", "Error reading voice audio", x);
}
}


But in both the cases there is a delay of about 0.5-1 second. Can
someone help me figure out the reason or suggest me how to reduce this
delay?

Aditya Singal



On Nov 8, 7:00 pm, Aditya Singal  wrote:
> Hi,
> I wish to know howAudiodata is transmittedoverBluetoothchannel.
> What I mean to ask is, if I have a stream of bytes ofaudiodata, what
> kind of conversion or encoding is required before transmission.
&

[android-developers] Audio data handling during phone call

2011-02-25 Thread Aditya Singal
Hi,

I was wondering if someone can provide me with the code for setting up
a phone call.

Aditya Singal

-- 
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: Bluetooth Walkie Talkie

2011-04-13 Thread Aditya Singal


Is it possible to get the code for an audio call using bluetooth
headset? That may be helpful.
That may help me to figure out how to send continuous streams of data.


On Apr 6, 11:03 pm, Kristopher Micinski 
wrote:
> You'll have to connect the phones right, and then send a stream of data...
>
> I think you might want to look into how BT headsets work in this type of
> scenario,
> that's probably what you want to do instead. (I'm out of my element here,
> I'm not
> sure if that's possible with the API.)
>
>  Otherwise you have to look into connecting between the two phones.  Look at
> the
> BluetoothChat example, which shows how to go about sending data, then you
> have
> a stream socket. By the way, I think that the data rate will be too low for
> audio using
> a socket like the one from the bt chat example.
>
> Kris
>
> On Wed, Apr 6, 2011 at 1:53 PM, Aditya Singal 
> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I am trying to implement a walkie talkie set between two  android
> > mobile phones using bluetooth connection. But I am not sure how to
> > send audio data as a stream through bluetooth. So far I am trying to
> > use media recorder to capture audio.
>
> > mRecorder = new MediaRecorder();
> >        mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
>
> > mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
> >        mRecorder.setOutputFile(mFileName);
> >        mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
>
> > This is part of the code that I took from android.com. I believe that
> > this will simply save the sound file at path specified by "mFileName"
> > however I wish to transmit it through bluetooth instead of saving it.
>
> > Aditya
>
> > --
> > 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

-- 
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: Bluetooth Walkie Talkie

2011-04-14 Thread Aditya Singal

I am working on it as course project, there is no practical use as of
now.. :)

On Apr 14, 7:44 pm, Streets Of Boston  wrote:
> Unless your app is a test-project, i don't see much use in your app.
> You'd be better of just talking to each other, because you will be no more
> than about 10 meters (30 feet) from each other. Blueotooth's range is about
> 10 meters...

-- 
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] Bluetooth Walkie Talkie

2011-04-06 Thread Aditya Singal
Hi,

I am trying to implement a walkie talkie set between two  android
mobile phones using bluetooth connection. But I am not sure how to
send audio data as a stream through bluetooth. So far I am trying to
use media recorder to capture audio.

mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
 
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

This is part of the code that I took from android.com. I believe that
this will simply save the sound file at path specified by "mFileName"
however I wish to transmit it through bluetooth instead of saving it.

Aditya

-- 
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