0
私は、元のTarsosDSPプロジェクトのフォークを使用してしばらく前にコード化したアコースティックチューナーを(再)作成しようとしています。今回は、JorenSixがAndroidプロジェクト用に更新したTarsosDSPを使用していますが、私のコードでは構造的に重要な変更はありませんでしたが、アプリケーションを実行しようとすると次のエラーが表示されます。Android用TarsosDSP AudioRecordオブジェクトがLibGDXプロジェクト内で初期化されていません
E/AudioRecord: AudioFlinger could not create record track, status: -1
E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -1.
E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
D/libEGL: eglTerminate EGLDisplay = 0x7f90cf2e28
E/AndroidRuntime: FATAL EXCEPTION: GLThread 2218
Process: com.fraserjohnstone.tuner, PID: 19923
java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.
at android.media.AudioRecord.startRecording(AudioRecord.java:943)
at be.tarsos.dsp.io.android.AudioDispatcherFactory.fromDefaultMicrophone(Unknown Source)
at com.fraserjohnstone.tuner.screens.TunerScreen.initTuner(TunerScreen.java:238)
at com.fraserjohnstone.tuner.screens.TunerScreen.show(TunerScreen.java:123)
at com.badlogic.gdx.Game.setScreen(Game.java:61)
at com.fraserjohnstone.tuner.screens.SplashScreen.goToTunerScreen(SplashScreen.java:148)
at com.fraserjohnstone.tuner.screens.SplashScreen.render(SplashScreen.java:131)
at com.badlogic.gdx.Game.render(Game.java:46)
at com.fraserjohnstone.tuner.Tuner.render(Tuner.java:73)
at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:459)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1649)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1354)
E/AndroidGraphics: waiting for pause synchronization took too long; assuming deadlock and killing
私は、コンストラクタから呼び出されるメソッドinitTuner()でチューナーを初期化しています:
private void initTuner(){
if(dispatcher == null){
//set initial tuner values
algo = PitchEstimationAlgorithm.FFT_YIN;
currentHertz = 440.00;
sampleRate = 44100;
bufferSize = 2048;
sampleOverlap = 1536;
offsetInCents = 0;
sharpOrFlat = "";
targetNote = "A";
targetRotation = 0;
dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(sampleRate, bufferSize, sampleOverlap);
PitchDetectionHandler printPitch = new PitchDetectionHandler() {
@Override
public void handlePitch(PitchDetectionResult pitchDetectionResult, AudioEvent audioEvent) {
double pitch = pitchDetectionResult.getPitch();
if(pitch != -1 && !audioEvent.isSilence(silenceThreshold)){
audioDetected = true;
currentHertz = pitch;
}
else{
audioDetected = false;
offsetInCents = 0.00;
}
}
};
AudioProcessor audioProcessor = new PitchProcessor(algo, sampleRate, bufferSize, printPitch);
dispatcher.addAudioProcessor(audioProcessor);
new Thread(dispatcher,"Audio Dispatcher").start();
}
}
そして、私のandroid manifestファイル:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fraserjohnstone.tuner"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="24" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/GdxTheme" >
<activity
android:name="com.fraserjohnstone.tuner.AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
ご協力いただければ幸いです。