Answered
0
0

Hi, Guys.
Sorry for my poor English.
I come across a problem. I have an app that attempting to record sounds through microphone.but I found that it can’t work well.And here is my code:

public void OnRecordClick(GameObject go)
 {
    FMOD.RESULT m_Result;

    if (Application.platform == RuntimePlatform.Android)
    {
        FMODUnity.RuntimeManager.LowlevelSystem.setOutput(FMOD.OUTPUTTYPE.OPENSL);
    }

     CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO();
     exinfo.cbsize = Marshal.SizeOf(exinfo);
     exinfo.numchannels = 1;
     exinfo.format = SOUND_FORMAT.PCM16;
     exinfo.defaultfrequency = 44100;
     exinfo.length = (uint)(exinfo.defaultfrequency * exinfo.numchannels*sizeof(short))*8;

     FMOD.MODE soundMode = MODE.OPENUSER | MODE.LOOP_NORMAL ;
     m_Bytes = new byte[exinfo.length + 1];

     m_Result = FMODUnity.RuntimeManager.LowlevelSystem.createSound(m_Bytes, soundMode, ref exinfo, out m_Sound);

    if (m_Result != FMOD.RESULT.OK)
     {
         UnityEngine.Debug.Log("failed to createSound:" + m_Result);
         return;
     }

     FMOD.RESULT result = FMODUnity.RuntimeManager.LowlevelSystem.recordStart(0, m_Sound, true);

    if (result != FMOD.RESULT.OK)
    {
        UnityEngine.Debug.Log("failed to startrecord:" + result);         
    }else
    {
        m_isrecording = true;
        UnityEngine.Debug.Log("OnRecordClick" + result);
    }
}

I have alreay added “android.permission.RECORD_AUDIO”to the “AndroidManifest.xml” file.

When runnint the function: LowlevelSystem.recordStart the result it that “failed to startrecord:ERR_INVALID_PARAM”.

what is more, the fmod.log info as follow:

[LOG] AsyncThread::threadFunc : Finished Asynchronous operation on sound 0000000021A36B48
[LOG] SoundI::getSubSound : sound 0000000021A36B48. Subsound index 0 / 1
[LOG] SystemI::updateRecordCache : Enumerating 2 record drivers
[LOG] SystemI::updateRecordCache : 0. Found record driver: ‘S/PDIF (M-Audio Delta AP 192)’
[LOG] SystemI::updateRecordCache : 1. Found record driver: ‘Line 1/2 (M-Audio Delta AP 192)’
[LOG] SystemI::createSoundInternal : filename = : mode 00000402
[LOG] SystemI::createSoundInternal : exinfo->cbsize = 232
[LOG] SystemI::createSoundInternal : exinfo->numchannels = 1
[LOG] SystemI::createSoundInternal : exinfo->defaultfrequency = 44100
[LOG] SystemI::createSoundInternal : exinfo->format = 2
[LOG] SystemI::createSoundInternal : Format has 0 subsounds.
[LOG] SystemI::createSoundInternal : Create as FMOD_CREATESAMPLE
[LOG] SystemI::createSoundInternal : creating subsound 0/0
[LOG] SystemI::createSample : mode 00000402 length 0 samples, lengthbytes 0
[LOG] SystemI::createSample : channels = 1
[LOG] SystemI::createSample : output = 00000000217C76A8
[LOG] OutputSoftware::createSample : lengthpcm 0, lengthbytes 0, channels 1, format 2, freq 44100, mode 0000040a
[LOG] SystemI::createSoundInternal : No name found in file, use filename.
[LOG] SystemI::createSoundInternal : done. OpenState now = FMOD_OPENSTATE_READY.

[ERR] SystemI::recordStart : Invalid sound, must be an FMOD::Sound with positive length created as FMOD_CREATESTREAM.
c:\jk\workspace\Build__1.8__UnityLibs_Win\lowlevel_api\src\fmod_system.cpp(1265) : [LOG] FMOD_RESULT = 31 — An invalid parameter was passed to this function.
[LOG] SystemI::mixerSuspend : Suspending output.
[LOG] SystemI::mixerResume : Resuming output.

I’m entirely unsure what else to do. Help?

  • You must to post comments
Best Answer
0
0

This has been fixed in a patch since 1.08.04, updating to the latest 1.08 version will solve the issue.

  • boluns

    thanks for your help!

    I upgrade to the latest FMOD Unity Integration fmodstudio10904_v2.unitypackage.

    And the recordStart function works well on the windows platform.

    But thrown out an error: FMOD.RESULT.ERR_INTERNAL when running on the android platform.

  • boluns

    oh, It’s my fault.I forget to add the ” android.permission.RECORD_AUDIO ” to the AndroidManifest.xml. Sorry.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.