You Are Here:

Community: Developer Discussion Boards

#1 Old Exclamation how to save captured audio ? - 2008-10-03, 13:33

Join Date: Oct 2008
Posts: 2
rohinanand
Offline
Registered User
i have the code for real time play back of audio being captured but i am unable to save it ... can some one please suggest me how to save the recorded data in amr or wav format .

the code follows -------->
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.control.RecordControl;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class Rec3 extends MIDlet implements CommandListener
{
private Form init = new Form("info");
private Command rec = new Command("rec",Command.OK, 1),
stop = new Command("stop",Command.STOP, 0),
exit = new Command("exit",Command.EXIT, 0);
private byte[] recordedSoundArray;
private Player p;
private RecordControl rc;
private ByteArrayOutputStream output;

public void startApp()
{
init.addCommand(rec);
init.addCommand(stop);
//init.addCommand(exit);
init.setCommandListener(this);
Display.getDisplay(this).setCurrent(init);

}

public void pauseApp()
{
}

public void destroyApp(boolean unconditional)
{
}

class dorecord extends Thread
{
public void run(){

try {

init.append("record voice ...\n\n");
// Create a Player that captures live audio.
p = Manager.createPlayer("capture://audio?encoding=pcm&rate=1000&bits=8");
p.realize();
// Get the RecordControl, set the record stream,
rc = (RecordControl)p.getControl("RecordControl");
output = new ByteArrayOutputStream();
rc.setRecordStream(output);
rc.startRecord();
p.start();




} catch (Exception ioe)
{
init.append(ioe.toString());
}
}
}

class stopplay extends Thread{
public void run(){

try
{
init.append("finish record... starting playback\n\n");
rc.stopRecord();
rc.commit();
p.stop();
p.close();

init.append("playing...\n");
recordedSoundArray = output.toByteArray();
init.append("recorded sound = " +String.valueOf(recordedSoundArray.length)+"\n\n");
ByteArrayInputStream recordedInputStream = new ByteArrayInputStream(recordedSoundArray);
Player p2 = Manager.createPlayer(recordedInputStream,"audio/x-wav");
p2.prefetch();
p2.start();
//init.append("finish playing...");
}
catch (Exception e) {
init.append("stop command: "+e.toString());

}

}

}


public void recordaud()
{
new dorecord().start();
}
public void stopplaying()
{
new stopplay().start();
}

public void commandAction(Command com, Displayable dis)
{
if(com == exit)
notifyDestroyed();
else if(com == stop)
{
init.removeCommand(stop);
init.addCommand(exit);
stopplaying();
}
else if(com == rec)
{
recordaud();
}

}
}
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Save audio for object, not memory card faran12 Python 7 2008-10-02 15:27
how to save captured video Mr.Developer Mobile Java Media (Graphics & Sounds) 11 2007-09-26 17:42
Open audio from an URL and save it laurapanizo Symbian Media (Graphics & Sounds) 0 2006-06-08 12:34
Half Duplex Audio Streaming subhrajyotisaha Symbian Media (Graphics & Sounds) 0 2006-05-25 05:39
save an audio file from message elena_santander General Symbian C++ 0 2003-11-20 13:50

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ