fbpx
Skip to main content

MIDI Forum

Calculate absolute ...
 
Notifications
Clear all

Calculate absolute time from PPQ and ticks?

4 Posts
2 Users
0 Reactions
14.8 K Views
Jonas
Posts: 207
Reputable Member
Topic starter
 

I decided to use PPQ afterall to be able to change tempo and maybe later export as midi here is an imported JSON event.
{
"duration": 1.2000000000000028,
"durationTicks": 1920,
"midi": 53,
"name": "F3",
"ticks": 34560,
"time": 21.599999999999998,
"velocity": 0.6614173228346457
},
But it was a long time since i programmed it, i basicly forgotten how.
Lets say our ppq "parts per quarter" is 960.

So 4 * 960 is one bar 3850?

Lets say i have BPM is 100 for the note that is "2400 ms timelapse" in one bar?
But i am not sure i understand the millisecond calculation, although i can see how it is done.
60/100=0,6 seconds/beat to get it milliseconds * 1000 gives us 600 but why would that be a quarter note?
600*4=2400 someone that understand notes maybe can explain?

So to calculate number of bars 34560/3850 = 8,976623376623377 bars?

To get the time we take a bar 2400 * 8,976623376623377=21 543,8961038961‬ ms

Is it that simple is there just a rounding error above in the JSON, or is it maybe the realtime recording?
Well i think it is correct but maybe someone else interested in doing some javascript, it is much easier when writing things down.

Jonas T

 
Posted : 28/11/2019 4:03 am
Clemens Ladisch
Posts: 323
Reputable Member
 

One beat is a quarter note, and a pulse is a tick, so with 100 BPM and 960 PPQ, you have 100 × 960 = 96000 ticks per minute. This is 96000 / 60 = 1600 ticks per second.
So the time, in seconds, is 34560 / 1600 = 21.6 s; the duration is 1920 / 1600 = 1.2 s.

A "quarter note" is just used as a unit of time, and not necessarily related to actual notes or bars in the song.

(MIDI files actually do not use BPM but a tempo value measured in microseconds per quarter note, i.e., BPM = 1000000 × 60 / tempo, or tempo = 1000000 × 60 / BPM.)

Please note that the tempo/BPM can change at any time, so you should compute all times relative to the last event. (See How to correctly convert MIDI ticks to milliseconds? for details.)

 
Posted : 28/11/2019 11:46 pm
Jonas
Posts: 207
Reputable Member
Topic starter
 

???

if you have 100 beat / minute, each beat is 0.6 seconds or 600 ms.

Npw PPQ means part per quarter. there is 4 quarters in one full note right?

That means
960*4=3840
ticks in a full bar 4/4 right?
Isn't ticks = PPQ meaning "parts/partitions/ticks" per quarter note, not "parts/ticks" per minute????

?????100 BPM and 960 PPQ, you have 100 × 960 = 96000 ticks per minute?????????????

60/2.4=25 bars per minute.
And each bar is 3840 ticks so 25*3840=96000
So what you say is correct, but i do not get how, are you saying you can always multiply PPQ and BPM to get ticks per minute?

That a PPQ is partitioning number of the beat, i can see its turn out correct but i don't understand why?
OK i am a bit daft now i see a PPQ is simply a quarter note of 0.6 seconds in example and we have 100 of quarter notes with 960 ticks in a minute.

Case solved.

PS Why isn't it called QPM instead of BPM if a beat always correspond to a quarter note?
Well i guess BPM is an old term, but then why not call PPQ for PPB less confusion?

 
Posted : 29/11/2019 4:27 am
Clemens Ladisch
Posts: 323
Reputable Member
 

The SMF specification itself is internally consistent because it uses "quarter note" for both values, PPQ and tempo (= μs per quarter).

"BPM" is just a historically-grown term that happens to be easier to handle for humans, but who cares about those? 😉

 
Posted : 30/11/2019 10:31 pm
Share: