audio recording - how can i change frequency of recorded sound in android -
i developing android application records through mic , changes frequency. similar helium booth app iphone. time being have written code record file , save in sdcard. question can change frequency of sound while recording? or can set frequency in audio should recorded. following code:
public class mainactivity extends activity { mediarecorder recorder; file audiofile = null; private static final string tag = "soundrecordingactivity"; private view startbutton; private view stopbutton; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); startbutton = findviewbyid(r.id.start); stopbutton = findviewbyid(r.id.stop); startbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { try { startrecording(v); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } }); stopbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { stoprecording(v); } }); } public void startrecording(view view) throws ioexception { startbutton.setenabled(false); stopbutton.setenabled(true); file sampledir = environment.getexternalstoragedirectory(); try { audiofile = file.createtempfile("sound", ".3gp", sampledir); } catch (ioexception e) { log.e(tag, "sdcard access error"); return; } recorder = new mediarecorder(); recorder.setaudiosource(mediarecorder.audiosource.mic); recorder.setoutputformat(mediarecorder.outputformat.three_gpp); recorder.setaudioencoder(mediarecorder.audioencoder.amr_nb); recorder.setoutputfile(audiofile.getabsolutepath()); recorder.prepare(); recorder.start(); } public void stoprecording(view view) { startbutton.setenabled(true); stopbutton.setenabled(false); recorder.stop(); recorder.release(); addrecordingtomedialibrary(); } protected void addrecordingtomedialibrary() { contentvalues values = new contentvalues(4); long current = system.currenttimemillis(); values.put(mediastore.audio.media.title, "audio" + audiofile.getname()); values.put(mediastore.audio.media.date_added, (int) (current / 1000)); values.put(mediastore.audio.media.mime_type, "audio/3gpp"); values.put(mediastore.audio.media.data, audiofile.getabsolutepath()); contentresolver contentresolver = getcontentresolver(); uri base = mediastore.audio.media.external_content_uri; uri newuri = contentresolver.insert(base, values); sendbroadcast(new intent(intent.action_media_scanner_scan_file, newuri)); toast.maketext(this, "added file " + newuri, toast.length_long).show(); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; }}
Comments
Post a Comment