# The problem of sound delay in record.cpp

**URL:** https://qa.fmod.com/t/the-problem-of-sound-delay-in-record-cpp/13757
**Category:** FMOD Engine
**Created:** [March 14, 2018, 1:52am UTC](https://qa.fmod.com/t/the-problem-of-sound-delay-in-record-cpp/13757 "2018-03-14T01:52:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![yourk](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yourk](https://qa.fmod.com/u/yourk)
#### Post date: [March 14, 2018, 1:52am UTC](https://qa.fmod.com/t/the-problem-of-sound-delay-in-record-cpp/13757/1 "2018-03-14T01:52:14Z")

</div>

Hello, I am using record.cpp demo to develop record sound function, the record code is right running and my headphone also and listen playback, but, these is a serious problem, the playback sound is about 10% delay compare to my recording voice, it result in my record music experience is disorder, some relate code is underline:

```
        lastPlayPos = playPos;
        samplesPlayed += playDelta;

        /*
            Compensate for any drift.
        */
        int latency = samplesRecorded - samplesPlayed;
        actualLatency = (0.97f * actualLatency) + (0.03f * latency);

        int playbackRate = nativeRate;
        if (actualLatency < (int) (adjustedLatency - driftThreshold)) {
            /* Play position is catching up to the record position, slow playback down by 2% */
            playbackRate = nativeRate - (nativeRate / 50);
        } else if (actualLatency > (int) (adjustedLatency + driftThreshold)) {
            /* Play position is falling behind the record position, speed playback up by 2% */
            playbackRate = nativeRate + (nativeRate / 50);
        }

        channel->setFrequency((float) playbackRate);
        ERRCHECK(result);

```

Is someone has met such problem? hope you can tell me how to adjust the playback delay, it is appreciate！

---

<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 18, 2018, 11:04pm UTC](https://qa.fmod.com/t/the-problem-of-sound-delay-in-record-cpp/13757/2 "2018-03-18T23:04:04Z")

</div>

Do you get the delay when using the example without any changes?  
Are you using a bluetooth headset?  
What version of FMOD are you using?
