# Send microphone input to programmer instrument

**URL:** <https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554>\
**Category:** Unity\
**Created:** [March 18, 2020, 9:37pm UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554 "2020-03-18T21:37:20Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guiboune](https://avatars.discourse-cdn.com/v4/letter/g/977dab/32.png) [@Guiboune](https://qa.fmod.com/u/Guiboune)\
**Post date:** [March 18, 2020, 9:37pm UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/1 "2020-03-18T21:37:20Z")

</div>

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;
> 
> }

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [March 24, 2020, 3:03am UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/2 "2020-03-24T03:03:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Guiboune](https://avatars.discourse-cdn.com/v4/letter/g/977dab/32.png) [@Guiboune](https://qa.fmod.com/u/Guiboune)\
**Post date:** [March 24, 2020, 11:58am UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/3 "2020-03-24T11:58:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [March 24, 2020, 11:30pm UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/4 "2020-03-24T23:30:44Z")

</div>

What version of FMOD are you using?

---

<div class="post-metadata">

**Author:** ![Guiboune](https://avatars.discourse-cdn.com/v4/letter/g/977dab/32.png) [@Guiboune](https://qa.fmod.com/u/Guiboune)\
**Post date:** [March 24, 2020, 11:48pm UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/5 "2020-03-24T23:48:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [March 31, 2020, 4:03am UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/6 "2020-03-31T04:03:37Z")

</div>

What you will have to do is set the programmer instrument to async and looping and use a sustain point or loop (inside the instrument region). This will stop the instrument from being destroyed, but then you will need to make sure to clean up the event as it won’t end or release naturally.

---

<div class="post-metadata">

**Author:** ![amai](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@amai](https://qa.fmod.com/u/amai)\
**Post date:** [February 10, 2022, 6:43pm UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/7 "2022-02-10T18:43:58Z")

</div>

Hi. This is _exactly_ what I am trying to do, without success. I was wondering if you could answer some questions for me.

In this code, the callback function is set for a particular event instance, but as I understand, the named programmer instrument in FMOD already generates callback functions. I am getting the error “[FMOD] EventInstance::createProgrammerSoundImpl : Programmer sound callback for instrument ‘playRecording’ returned no sound.” How can I assign the recorded sound to the callback function for this programmer instrument without generating an instance of the event in the code? In general, I am confused about whether it is the _event_ that sends the callback or the _programmer instrument_.

Also, I see that you have named your sound “record”. Does this correspond to the name of the programmer instrument in FMOD? If not, where do you set the name of the programmer instrument in FMOD that this callback function corresponds to?

My goal is to record sound from the microphone, and then later trigger an event with a programmer instrument that plays back that sound through the routing and effects chains I have set up in my FMOD session. So far I have succeeded in recording and playing back sound with triggers in a Unity script, but I ideally would like to integrate the playback with FMOD for greater control using programmer instruments.

Thank you in advance for any help you can provide!

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [February 14, 2022, 10:30pm UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/8 "2022-02-14T22:30:48Z")

</div>

We have an example for programmer sounds in the API downloads and in the docs: [Unity Scripting Examples - Programmer Sounds](https://fmod.com/resources/documentation-unity?version=2.02&page=examples-programmer-sounds.html).

> [@amai](#):
>
> How can I assign the recorded sound to the callback function for this programmer instrument without generating an instance of the event in the code?

When you create and play an Event you will also need to assign the callback function for that event, when the callback function is called it is called from an existing Event instance. You can then access the instance and modify/control it from there.

> [@amai](#):
>
> Also, I see that you have named your sound “record”. Does this correspond to the name of the programmer instrument in FMOD? If not, where do you set the name of the programmer instrument in FMOD that this callback function corresponds to?

You don’t set a name for the programmer instrument in an Event, you set a callback for the Event and then you can check what is causing the callback from the function. ie. if you have multiple programmer sounds in a single event, they will all trigger the same callback function but you can determine when instrument has triggered it from the [`FMOD_STUDIO_PROGRAMMER_SOUND_PROPERTIES`](https://fmod.com/resources/documentation-api?version=2.02&page=studio-api-eventinstance.html#fmod_studio_programmer_sound_properties).

---

<div class="post-metadata">

**Author:** ![amai](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@amai](https://qa.fmod.com/u/amai)\
**Post date:** [February 15, 2022, 9:36pm UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/9 "2022-02-15T21:36:58Z")

</div>

Thanks so much for this explanation. I figured it out and now it is working great. 😁  
~andy

---

<div class="post-metadata">

**Author:** ![panpangou](https://avatars.discourse-cdn.com/v4/letter/p/8e7dd6/32.png) [@panpangou](https://qa.fmod.com/u/panpangou)\
**Post date:** [July 24, 2024, 6:41pm UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/10 "2024-07-24T18:41:05Z")

</div>

Hi there,

I know this is an old thread, but I was wondering if you could share your full script in terms of how to record into programmer instrument? I am having trouble understanding how to combine the recording scripts and programmer instrument script when it comes to that part. Am I recording into an FMOD Sound, which is then stored into the StreamingAssets folder, which is then being called by the programmer instrument?

Thank you so much!

---

<div class="post-metadata">

**Author:** ![Gazzor](https://avatars.discourse-cdn.com/v4/letter/g/e9a140/32.png) [@Gazzor](https://qa.fmod.com/u/Gazzor)\
**Post date:** [July 17, 2026, 6:10pm UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/11 "2026-07-17T18:10:11Z")

</div>

Did you ever get a script working for this?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [July 20, 2026, 6:26am UTC](https://qa.fmod.com/t/send-microphone-input-to-programmer-instrument/15554/12 "2026-07-20T06:26:20Z")

</div>

We have a [Record - Scripting Example](https://www.fmod.com/docs/2.03/unity/examples-record.html) which demonstrates how to record continuously and play back the same data in Unity specifically.
