Hi, i’m trying to perform filter on a file from Android and play it real-time, but i can not manage to firstly play a .wav file that i passed from my kotlin code to work. Here’s my code:
extern "C" {
JNIEXPORT void JNICALL Java_com_juce_test_MainActivityKt_playAudio(JNIEnv *env, jclass clazz, jstring filePath) {
auto convertedPath = env->GetStringUTFChars(filePath, JNI_FALSE);
juce::String audioPath((juce::CharPointer_UTF8(convertedPath)));
juce::File audioFile(audioPath);
juce::AudioFormatManager formatManager;
formatManager.registerBasicFormats();
juce::AudioFormatReader *audioFormatReader(
formatManager.createReaderFor(audioFile));
std::unique_ptr<juce::AudioFormatReaderSource> tempSource(
new juce::AudioFormatReaderSource(audioFormatReader, true));
if (audioFormatReader != nullptr) {
auto *transportSource = new juce::AudioTransportSource();
transportSource->setSource(tempSource.get());
transportSource->setPosition(0.0);
transportSource->start();
}
env->ReleaseStringUTFChars(filePath, convertedPath);
}
}
I also checked that the juce::File does exists, the length of the audio is correct and isPlaying() return true. However no sound was playing, nothing appear in log console as well.
Appreciate any help. Thanks in advance