I am using musicg library for comparing between two audio sounds. One of them is saved before and the another is detected by recording. musicg library have whistle 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.
this is in MainAcivity.java
public static Wave w1;
InputStream sw1 = getBaseContext().getResources().openRawResource(R.raw.top_of_the_world_rec);
w1=new Wave(sw1);
and this in a DetectorThread.java
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(); // ~> 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 ");
}
so ;
1-how to convert Byte[] to wav ?
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 !
3- I do not edit the record thread at all> is that will couse problem ? please help me.