Skip to content

Instantly share code, notes, and snippets.

@lattejed
Created January 6, 2014 05:32
Show Gist options
  • Save lattejed/8278706 to your computer and use it in GitHub Desktop.
Save lattejed/8278706 to your computer and use it in GitHub Desktop.
int fromPPQ15360TicksToSamples (int ticks, int tempo, int sampleRate)
{
// ticks -> samples
// 3.9025 = 60000 (milliseconds / min) / 15360 (ticks per quarter note)
return (3.9025 * sampleRate * ticks) / (double)tempo;
}
int fromSamplesToPPQ15360Ticks (int sampleOffset, int tempo, int sampleRate)
{
// samples -> ticks
// 3.9025 = 60000 (milliseconds / min) / 15360 (ticks per quarter note)
return (sampleOffset * tempo) / (3.9025 * sampleRate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment