How can i get a sample accurate clock?
If i call System::getDSPClock, it increments in 1024 sample chuncks.
Is it possible, that the clock increments each sample?

I call the getDSPClock in an endless loop with sleep(15).
time.mHi is always 0
and time.mLo increments with 1024 steps.

  • You must to post comments

extern FMOD_RESULT FMOD_OS_Time_GetMs(unsigned int *ms);


  • You must to post comments

The DSP clock will increment in chunks of the size set by setDSPBufferSize (which defaults to 1024 on many platforms), each chunk is 1 mix of the DSP tree. You can of course schedule using setDelay the exact sample you wish, but the clock always increments in chunks.

FMOD_OS_Time_GetMs is an internal function that we don’t expose. It simply calls a platform specific time function such as timeGetTime, or queryPerformanceCounter, this is not sample accurate.

  • You must to post comments

thanks, but i have still the problem to trigger my samples excactly at 1 specific tick.

a short explanation about my use case:
I have a step sequencer with 16 steps. If i have for example 120 BPM, 1 step is 1378,13 samples.
So 1 cycle is 16 * 1378,13 = 22050 samples.
I will check at each sampleStepSize (1378, 2756,..) if the step is selected.
If the step is selected i will trigger the selected sample immediately.

What you you think about my idea?
If the BPM is changing(e.g. at application start) i assign the sample StepSizes to a vector 2D.
e.g.: audioBufferSize = 4096 , BPM = 120 , sampleStepSize = 1378

chuncksize 0  = 1378, 2756
chuncksize 4096 = 4134, 5512, 6890
 ....till sampleStepSize = 22050

then i have a reference channel with a reference sound file(silent file)
i like to to trigger that sound in the width of the sampleStepSize.
if this channel is playing the stepCounter can be Iteraterd, and make at this time a Hittest.
If the step is selected trigger the sound immediatly.
if stepCounter > 16, i reset the counter, currentBufferSize and stepCounter.

The following code is more or less sample code:
counter = 0;
currentBufferSize = 0

Uint64P m_masterClock;
Utils::ERRCHECK(m_system->getDSPClock(&m_masterClock.mHi, &m_masterClock.mLo));
if(m_masterClock.Lo % m_audioBufferSize == 0){

   for (i = 0; i < vector[counter].size(); i++{
          sampleOffset = vector[counter][i] -  currentBufferSize;                 
          m_channel[i]->setDelay(FMOD_DELAYTYPE_DSPCLOCK_START,0, sampleOffset);
          Utils::ERRCHECK(m_system.playSound(FMOD_CHANNEL_FREE, m_soundRef, true, &m_channels[i]));
   counter ++;
   currentBufferSize += m_audioBufferSize;    


// iterate to the channels and ask if it is playing
// if it is playing iterate the stepCounter
for (int i = 0; i < m_channels.size(); i++){
bool isplaying;
if (isplaying){
//check patterns if step ist Triggered comes here
if (hittest == True){
pattern.triggerSound(); //plays the sound immediatly
stepCounter ++;
if (stepCounter > 16){
counter = 0;
currentBufferSize = 0;
stepCounter = 0;

What are you thinking about my idea?
Better suggestions to achieve a stepSequencer behaviour?

Thanks in advance!

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.