Re: R: Re: Re: [android-developers] Searching for Vumeter or needle indicator

2012-08-27 Thread IronBlossom
YOUR  
AudioRecord.getMinBufferSize(SAMPPERSEC,channelConfiguration,audioEncoding);  
returns -2 value which crashes while allocation of buffer = new 
short[buffersizebytes];

Can you Explain the reason?

On Saturday, May 22, 2010 11:23:34 AM UTC+6, BobG wrote:

 try this, turn on audio record permission 

 package com.aiti.vumeter; 
 //vumeter 
 //May 21 2010 Bob Gardner at aol.com 

 import java.util.Timer; 
 import java.util.TimerTask; 

 import android.app.Activity; 
 import android.content.Context; 
 import android.graphics.Canvas; 
 import android.graphics.Color; 
 import android.graphics.Paint; 
 import android.media.AudioFormat; 
 import android.media.AudioRecord; 
 import android.os.Bundle; 
 import android.os.SystemClock; 
 import android.util.DisplayMetrics; 
 import android.view.View; 
 import android.widget.TextView; 

 public class vumeter extends Activity { 
 public AudioRecord audioRecord; 
 public VuView vuview; 
 public Timer timer; 
 public int channelConfiguration = 
 AudioFormat.CHANNEL_CONFIGURATION_MONO; 
 public int audioEncoding = AudioFormat.ENCODING_PCM_16BIT; 
 public int mSamplesRead;//how many samples read 
 public int buffersizebytes; 
 public int buflen; 
 public int scrwidth; 
 public int scrheight; 
 public int cursamprate; 
 public final int SAMPPERSEC = 48000; //samp per sec 8000, 11025, 
 22050 44100 or 48000 
 public float vin;//input volts 
 public float iavg;   //avg of input volts 
 public float ipk;//peak input volts 
 public float isum;   //sum of ans of input volts 
 public float idbavg; //db below 0 of avg input volts 
 public float idbpk; 
 public float pixperdb; 
 public float pixperdiv; 
 public final float rangedb=60.0f; 
 public final float dbperdiv=3.0f; 
 public final float barwid=30f; 
 public float scrbot; 
 public long t1,t2,dt, t3,t4,dt2; 
 public short[] buffer; //+-32767 

 /** Called when the activity is first created. */ 
 @Override 
 public void onCreate(Bundle savedInstanceState){ 
 super.onCreate(savedInstanceState); 
 //  setContentView(R.layout.main); 
 DisplayMetrics metrics = new DisplayMetrics(); 
 getWindowManager().getDefaultDisplay().getMetrics(metrics); 
 scrwidth=metrics.widthPixels;   // 
 scrheight=metrics.heightPixels; // 
 scrbot=scrheight-100; //480-100-380 
 pixperdb=scrbot/rangedb;  //380/60-5 
   pixperdiv=dbperdiv*pixperdb; //3*5-15 

 buffersizebytes = 
 AudioRecord.getMinBufferSize(SAMPPERSEC,channelConfiguration,audioEncoding); 
 // 
 4096 on ion 
 buffer = new short[buffersizebytes]; //4096 
 buflen=buffersizebytes/2;//2048 
 audioRecord = new 
 AudioRecord(android.media.MediaRecorder.AudioSource.MIC,SAMPPERSEC, 
 channelConfiguration, audioEncoding, 
 buffersizebytes); //constructor 
 cursamprate=audioRecord.getSampleRate(); 
 vuview = new VuView(this); 
 setContentView(vuview); 

 timer = new Timer(); 
 timer.schedule(new TimerTask(){ 
 @Override 
 public void run(){ 
 TimerMethod(); 
 } 
 }, 0, 200); //every 200 ms 
 //trigger(); //grab samples and calc db 
 }//oncreate 

 private void TimerMethod(){ 
 //This method is called directly by the timer 
 //and runs in the same thread as the timer. 
 //We call the method that will work with the UI 
 //through the runOnUiThread method. 
 this.runOnUiThread(Timer_Tick); 
 } 

 private Runnable Timer_Tick = new Runnable(){ 
 public void run() { 
 //This method runs in the same thread as the UI. 
 //Do something to the UI thread here 
 trigger(); 
 } 
 }; 

 //-- 
 public void acquire(){ 
 try { 
 audioRecord.startRecording(); //48khz 
 } catch (Throwable t) { 
 //  Log.e(AudioRecord, startrecording Failed); 
 } 
 //SystemClock.sleep(50L);   //one period of 20 hz 
  mSamplesRead = audioRecord.read(buffer, 0, buflen); 
  try{ 
audioRecord.stop(); 
  } catch (Throwable t) { 
 //   Log.e(AudioRecord, stoprecording Failed); 
  } 
 } 

 //--- 
 public void avg(){ 
 int i; 
 float ftmp; 

 ipk=0f; 
 isum=0f; 
 for(i=0; i  buflen; i++){  //2048 samples 
 vin=(float)buffer[i];   //get a sample 
 ftmp=Math.abs(vin); //abs of 

[android-developers] Re: Anyone has expereiences in developing an audio visualizer?!

2012-08-27 Thread IronBlossom
Try using android.media.audiofx.Visualizer from APi 9 or above

On Monday, July 12, 2010 12:56:01 PM UTC+6, CMF wrote:

 Seems that there is no API in doing the audio visualizer?

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

Re: [android-developers] Confirmation when mail has been sent

2012-05-30 Thread IronBlossom
Same issue , just the difference is intent type, 
(intent.setType(application/*), because im sending email with attachments 
(pdf or zip). But my problem is with the attachment.The Intent.EXTRA_STREAM 
read from sdcard but after sending the mail i want to delete it from 
sdcard. So i used startActivityForResult and onActivityResult i delete that 
file from sdcard. Everything works well except the received mail has no 
attachment(not even the file name with 0 size). Think the sending process 
done by some other thread rather than a UI thread. and the deletion task is 
done from the UI thread even before the sending process is complete.

On Wednesday, September 29, 2010 5:07:07 PM UTC+6, Mark Murphy wrote:

 On Wed, Sep 29, 2010 at 7:02 AM, Amit amitmishr...@gmail.com wrote:
  When the user has actually send the mail, I want to know whether the
  mail has been sent or not?

 Sorry, but that is not part of the ACTION_SEND system, as far as I know.

 -- 
 Mark Murphy (a Commons Guy)
 http://commonsware.com | http://github.com/commonsguy
 http://commonsware.com/blog | http://twitter.com/commonsguy

 Android Training in London: http://skillsmatter.com/go/os-mobile-server



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

Re: [android-developers] Avoiding onItemSelected calls during initialization

2012-05-25 Thread IronBlossom
*Your event handler doesn't run during initialization. It runs on the**
first layout* 

New to android. Facing the same problem on spinner, but what do you mean by 
first layout? Is there any relationship with XML layout or you mean the 
first spinner.setOnItemSelectedListener(null)? 






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