I often struggle to decide whether a class member should be a property or a method.
The driving thought behind this decision was that it kept the class memory footprint much smaller, and I think calculations are much simpler this way. My fields are "totalFrames" and "frameRate", as opposed to a field for "hours", "minutes", "seconds", "frames", and "frameRate".
#Timecode calculator windows software
Private static int FramesPerDay(short framesPerSecond)Īlthough I've been doing software development for a couple of years, I still wrestle over what I feel are simple decisions when it comes to things like class design, so I'm hoping to ask a few questions about my class and hope that someone can re-assure or advise otherwise. Return timecodeA.TotalSeconds() >= timecodeB.TotalSeconds() Public static bool operator >=(Timecode timecodeA, Timecode timecodeB) Return timecodeA.TotalSeconds() > timecodeB.TotalSeconds() Public static bool operator (Timecode timecodeA, Timecode timecodeB) Return new Timecode(timecodeA.totalFrames - frames, ameRate) Public static Timecode operator -(Timecode timecodeA, int frames) Int totalFramesB = timecodeB.totalFrames Int totalFramesA = timecodeA.totalFrames Throw new InvalidOperationException("Cannot subtract two timecodes with different framerates.") Public static Timecode operator -(Timecode timecodeA, Timecode timecodeB) / If the second timecode has fewer frames than the first, it is presumed to have rolled over the 24 hour mark and therefore be conceptually greater than the first. Return new Timecode(timecodeA.totalFrames + frames, ameRate) Public static Timecode operator +(Timecode timecodeA, int frames) / Adds a given number of frames to the timecode. Return new Timecode(timecodeA.totalFrames + timecodeB.totalFrames, ameRate) Throw new InvalidOperationException("Cannot add two timecodes with different framerates.") Public static Timecode operator +(Timecode timecodeA, Timecode timecodeB) Return new Timecode(hours, minutes, seconds, frames) Int frames = int.Parse(captureGroups.Value) Int seconds = int.Parse(captureGroups.Value) Int minutes = int.Parse(captureGroups.Value) Int hours = int.Parse(captureGroups.Value) GroupCollection captureGroups = TimecodeRegex.Match(timecodeStr).Groups Public static Timecode Parse(string timecodeStr, short framerate = 25) / Parses a timecode string of the format "hh:mm:ss:ff". / The total number of frames in one day, for this timecode's framerate. Private static string PadTimecodeUnit(int unit, int places = 2) / Pads a number for display in a timecode string. Return (float)this.totalFrames / (float)ameRate / The total number of seconds in this timecode. / The total number of frames for this timecode. Return (int)this.totalFrames / ameRate % 60 Return (int)this.totalFrames / ameRate / 60 % 60 Return (int)this.totalFrames / ameRate / 60 / 60 Public Timecode(int totalFrames, short frameRate = 25) Private static readonly Regex TimecodeRegex = new RegexOptions.Compiled | RegexOptions.ExplicitCapture) / Represents a timecode in hh:mm:ss:ff format. The "timecode" that I'm trying to represent is a timecode that is used in video editing quite often, and is seen displayed in the format "hh:mm:ss:ff", or 10:00:05:24, for example ("ff" = frames").
#Timecode calculator windows code
Time code operations include adding, subtracting, multiply and dividing and time code types can be switch during operations without losing the current frame value.įilm 24 (720/1080p 24, p 23.98, psf 24, psf 23.98, 2K, 4K)ĭF 29.97 (NTSC, 720/1080i 29.97, 30, 59.94, 60) Time codes can be displayed as frame values or standard time code strings. It supports all the major frame rates (23.98, 24, 25, 29.97, 30, 50, 59.94 and 60) as well as drop and not drop frame time codes. TcCalc is a film and video time code/timecode calculator.