neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
facebook::util Namespace Reference

Classes

struct  flicks_hash
 

Typedefs

using flicks = std::chrono::duration< std::chrono::nanoseconds::rep, std::ratio< 1, 705600000 > >
 

Functions

constexpr double to_seconds (const flicks ns)
 
constexpr flicks to_flicks (const double s)
 
template<class Rep , class Period >
constexpr flicks flicks_cast (const std::chrono::duration< Rep, Period > in_duration)
 

Variables

constexpr flicks k_flicks_zero_seconds
 Useful constants.
 
constexpr flicks k_flicks_one_second
 
constexpr flicks k_flicks_one_twenty_fourth_of_second
 
constexpr flicks k_flicks_one_ninetieth_of_second
 
constexpr flicks k_flicks_min_time { std::numeric_limits<flicks::rep>::min() }
 

Typedef Documentation

◆ flicks

using facebook::util::flicks = typedef std::chrono::duration<std::chrono::nanoseconds::rep, std::ratio<1, 705600000> >

A flick (frame-tick) is a very small unit of time. It is 1/705600000 of a second, exactly. This unit of time is the smallest time unit which is LARGER than a nanosecond, and can in integer quantities exactly represent a single frame duration for 24hz, 25hz, 30hz, 48hz, 50hz, 60hz, 90hz, 100hz, 120hz, and also 1/1000 divisions of each. This makes it suitable for use via std::chrono::duration and std::ratio for doing timing work against the system high resolution clock, which is in nanoseconds, but doesn't get slightly out of sync when doing common frame rates.

In order to accomodate media playback, we also support some common audio sample rates as well. This list is not exhaustive, but covers the majority of digital audio formats. They are 8kHz, 16kHz, 22.05kHz, 24kHz, 32kHz, 44.1kHz, 48kHz, 88.2kHz, 96kHz, and 192kHz. While humans can't hear higher than 48kHz, the higher sample rates are used for working audio files which might later be resampled or retimed.

The NTSC variations (~29.97, etc) are actually defined as 24 * 1000/1001 and 30 * 1000/1001, which are impossible to represent exactly in a way where 1 second is exact, so we don't bother - they'll be inexact in any circumstance.

1/24 fps frame: 29400000 flicks 1/25 fps frame: 28224000 flicks 1/30 fps frame: 23520000 flicks 1/48 fps frame: 14700000 flicks 1/50 fps frame: 14112000 flicks 1/60 fps frame: 11760000 flicks 1/90 fps frame: 7840000 flicks 1/100 fps frame: 7056000 flicks 1/120 fps frame: 5880000 flicks 1/8000 fps frame: 88200 flicks 1/16000 fps frame: 44100 flicks 1/22050 fps frame: 32000 flicks 1/24000 fps frame: 29400 flicks 1/32000 fps frame: 22050 flicks 1/44100 fps frame: 16000 flicks 1/48000 fps frame: 14700 flicks 1/88200 fps frame: 8000 flicks 1/96000 fps frame: 7350 flicks 1/192000 fps frame: 3675 flicks

Definition at line 59 of file flicks.h.

Function Documentation

◆ flicks_cast()

template<class Rep , class Period >
constexpr flicks facebook::util::flicks_cast ( const std::chrono::duration< Rep, Period >  in_duration)
inlineconstexpr

Convert a regular duration to flicks

Definition at line 90 of file flicks.h.

◆ to_flicks()

constexpr flicks facebook::util::to_flicks ( const double  s)
inlineconstexpr

Convert doubles (as seconds) to flicks

Definition at line 83 of file flicks.h.

◆ to_seconds()

constexpr double facebook::util::to_seconds ( const flicks  ns)
inlineconstexpr

Convert flicks to seconds as doubles

Definition at line 77 of file flicks.h.

Variable Documentation

◆ k_flicks_min_time

constexpr flicks facebook::util::k_flicks_min_time { std::numeric_limits<flicks::rep>::min() }
constexpr

Definition at line 73 of file flicks.h.

◆ k_flicks_one_ninetieth_of_second

constexpr flicks facebook::util::k_flicks_one_ninetieth_of_second
constexpr
Initial value:
{
std::chrono::duration_cast<flicks>(
std::chrono::duration<flicks::rep, std::ratio<1, 90>>{1}) }

Definition at line 70 of file flicks.h.

◆ k_flicks_one_second

constexpr flicks facebook::util::k_flicks_one_second
constexpr
Initial value:
{
std::chrono::duration_cast<flicks>(std::chrono::seconds{ 1 }) }

Definition at line 65 of file flicks.h.

◆ k_flicks_one_twenty_fourth_of_second

constexpr flicks facebook::util::k_flicks_one_twenty_fourth_of_second
constexpr
Initial value:
{
std::chrono::duration_cast<flicks>(
std::chrono::duration<flicks::rep, std::ratio<1, 24>>{1}) }

Definition at line 67 of file flicks.h.

◆ k_flicks_zero_seconds

constexpr flicks facebook::util::k_flicks_zero_seconds
constexpr
Initial value:
{
std::chrono::duration_cast<flicks>(std::chrono::seconds{ 0 }) }

Useful constants.

Definition at line 63 of file flicks.h.