我想比较两个音频文件,所以我正在使用库musicg。但我得到一个错误“WaveHeader:只支持bitsPerSample 8或16”
代码:
String root = getExternalFilesDir(null).toString();
Log.i(TAG, root);
String bell1 = "bell1.wav";
String bell2 = "DOORBELL-3_SPLITTED.wav";
String fullPath1 = root + File.separator + bell1;
String fullPath2 = root + File.separator + bell2;
Log.i(TAG, "Full Path 1: " + fullPath1);
Log.i(TAG, "Full Path 2: " + fullPath2);
File f = new File(fullPath2);
Log.i(TAG, "" + f.canRead());
Wave b1 = new Wave(fullPath1);
Wave b2 = new Wave(fullPath2);
我收到了以下错误。
StackTrace:
11-25 00:17:08.597: I/MainActivity(26472): /storage/sdcard0/Android/data/com.musicg.demo.android/files
11-25 00:17:08.597: I/MainActivity(26472): Full Path 1: /storage/sdcard0/Android/data/com.musicg.demo.android/files/bell1.wav
11-25 00:17:08.597: I/MainActivity(26472): Full Path 2: /storage/sdcard0/Android/data/com.musicg.demo.android/files/DOORBELL-3_SPLITTED.wav
11-25 00:17:08.597: I/MainActivity(26472): true
11-25 00:17:08.602: W/System.err(26472): WaveHeader: only supports bitsPerSample 8 or 16
11-25 00:17:08.602: W/System.err(26472): Invalid Wave Header
11-25 00:17:08.602: I/MainActivity(26472): Length : 0.25
11-25 00:17:08.602: I/MainActivity(26472): Size : 48001
11-25 00:17:08.602: I/MainActivity(26472): Length : NaN
11-25 00:17:08.602: D/AndroidRuntime(26472): Shutting down VM
11-25 00:17:08.602: W/dalvikvm(26472): threadid=1: thread exiting with uncaught exception (group=0x41e542a0)
11-25 00:17:08.612: E/AndroidRuntime(26472): FATAL EXCEPTION: main
11-25 00:17:08.612: E/AndroidRuntime(26472): java.lang.NullPointerException
11-25 00:17:08.612: E/AndroidRuntime(26472): at com.musicg.wave.Wave.size(Wave.java:255)
11-25 00:17:08.612: E/AndroidRuntime(26472): at com.musicg.demo.android.MainActivity$ClickEvent.onClick(MainActivity.java:139)
11-25 00:17:08.612: E/AndroidRuntime(26472): at android.view.View.performClick(View.java:4261)
11-25 00:17:08.612: E/AndroidRuntime(26472): at android.view.View$PerformClick.run(View.java:17356)
11-25 00:17:08.612: E/AndroidRuntime(26472): at android.os.Handler.handleCallback(Handler.java:615)
11-25 00:17:08.612: E/AndroidRuntime(26472): at android.os.Handler.dispatchMessage(Handler.java:92)
11-25 00:17:08.612: E/AndroidRuntime(26472): at android.os.Looper.loop(Looper.java:137)
11-25 00:17:08.612: E/AndroidRuntime(26472): at android.app.ActivityThread.main(ActivityThread.java:4921)
11-25 00:17:08.612: E/AndroidRuntime(26472): at java.lang.reflect.Method.invokeNative(Native Method)
11-25 00:17:08.612: E/AndroidRuntime(26472): at java.lang.reflect.Method.invoke(Method.java:511)
11-25 00:17:08.612: E/AndroidRuntime(26472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
11-25 00:17:08.612: E/AndroidRuntime(26472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
11-25 00:17:08.612: E/AndroidRuntime(26472): at dalvik.system.NativeStart.main(Native Method)