Send microphone input to programmer instrument

Hello,
I want to record microphone input and send it to a programmer instrument. So far I managed to get the input and send it in the actual programmer instrument BUT the sound cuts off when the programmer event reaches its end.

Looping the programmer event seems to call CREATE_PROGRAMMER_SOUND and DESTROY_PROGRAMMER_SOUND every loop iteration, which seem to stop the event momentarily causing stuttering.

Am I doing something wrong ? What is the proper way to send microphone input through a FMOD event ?

Here’s my code if it helps:
RECORD START

//create record sound
CREATESOUNDEXINFO createSoundInfo = new CREATESOUNDEXINFO();
createSoundInfo.cbsize = Marshal.SizeOf(typeof(CREATESOUNDEXINFO));
createSoundInfo.numchannels = _currentInputDriver.SpeakerModeChannels;
createSoundInfo.format = SOUND_FORMAT.PCMFLOAT;
createSoundInfo.defaultfrequency = _currentInputDriver.SystemRate;
createSoundInfo.length = (uint)(createSoundInfo.defaultfrequency * sizeof(float) * createSoundInfo.numchannels);
MODE recordMode = MODE.LOOP_NORMAL | MODE.OPENUSER;
FMODUnity.RuntimeManager.CoreSystem.createSound(“record”, recordMode, ref createSoundInfo, out _recordSound);

//create record event
_recordEvent = FMODUnity.RuntimeManager.CreateInstance(“event:/VOIP”);
_recordEvent.setCallback(VoipCallback);
_recordEvent.start();
_recordEvent.release();

//start recording
FMODUnity.RuntimeManager.CoreSystem.recordStart(_currentInputDriver.Index, _recordSound, true);

CALLBACK

switch (pCallbackType)
{
case EVENT_CALLBACK_TYPE.CREATE_PROGRAMMER_SOUND:
{
//get properties
PROGRAMMER_SOUND_PROPERTIES properties = (PROGRAMMER_SOUND_PROPERTIES)Marshal.PtrToStructure(pPropertiesPtr, typeof(PROGRAMMER_SOUND_PROPERTIES));
properties.sound = _recordSound.handle;
Marshal.StructureToPtr(properties, pPropertiesPtr, false);
}
break;

}

Is the programmer instrument in the Event marked as ‘Async’?

Yes. As soon as the sound loops once (it’s 1s long and loops forever) it calls the SOUND_STOPPED event and so the event is killed.

What version of FMOD are you using?

2.00.08, both Studio and Unity SDK, with Unity 2019.3.6f1 if that matters.