Thursday, December 10, 2015

nano seconds

This week, struggling with time and synchronisation in the digital world, the author attempts a more academic ramble on the topic of audio production in search of literary avenues of maturation.

Tick

A computer is essentially a clock.

A conductor of an orchestra not so much.

When a computer is asked to generate an output signal at 60 hertz in order for our eyes to receive messages encoded in light it needs to use a period of 16 and a bit milliseconds between frames.

Another name for that particular bit is the vulgar fraction  in which a lone binary or decimal variable no matter how large can ever hope to represent with 100% accuracy.

In terms of audio the frequency is typically 44.1 khz which gives us a period of .02 milliseconds. 

Interestingly for those looking to synchronise audio and video updates, 735 samples of audio are required to accompany each frame when delivering 60 fps content.


Tock

Earlier this year I learned from Oculus Chief Scientist Michael Abrash that the modelling of light is significantly simpler than that of sound and unlike our optical receptors our listening holes operate on a higher plane. 

The implication here is that quality simulation in audio can represent an emotional and temporal connection with the listener via a nearly direct path to the conscious mind.

The work involved to feeding a signal of air pressure to our ears as convincing as the pixels hitting our eyeballs has in fact only just begun.

Since dawn of information age,  ray-tracing begat caustic global illumination begat light field rendering begat the wonders that is OToy

Ping

The term latency refers to the delay between transmission and reception. Typically it is regarded in units of time. A useful conversion when considering audio timing is that of distance.

Compared to light travelling at 3.0e8 meters per second, audio from speaker to ear travels at the more pedestrian 340 meters per second.

The lag from sitting 1meter away from your loud speakers is 3 milliseconds an easy number to remember when calculating the depth of cave, tunnel and canyon while shouting the word "echo!" at the top of one's voice.

The lag of an electron with a round trip of 4e7 meters to traverse the planet is 133 milliseconds.

In terms of conversation, the global village is only 45 meters in distance and audibly in theory is close to that of a single football field.

In terms of gaming, that is like 3 button presses away.

For musical and arcade dimensions the global village concept needs to be reduced from playing field to cricket pitch.

One hopes that magnetic attraction can afford a break with 3e8 constraint as we mine the galaxy for rare earth metals.

Pong

Aha

In an Xcode window behind my current Chrome session sits the decimated remains of Port Midi.

Decimation is a term for culling 1 in ten, popular with mafia digits and roman war dice.

It is a possibly a sane limit when refactoring any source file or project tree.

After sleeping on issues of units of time, I have had a quick peek at the remains and become quite irritated with the timestamp issue.



My clock source is a Yamaha QX7 Digital Sequence Recorder.

As master midi clock, it sends 24 pulses per beat and features a large rotary dial to control beats per minute. The output shows nano converted timestamp and jitter which is based on standard deviation from the tempo computed in nanoseconds.

If we trust the QX7 as a reliable clock we theorise midi plus usb plus operating system is causing on average .3 millisecond noise in the source. Linux testing will commence shortly...


As a lover of triplets I need to remind myself that this for purposes of synchronisation not quantisation.

Detecting such noise when using the midi bus for other purposes will also be of great value.

Denominator

The story of a Tool support band having mixing desk set to master clock causing main desk to crash on cue live every night 27:02 minutes into main act is a soul destroying reminder of digital clock skew.

A computer using a single variable to compute time is a dangerous simplification.

As didactic binary stupification continues and the analog world fades from grasp time now requires vulgar fraction friendly denominator based timestamps.

It is intended that denominators be accompanied by timebase attribute for beat, 24th, decimate etc.

Numerator

Unlike the denominator the numerator is expected to be integer.

int64_t numerator;
double denominator;

Just like nano meter measurements are required to locate a single sample on path of holes along CD spiral it is decided that instead of 32 bit milliseconds being the unit of interval, a combination of 64 bit numerator and 53 bit denominator should be a solid basis from which to tick our tocks.



"Bloody Hard"
- Satoshi Nakamoto