FMOD Android: error 18, File not found

Hi, I am using FMOD for the first time. Facing some errors in code, seeking for help. ASAP
I have successfully imported audio from Android to FMOD native c++, added dsp filters and effects, Created the sound, Played the sound. Now it was time to SAVE the sound to android specific folder.
But I am getting an error while doing so.
When i put this Line of code:
result = system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT)

i get this error:
Error 18, File not found.

I created input sound file and output sound empty file path from Android side, and they do exists. Input is working fine but giving error on saving the file.
Need urgent help.

It sounds like the path for writing the output wav isn’t accessible.
What path are you giving to System::init?

Internally we take the path passed via extradriverdata and do the following:
mFP = fopen(mFileName, "wb");

As a test you could ensure that works before calling System::init?

Sorry, Don’t know much about FMOD, i tried following solution but didn’t work.

  1. Created File in android, Its visible in file manager now.
    mFileName = Environment.getExternalStorageDirectory().absolutePath + "/voiceChanger/savedRecording.wav

  2. Called Native C++ from android side and passed file parameter
    public static native void fix(String path);

  3. On Native side, got the path successfully and tried to save file in that path.

extern "C" JNIEXPORT void JNICALL my_function_fix(JNIEnv *env, jclass jcls, jstring path) {
//Attribute related to Path are posted Only
void *extraDriverData = NULL;
const char *path_cstr = env->GetStringUTFChars(path, NULL);
extraDriverData = *path_cstr;
system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT);
system->init(32, FMOD_INIT_NORMAL, extraDriverData);
}
Getting Error on System-init (18) File Not Found.
Can you please tell me what code to change with code eloboration.

Instead of calling system->init(32, FMOD_INIT_NORMAL, extraDriverData);

Try system->init(32, FMOD_INIT_NORMAL, (void *)path_cstr);

1 Like

With using this
system->init(32, FMOD_INIT_NORMAL, (void *)path_cstr);
File not found error is solved.
But this
system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT);
is producing 0kb file.
Then I tried using
system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER);
which is writing file first time successfully, next time android isn’t able to play file.

And is there any way to track progress while saving the file?

When using FMOD_OUTPUTTYPE_WAVWRITER_NRT, you need to call System::update for any mixing to happen, this is the non-realtime (NRT) component of wav writer. Each call to update will produce 512 samples of audio output. Using FMOD_OUTPUTTYPE_WAVWRITER internally a thread is created that will do the writing in real-time.

The file will be written synchronously with each mixer update, make sure you call System::release at the end to properly terminate the output file with the correct file length.

1 Like

ThankYou, @mathew.