问题
Hi all! Sorry in advance for my English. :)
I am trying to make an audio recognition app with Echoprint code. One instance works fine, but we would like to listen simultaneously with several AudioRecords. For example, instead of analyzing 20 seconds of a song for recognition, we would like to have, for example, 3 audio recorders with 3 matches to improve the results.
Ex. one listening from the 0s to 20s, another one listening from 0s to 10s and another one listening from 10s to 20s. That way we will have 3 matches-responses, which we expect will give us more accuracy or more possibilities of matching audio in a short time (we need to match in 5-15 seconds max).
The thing is, I have the code from http://masl.cis.gvsu.edu/2012/01/25/android-echoprint/ I have a class that calls a library who makes all. I tried to create in the class several threads, so everyone has his own instances of the library classes, but always fail in the instantiation of the second AudioRecord:
new AudioRecord(MediaRecorder.AudioSource.MIC,FREQUENCY, CHANNEL, ENCODING, minBufferSize);
If I put a sleep in the second thread, in order to let the first finish, all is okay. The problem is in that instantiation... the error is:
AudioRecord: Could not get Audio input for record source 1 AudioRecord: Error Creating AudioRecord instance: initialization check failed. AudioRecord: [ Android.media.AudioRecord ] Error code -20 when initializating native AudioRecord object
So, I have two questions:
One is if the problem is that it is not possible to listen simultaneously to several AudioRecords instances. Like if there were just one channel, device, input device, port or etc. to listen and if it is busy it crashes, until you make the audiorecord.release()? In both I was using mic and same channel....maybe that's the problem? If it's that...how do I do it properly?
Also I am in the emulator... in a real device it works but not in the emulator?
Best regards and truly thanks for all!
来源:https://stackoverflow.com/questions/12299214/is-it-possibly-to-have-sumultaneously-two-instances-of-audiorecord-with-echoprin