# Audio artifacts when playing audio generated via code

**URL:** <https://qa.fmod.com/t/audio-artifacts-when-playing-audio-generated-via-code/22880>\
**Category:** FMOD Engine\
**Tags:** unity, csharp\
**Created:** [May 5, 2025, 1:56am UTC](https://qa.fmod.com/t/audio-artifacts-when-playing-audio-generated-via-code/22880 "2025-05-05T01:56:40Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [May 15, 2025, 5:05am UTC](https://qa.fmod.com/t/audio-artifacts-when-playing-audio-generated-via-code/22880/4 "2025-05-15T05:05:05Z")

</div>

Thank you for the project, it greatly helped in testing!

Some things I tested:

- Artifacts
  - Moved the `CaptureFrame()` function from `Update()` to `FixedUpdate()` to remove the dependence on frames.
  - Decreased the size of the default `DSP Buffer Length` ([Unity Integration | Settings DSP Buffer Length Settings](https://fmod.com/docs/2.02/unity/settings.html#dsp-buffer-settings)), I tested `256`.

- Latency
  - Reducing the size of the buffer created in the `exinfo`  
`exInfo.length = SampleRate * PCMMultiplier;`, I tested halving this value.

Another option maybe using a `FMOD_SOUND_PCMREAD_CALLBACK` ([FMOD Engine | Core API Reference - FMOD\_SOUND\_PCMREAD\_CALLBACK](https://fmod.com/docs/2.02/api/core-api-sound.html#fmod_sound_pcmread_callback)) which would further decouple the recording from the frame rates and more closely attach it to the FMOD system.

> [@hardsmoke](#):
>
> In my 4th question I mean that if a freeze occurs when starting playback (to debug it can use method with ContextMenu attribute - it will cause the game freeze), then the playback delay will increase - this is solved by compensating for the delay, you just need to wait a while.

Thank you for the explanation.

Let me know if that makes a difference!

---

_[View the full topic](https://qa.fmod.com/t/audio-artifacts-when-playing-audio-generated-via-code/22880)._
