# How do i get ‘x’ number of calls to System::update?

**URL:** <https://qa.fmod.com/t/how-do-i-get-x-number-of-calls-to-system-update/18765>\
**Category:** FMOD Studio\
**Tags:** ios\
**Created:** [May 16, 2022, 4:54pm UTC](https://qa.fmod.com/t/how-do-i-get-x-number-of-calls-to-system-update/18765 "2022-05-16T16:54:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![FavoShuai](https://avatars.discourse-cdn.com/v4/letter/f/48db29/32.png) [@FavoShuai](https://qa.fmod.com/u/FavoShuai)\
**Post date:** [May 16, 2022, 4:54pm UTC](https://qa.fmod.com/t/how-do-i-get-x-number-of-calls-to-system-update/18765/1 "2022-05-16T16:54:41Z")

</div>

```
result = fmod_system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER);
fmod_system->setSoftwareFormat(48000, FMOD_SPEAKERMODE_DEFAULT, 0);
fmod_system->setDSPBufferSize(1024, 4);
result = fmod_system->getSoftwareFormat(&frequency, 0, 0);
result = fmod_system->getDSPBufferSize(&blocksize, &numblocks);
ms = (float)blocksize * 1000.0f / (float)frequency;
printf("numblocks = %d\n",numblocks); // 4
printf("blocksize = %d\n",blocksize); // 1024
printf("frequency = %d\n",frequency); // 48000
printf("Mixer blocksize = %.02f ms\n", ms); // 21.33ms
printf("Mixer Total buffersize = %.02f ms\n", ms * numblocks);
printf("Mixer Average Latency = %.02f ms\n", ms * ((float)numblocks - 1.5f));

result = fmod_system->init(32, FMOD_INIT_STREAM_FROM_UPDATE, cDest);
result = fmod_system->getMasterChannelGroup(&mastergroup);
result = fmod_system->createSound([[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], fileName] UTF8String], FMOD_DEFAULT, 0, &sound);
fmod_system->playSound(sound, mastergroup, false, &channel);
result = fmod_system->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT, &dsppitchshift);
result = mastergroup->addDSP(0, dsppitchshift);
result = dsppitchshift->setBypass(false);
dsppitchshift->setParameterFloat(FMOD_DSP_PITCHSHIFT_PITCH, 1.5);

unsigned int sound_pcmbytes = 0;
sound->getLength(&sound_pcmbytes, FMOD_TIMEUNIT_PCMBYTES); // 1046400

unsigned int sound_length = 0;
sound->getLength(&sound_length, FMOD_TIMEUNIT_MS); // 10900

// what to do next

```

// while (???) { // the number is (10900 / 21.3) + 1 ?  
// fmod\_system-\>update();  
// }

```
fmod_system->release();
```

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [May 17, 2022, 11:30pm UTC](https://qa.fmod.com/t/how-do-i-get-x-number-of-calls-to-system-update/18765/2 "2022-05-17T23:30:33Z")

</div>

Next thing to do is call `System::update` and sleep repeatedly in a while loop, and then sleep for a period of time. If you want it to play forever you could go:

```cpp
while (true) {
    fmod_system->update();
    usleep(50);
}

```

If you want 4 calls to `System::update`:

```cpp
for (int i = 0; i < 4; ++i) {
    fmod_system->update();
    usleep(50);
}

```

If you want it to run for approximately n milliseconds:

```cpp
int n_milliseconds = 4000; // 4s
int sleep_time = 50; // 50ms

while (n_milliseconds > 0) {
    fmod_system->update();
    usleep(sleep_time);
    n_milliseconds -= sleep_time;
}

```
