I'm currently trying to make my Android application based on frequencies work but I encounter some issues with speakers. In fact, I obtained three different results, depending of the method I use. Here are the methods, and the result for a 440 Hz sound (A for audiophiles) :
- Method 1 : I use my voice directly in the application.
Result : Method 1 Result
Average Frequency : 443 Hz. Good result.
- Method 2 : I record my voice through the default Android recording application, add this file in my application Firebase database and play it with my application.
Result : Method 2 Result
Average Frequency : 224 Hz. Frequencies are divided by 2 ?!
- Method 3 : I play a 440 Hz sound found on Youtube with my laptop and record it directly with my application.
Result : Method 3 Result
Average Frequency : 886 Hz. Frequencies are multiplied by 2 now ?!
- Method 4 : Same method as the second one but I don't use the default Android recording application. I use EasyVoiceRecorder where I can configure the sample rate (I put 44 kHz) and the encoding (I put .wav).
Result : Method 4 Result
Average Frequency : 431 Hz. Good result.
Additional informations :
- To save the files in Firebase database as WAV files, I use AndroidAudioConverter library in order to not manipulate different audio formats and take advantage of WAV headers informations.
- I use AudioTrack and AudioRecord classes and then Fast Fourier Transform to get the main frequencies every 128 ms. AudioRecord is configured with 44.1 kHz sample rate, AudioFormat.CHANNEL_IN_MONO and AudioFormat.ENCODING_PCM_16BIT. AudioTrack is configured according to WAV header file information.
- When I play sounds located in raw application folder, frequencies result is perfect.
I don't really see the point in sharing the code of my application because as I showed you, it doesn't work only if I use third-party devices (default recording application, laptop, ...), so it must be a hardware issue. But if you need some code pieces, ask me and I will give them to you.
Thanks for reading, thanks in advance for your help and... happy coding ! :D