TimeCode
TimeCode 1.0.1
The TimeCode class provides methods to calculate Time Code values for film, video and audio applications. It supports all current frame rates including NTSC with Drop Frame.
Download class and sample project
http://www.belle-nuit.com/download/timecode.sit.hqx
TimeCode works with REALBasic 2.1 or later. It is self-contained and works with both 68k and PowerPC. It should work on Windows, but it hasn't been tested for.
Methods
TimeCode()
TimeCode(fpsin as double)
Initializes the TimeCode class. You should call this method in the open event of your window, if you drag an instance directly to the window in the IDE. It sets the following default values
- fps 25.0 (if fpsin is not provided)
- Pulldown false
- Gauge 35
It also resets the Error and the Errormessage, so you might call this method after an error. The Class has written with Error handling, so you shouldn't get Runtime exceptions when you provide unvalid values. When the input values are invalid, the output is set to 0 or "". You can check for error with the Error method and check for an eventually errormessage.
Error() as boolean
If an error has occurred, you have to reset the class with TimeCode before doing further calculations
Errormessage() as string
Fps() as double
returns current frame rate
fps(f as double)
sets current frame rate. Allowed are values from 1 to 99 frames per second. fps 29.97 automatically enables Drop Frame mode.
Function Gauge() as integer
return current Gauge
Gauge(g as integer)
sets current Gauge. Allowed are 16 and 35. Gauge is used in the Meter, the Feet and the Keyframe functions.
Pulldown() as boolean
returns current pulldown status
Pulldown(p as boolean)
sets current pulldown status. Pulldown is used by the Keycode functions
Function IsTC(TC as integer) as boolean
True if TC is a valid timecode.
- TC is not null
- TC is positive
- TC is less than 24:00:00:00
FramesToTC(frames as integer) as integer
TCtoFrames(TC as integer) as integer
TCtrans(TC as integer, FromFps as double, ToFps as double) as integer
Translates from one frame rate to another based on the frame number.
TCtoText(TC as integer) as string
Time Code values are treated as numbers in this class. This functions adds the colons for proper formatting. It uses the "00:00:00:00" for all frame rates, except for 29.97 where its uses "00:00:00;00"
TextToTC(text as string) as integer
Parses a time code string to a Time Code value which can be used as an argument for the Time Code functions. Allowed separators are ":", ";" and "."
TCtoTime(TC as integer) as date
Returns the TimeCode as time of the day 1.1.1904
TimeToTC(d as date) as integer
Returns the timepart of the date as timecode.
TCplus(TC1 as integer, TC2 as integer) as integer
TCminus(TC1 as integer, TC2 as integer) as integer
TCmult(TC as integer,m as double) as integer
=TCdiv(TC as integer, d as double) as integer
=TCsum(TCarray() as integer) as integer
The sum-function adds each value of the array.
TC3edit(edit() as integer)
Returns the 4th editing point when 3 points are provided.The edit array must have exactely 4 values: SourceIn, SourceOut, RecordIn,RecordOut. If all values are different from zero, then RecordOut is calculated.
FeetToFrames(feet as integer) as integer
FeetToTC(feet as integer) as integer
FramesToFeet(frames as integer) as integer
TCtoFeet(TC as integer) as double
Feet is formatted like feet.frames. 16.08 means 16 feet, 8 frames. In 35 mm, 1 feet has 16 frames, in 16mm 1 feet has 35 frames.
FramesToMeter(frames as integer) as double
MeterToFrames(m as double) as integer
MeterToTC(m as double) as integer
TCToMeter(TC as integer) as double
Meter is formatted like meter.cm
FramesToKey(frames as integer, prefix as string) as string
KeyOffset(keycode as string, frames as integer) as string
KeyPrefix(keycode as string) as string
KeyTCOffset(keycode as string, TC as integer) as string
KeyToFrames(keycode as string) as integer
KeyToTC(keycode as string) as integer
TCtoKey(TC as integer, prefix as string) as string
The Keycode functions use the Keycode format: prefix+feet+"+"+frames. In 35mm, one feet has 16 frames, in 16mm Keycode one feet has 20 frames (not 40).
Function About() as string
Returns an about-string of the class.
Function Methods() as string
Returns a string with the definitions of the methods.
Function Properties() as string
Returns a string with the definitions of the properties.
Function Version() as string
Returns the current version of the class.
Properties
This class does not have any public property.
Technical comment
The TimeCode class is an extended port of the Excel Time Code extension to REALbasic. You can find more information about the Time Code on the TC.XLA-page.
Terms of use / Disclaimer
© Belle Nuit Montage / Matthias Bürcher April 2000. All rights reserved. Written in Switzerland.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Comments please to matti@belle-nuit.com
The latest version is available at http//www.belle-nuit.com/
History
14.11.00 1.0.1 fixed bug in drop,undrop and h24 which caused errors in drop frame calculations.
8.6.00 Released as open source
6.5.00 Release TimeCode 1.0