tags:

views:

20

answers:

0

i am capturing sound in J2me and send these bytes to remote system, i then play these bytes on remote system.five second voice is capture and send to remote system. i get the repeated sound again .i am making a sound messenger please help me where i am doing wrong i am using the follown code.

String remoteTimeServerAddress = "192.168.137.179";
sc = (SocketConnection) Connector.open("socket://"
    + remoteTimeServerAddress + ":13");
p = Manager.createPlayer(
    "capture://audio?encoding=pcm&rate=11025&bits=16&channels=1");
p.realize();
RecordControl rc = (RecordControl) p.getControl("RecordControl");
ByteArrayOutputStream output = new ByteArrayOutputStream();
OutputStream outstream = sc.openOutputStream();
rc.setRecordStream(output);
rc.startRecord();
p.start();
int size = output.size();
int offset = 0;
while (true) {
    Thread.currentThread().sleep(5000);
    rc.commit();
    output.flush();
    size = output.size();
    if (size > 0) {
        recordedSoundArray = output.toByteArray();
        outstream.write(recordedSoundArray, 0, size);
    }
    output.reset();
    rc.reset();
    rc.setRecordStream(output);
    rc.startRecord();
}