I like to do calculations using SMPTE timecode.
These are times using hours:minutes:seconds:frames
Frames are parts of a second. In my case they are always 25 frames in a second. 00~24
I want to do calculations like:
16:23:17:14 + 00:09:09:15
and the the result should be:
16:32:27:04
This macro so do the trick.
The calculations are complicated enough that it makes sense to me to do this in script, JXA in this case.
Please let us know if you have any further questions.
2018-03-20 22:25 GMT-0500
Version 1.1
Fixed Bug in secToSMPTE() function caused by JavaScript round-off error
Added Math Action option for "ADD" or "SUBTRACT"
Result TimeCode is now put on Clipboard
Example Output
MACRO: Add or Subtract SMPTE TimeCode Strings [Example]
#### DOWNLOAD:
<a class="attachment" href="/uploads/default/original/3X/e/d/ed0c186f09ab649120863a560641751334b07f37.kmmacros">Add or Subtract SMPTE TimeCode Strings [Example].kmmacros</a> (14 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**
---
### ReleaseNotes
Author.@JMichaelTX
**PURPOSE:**
* **Add SMPTE TimeCode Strings**
**REQUIRES:**
1. **KM 8.0.2+**
* But it can be written in KM 7.3.1+
* It is KM8 specific just because some of the Actions have changed to make things simpler, but equivalent Actions are available in KM 7.3.1.
.
2. **macOS 10.11.6 (El Capitan)**
* KM 8 Requires Yosemite or later, so this macro will probably run on Yosemite, but I make no guarantees. :wink:
**NOTICE: This macro/script is just an _Example_**
* It has had very limited testing.
* You need to test further before using in a production environment.
* It does not have extensive error checking/handling.
* It may not be complete. It is provided as an example to show you one approach to solving a problem.
**How To Use**
1. Trigger this macro.
* It will then Prompt you for TimeCode values and frame rate.
* Results will be shown in KM Display Window.
**MACRO SETUP**
* **Carefully review the Release Notes and the Macro Actions**
* Make sure you understand what the Macro will do.
* You are responsible for running the Macro, not me. ??
.
1. Assign a Trigger to this maro..
2. Move this macro to a Macro Group that is only Active when you need this Macro.
3. ENABLE this Macro.
.
* **REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:**
(all shown in the magenta color)
* Prompt for User Input: Conform/Change Default values
TAGS: @JXA @SMPTE @TimeCode @Date @Time
USER SETTINGS:
* Any Action in _magenta color_ is designed to be changed by end-user
ACTION COLOR CODES
* To facilitate the reading, customizing, and maintenance of this macro,
key Actions are colored as follows:
* GREEN -- Key Comments designed to highlight main sections of macro
* MAGENTA -- Actions designed to be customized by user
* YELLOW -- Primary Actions (usually the main purpose of the macro)
* ORANGE -- Actions that permanently destroy Variables or Clipboards,
OR IF/THEN and PAUSE Actions
**USE AT YOUR OWN RISK**
* While I have given this limited testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
* If you have any doubts or questions:
* **Ask first**
* Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.
---
![image|478x1448](upload://jIxOne9S5OarBuu5ooqUgNjc3tc.jpg)
Thanks a lot man! I will try to implement this in a macro i am thinking of. The goal is in ProTools to find a timecode spot within a file, so maybe i have to subtract instead of add, but i will puzzle on the script to see how to do that.
Just wow
questions? no, not yet!
After some tweaking it works here! So good!
I will make the macro better in the next days and later i’ll post it here.
I am making a macro for ProTools that will jump my cursor to a specific original timecode within an audiofile. This is something ProTools cannot do.
I just managed with the help from you!
My apologies for this bug. It was caused by a JavaScript round-off error, which I should have caught and fixed. The bug is now fixed.
I also added the Math Action option to "ADD" or "SUBTRACT" the timecodes.
Please give this a thorough testing, and let me know if you find any issues, or have any comments or suggestions.
It works here, i have to start using it for a while to find out how it performs in actual situations but it looks promising!
One question; I noticed that the variables you used get deleted after the whole macro is finished.
In the macro’s that i make the variables and their contend stay alive. They do fill up the memory a wee bit, but this way they can be used in other macro’s as well.
What makes it that the variables that i used in your script are deleted after the last action?
They are deleted because they are "Local" Variables, which you can identify because they have a prefix of "Local".
The script I wrote uses these Local variables. If you wish to retain the information for later use, the easiest thing to do is to add an Action that simply sets a Global Variable to the Local Variable.
I like to use the naming convention of "DND__" as a prefix for my Global Variables, which stands for "Do Not Delete", a reminder to me when viewing in the KM Preferences Variable pane.
Thank you @Fokke and @JMichaelTX for making this macro, Michael you are amazing, very neat this can be done.
I have uploaded a couple personal updates incase it helps anyone's workflow that comes across this. I am in America so 25 is not a frame rate I ever use. Not that 29.97 makes any sense for these calculations it works fine for this. Feel free of course to change to 24 or 30 or whatever.
The macro is designed to make text selections in another editor of a mix down (bounce) that has several songs in a single session. Give to a client/artist and have them give you time locations they want edits done. With this macro is helpful for finding where 2:30 seconds into a song is by placing your cursor at the start location of the mix down (which could be at any location other than 00:00:00:00) and finding the new location in the Pro Tools timeline.
Do note if you weren't aware that Pro Tools does allow you to just press
asterisk *
plus +
49
period .
enter
to add or (minus sign to subtract) from a current location. So for example if you were at 00:20:55:29 and ran the above you would then be at 00:21:44:29 which would be the same location as if you just ran this macro but with out all the steps. It does save you a little time but you have to highlight selections in your text document.
Keyboard Maestro 8.2 “Pro Tools - Using MS Word, MS Excel, TextEdit or Simple Edit Macros” Macro
Yes, i am aware of the fact that the main counter can be used as a calculator this way.
I needed a calculator like JMichaels made for me (us!) because i was looking for a method to jump to a user given ‘original timestamp’ position within a clip.