title: compare two sounds in android
body: <p>I am using <a href="https://code.google.com/p/musicg/" rel="nofollow">musicg</a> library for comparing between two audio sounds. One of them is saved before and the another is detected by recording. 
  musicg  library have <a href="https://code.google.com/p/musicg/downloads/detail?name=musicg_android_demo.zip&amp;can=2&amp;q=" rel="nofollow">whistle</a> demo; which I edited it to be works as I want.the problem is when I want to convert the detected sound [ which is a buffer ] to wav and get a fingurprint for it , it return nullpointerexption. </p>
  
  <p>this is in MainAcivity.java<br>
  <i></p>
  
  <blockquote>
    <p>public static Wave w1;</p>
    
    <p>InputStream sw1 = getBaseContext().getResources().openRawResource(R.raw.top_of_the_world_rec);</p>
    
    <p>w1=new Wave(sw1);</p>
  </blockquote>
  
  <p></i></p>
  
  <p>and this in a DetectorThread.java 
  <i></p>
  
  <pre><code>                InputStream obj = new ByteArrayInputStream(buffer);
                  Wave woo = new Wave(obj);
                  if (woo.toString() == null)
                      Log.i("", "recoded sound  is null");
                  if (MainActivity.w1.toString() == null)
                      Log.i("", "the detected sound is null");
                  try {
                      similarity = woo.getFingerprintSimilarity(MainActivity.w1);/// this couse null pointer exption
                      Log.i("", "1-" + similarity); // not appear
                      if (similarity == null) {  // not enter this if at all ~!
                          Log.i("", "lolol" + similarity);
                          TheSemilarityISnull = true;
                      }
                  }
                  catch (NullPointerException n) {
                      Log.i("", "first error");
                      TheSemilarityISnull = true;
                  }
                  // EnD of addition
  
                  Log.i("", "2-" + similarity); //appear 2-null
                  // byte[] io = MainActivity.w1.getFingerprint(); // good no problem
                  // Log.i("", "00-"+io); // apear bk09823 like this
                  try {
  
                      Log.i("", "0-");
                      byte[] po = woo.getFingerprint(); // ~&gt; this couse null pointer exption
                      Log.i("", "0-" + po);
                      if (po == null)
                          Log.i("", "fingurprint for detected  sound is null ");//not appear
                      byte[] io = MainActivity.w1.getFingerprint();
                      Log.i("", "00-" + io);
                      if (io == null)
                          Log.i("", "fingurprint for recorded sound is null");//not appear
                      double scoure = new FingerprintSimilarityComputer(po, io).getFingerprintsSimilarity().getSimilarity();
  
                  } catch (Exception e) {
                      Log.i("", "second error ");
                  }
  </code></pre>
  
  <p></i></p>
  
  <p>so ;</p>
  
  <p>1-how to convert Byte[] to wav  ?</p>
  
  <p>2-and can I call class or Mothed inside thread ? 
  Becouse I wonder that every time I call one of them it does not detect anything ! </p>
  
  <p>3- I do not edit the record thread at all> is that will couse problem ? 
  please help me. </p>