Auto4 kara-templater

From Aegisub Wiki

Jump to: navigation, search

This page is a work in progress for drafting specs on the Automation 4 karaoke templating script. It might later also be the base for some real documentation for it.

Please put comments, suggestions, flames and questions on the discussion page.

Contents

[edit] Concept

  • Generally inspired by Auto3 multi-template
    • Intended to replace not just multi-template but also simple-k-replacer and line-per-syllable
    • But much more flexible than any of those
    • And can combine both kinds of effects in one "package"
  • Template lines can define output for one or more "classes" of input
    • Classes can be syllable, furigana, line-build and pre-line-build
    • The line-build and pre-line-build classes (similar to simple-k-replacer) can not be combined with other classes however
  • Templates can have modifiers that change their functionality in some ways
    • For example, repeat n times, include syllable text or not, only for specific inline-fx etc.
    • Not every modifier works with every class
  • There will also be code templates, templates that don't output any text but instead execute some Lua code on specific events
    • The events most coincide with the template classes, except for line-build and pre-line-build, and two additional are added, run-once and per-line.
    • Run-once events will be run before any processing is done on the subs, per-line is done before processing on a line is started (ie. per-line still mostly coincides with line-build)
  • The order templates and code lines are executed in should be well-defined for all cases
  • The original \k-timed karaoke will not be removed but will just be marked as comments, and given a special tag in the Effect field, similarly template-generated lines will get a tag in the Effect field
    • If run on subs that have commented-out and tagged \k-timed karaoke that will be used as base for generating effects
    • Before anything is done, all generated-effect-tagged lines are removed from the subs
    • Template and code definition lines are always left alone
    • Result is that you can repeatedly run the script over some subs without the file changing, unless the templates have been modified in the meantime
    • Effect development cycle:
      1. Time karaoke
      2. Write initial templates
      3. Apply templates
      4. Preview
      5. Modify templates
      6. Apply again and repeat

[edit] Sample and implementation

Useless "sample" script used for original drafting: on SVN

Current implementation: on SVN

Except implementation to be unstable and buggy and very much incomplete.

[edit] Template classes

These generate lines in the output.

The Effect field starts with "template", a space and the name of one or more classes, separated with spaces. Effectively, this can only be used to combine syl and furi classes.

[edit] line and pre-line

Replacement for simple-k-replacer, but allowing for more complex effects.

These two classes are exclusive with all other, they can not be combined. (You cannot combined line with pre-line either.)

pre-line generates some text in front of the line.

line generates some text in front of each syllable on the line, replacing the \k-tag.

They take an optional name identifier. This makes it possible to have a pre-line and line template both build on the same line. Similarly, two or more line templates can also build on the same line.

[edit] syl

Line-per-syllable effect, similar to old multi-template.

The syl class is used for a template if no other classes are specified.

[edit] furi

Per-furigana effects, generates virtual syllables from furigana timed syllables; generated lines use a different, generated style so the effect-writer doesn't have to bother with font-scaling issues

  • Really no issues? How about cases where the text must be compressed?
    • Text is never compressed with new furigana engine, so problem.

[edit] Code lines

These run Lua code blocks.

[edit] once

The "once" identifier is optional but recommended.

Code in this class is run before any lines are processed.

[edit] line

Code in this class is run before per-syllable processing starts for a line, during the same time line and pre-line templates are applied.

[edit] syl and furi

Code in these classes are run at the same times templates in those classes are run.

[edit] Modifiers

[edit] loop n, repeat n

loop and repeat are synonyms.

Takes a single number as argument. The number specifies the number of times the template should be applied.

A counter variable is accessible, named j in the execution environment. (This is not a $-variable.)

No indefinite looping as in multi-template, probably. The number of loop iterations is constant for a template.

For line/pre-line, multiple output lines are produced. Ie. output is "N x (input1 + input2 + input3)" instead of "N x input1 + N x input2 + N x input3". This means the template execution order is different.

Also works on code lines.

[edit] multi

Use multi-highlight instead of single-highlight. (See furigana karaoke syntax page.)

Not compatible with line/pre-line templates.

Also works on code lines.

[edit] char

Makes the effect do per-character processing instead of whole-syllable processing. Properly handles UTF-8 ie. processes each Unicode character as one unit, but is not aware of text layout issues such as ligatures and complex text shaping.

Not compatible with line/pre-line templates.

Does not work (and would not make sense) on code lines.

[edit] notext

The original text for the syllable is not inserted.

Good for putting drawings or other generated stuff in place of the syllable.

The original text is still accessible through a variable.

Exclusive with keeptags.

Doesn't make sense on code lines.

[edit] all

Apply template to any style, not just the one of the defining line.

Also works on code lines.

[edit] fx inlinefx

Only apply to syllables with inline-fx inlinefx.

Incompatible with line and pre-line. (I think...)

[edit] noblank

Skip "blank" syllables when applying this effect.

"Blank" syllables are those with zero-timing or consisting only of whitespace characters.

Might not make sense for pre-line and line. Usually not for furi either, but only because the case of blank furi shouldn't happen in normal timings.

Should also work on code lines.

[edit] keeptags

Original override tags are kept in the output text.

Exclusive with notext.

Has no effect when used with pre-line, furi and char classes.

Doesn't make sense on code lines.

[edit] fxgroup groupname

Declares the template to be in fxgroup groupname, which can then be enabled/disabled in code lines.

The tenv.fxgroup table is used to enable/disable fxgroups. Also see below.

Templates not in an fxgroup are always enabled.

Can be combined with all other modifiers and works with all template classes.

Unavailable on code lines.

[edit] Template variables and inline code

The inline code delimiter has changed from %% (percent signs) to !! (exclamation marks.) Reason for this is that the percent sign has various significant meanings in Lua code, but the exclamation mark doesn't have any such meanings. It should also be exceedingly rare anyone will ever want to use a literal exclamation mark anywhere.

The convention of "put return in front unless a literal return is found in code block" is gone. A return is always prepended now.

  • For conditional statements, use the and and or operators. Eg. syl.duration>150 and "kf" or "k"
  • For changing line timings and other fancy stuff, define a function in a code template and call that, have it return an empty string. (Or nil/false.)
  • Other use-cases that might be broken with this?

Dollar-sign is still used to mark variable names. The character set used to grab variable names has been extended with the underscore character.

All user code (inline or on code lines) is run in an environment separate from the main execution environment. This separate execution environment is shared between all user code.

[edit] Dollar-variables

The dollar-variables are defined by varctx in kara-templater.lua. Since varctx is not available to the template code execution environment, dollar-variables can not be added or modified by template code.

It's important to understand that all dollar-variables are expanded before any template code blocks are run, so for example while using the retime() function does update the line.duration field it has no effect on what $ldur expands to, because by the time retime() is called all the dollar-variables have already been expanded.

Also, all positioning information stored in dollar-variables is rounded to nearest integer. On the other hand, positioning information stored in tenv is not rounded and has sub-pixel precision.

All in all, dollar-variables are often only useful for the simpler cases.

Line-specific variables
layer line layer
lstart, lend, ldur, lmid line start time, end time, duration and midway, all absolute times in milliseconds
style name of the line style
actor name of the line actor
margin_l, margin_r effective left and right margin (line if nonzero, otherwise style)
margin_v, margin_t, margin_b effective vertical, top and bottom margin, vertical and top is same
syln number of syllables on line
li line index (first physical line in file is 1)
lleft, lcenter, lright line left, horizontal center and right edges, taking margins and alignment into account, rounded to an integer value
ltop, lmiddle, lbottom line top, vertical middle and bottom edges, taking margins and alignment into account, rounded
lx, ly line x and y position suitable for a \pos command when alignment is not overridden
lwidth, lheight line width and height in pixels, this is rounded and might not match exactly with the positioning variables
Syllable-specific variables
sstart, send, smid syllable start, end and midway times relative to start of line, suitable for putting into \t and \move
sdur, skdur syllable duration in milliseconds and centiseconds
si syllable index from start of line
sleft, scenter, sright absolute left, horizontal center and right edges for syllable from left edge of screen, suitable directly for \pos and \move
sbottom, smiddle, stop absolute bottom, vertical middle and top edges for syllable from top edge of screen, suitable directly for \pos and \move, adjusted for furigana positioning if needed
sx, sy syllable absolute x and y position in default alignment, suitable for using directly in \pos and \move
swidth, sheight syllable width and height in pixelsthis is rounded and might not match exactly with the positioning variables
Line/syllable context variables
These variables change meaning depending on the context, but should have the most meaningful value possible depending on the class of the template (meaning syllable-context most of the time)
start, end, mid start and and midway time for line/syllable; absolute for lines and relative for syllables
dur, kdur duration in milliseconds and centiseconds of line/syllable
i line or syllable index
left, center, right left, center and right edges of line/syllable, absolute from left screen edge
top, middle, bottom top middle and bottom edges of line/syllable, absolute from top screen edge
x, y x and y position of line/syllable when using default alignment
width, height width and height of line/syllable in pixels, this is rounded and might not match exactly with the positioning variables

[edit] Things available in the template execution environment

As noted above, template code is run with a different environment (global namespace) than the regular Lua global namespace. This is done to avoid polluting the global namespace of the kara-templater script itself with user variables and similar, and to avoid inadvertent modifications that could make kara-templater break.

The "mother namespace" kara-templater itself is running in is still available, though, so it can be accessed if needed.

The following fields exist in the template execution environment (tenv) by default:

  • _G - Reference to the "mother environment" of kara-templater itself.
  • tenv - Self-reference to the tenv, ie. tenv.tenv == tenv.
  • math - The Lua math library.
  • string - The Lua string library.
  • meta - Subtitle file meta information (script resolution mainly)
  • orgline - Original line, the one templates are running for right now, it's a bad idea to modify this.
  • line - For templates, the new line being generated; this can freely be modified during templates. For code lines, this is the original line and should not be modified.
  • syl - The syllable templates are running for right now, this can be a pseudo-syllable if the multi or char modifiers are used.
  • basesyl - The base syllable templates are running for. This is always the actual syllable independent of multi and char modifiers being used, ie. for non-multi non-char templates, basesyl == syl.
  • j - The loop counter for templates with the loop modifier, runs from 1 to numloops.
  • maxj - The number of loops the current template is running, ie. the value j will have during the last iteration.
  • retime - The retime function, see below.
  • fxgroup - The fxgroup table used to enable/disable fxgroups from being used. See below.

Not all of the variables are set at all times. line, syl and basesyl are reset to nil each time processing starts for a new source line. Everything else is left alone after creation when the templates are first initialised.

This means that you can freely create new variables and functions inside the tenv and expect them to stay there.

[edit] The retime function

Synopsis: retime(mode, addstart, addend)

Changes the timing of the line being generated by the current template. mode specifies what the new line timing should be relative to. addstart and addend are used to adjust the starting and ending times of the new line further. If addstart and addend are left out, they default to zero.

mode is a string, it can take one of the following values:

  • abs or set - Use addstart and addend as absolute time values from the beginning of the time line, simply setting a new start and end time for the line.
  • preline - Intended to make effects that happen before the actual line start. The base start and end times are both set to the line start time and then adjusted by addstart and addend. Usually you will want to use a negative addstart and a zero addend.
  • line - The entire line, ie. this just adjusts the start and end time by the given amounts.
  • start2syl - The time from the start of line to the start of syllable.
  • presyl - Similar to preline but for the syllable timing instead.
  • syl - From start of syllable to end of syllable.
  • postsyl - Similar to presyl but the base timing is the syllable end time instead of start time. You will usually want to use a zero addstart and positive addend here.
  • syl2end - The time from the end of the syllable to the end of line.
  • postline - Similar to postsyl but for the line timing instead.

There is also one special value for mode:

  • sylpct - Use addstart and addend as percentage values of the syllable duration, and add those to the syllable start time to get the new line start and end time.

See also this test-file for examples on how to use retime.

You should never use retime on line templates, but you can safely use it on pre-line templates. Also, using anything but set/abs, preline and postline modes for pre-line templates will not work. Since a set of pre-line and line templates affect the same generated line it's only needed to change the timing once, and using retime on a line template will in fact result in the line timing being changed once for each syllable on the line.

retime changes the line.start_time, line.end_time and line.duration fields. These changes are visible to code blocks appearing later in the same template, but never to dollar-variables in the same template.

Using retime multiple times in one template has undefined behaviour. (So don't do that.)

[edit] The fxgroup table

This table can be used to enable/disable the use of templates declared to be in specific fxgroups.

The fxgroup table is indexed by the names of fxgroups defined. If no entry is defined for an fxgroup (or it's set to nil) the fxgroup is considered enabled. An fxgroup is only considered disabled when fxgroup.groupname == false.

Example:

Comment: 0,0:00:10.00,0:00:15.00,Default,,0000,0000,0000,code syl,fxgroup.long = syl.duration > 200
Comment: 0,0:00:05.00,0:00:10.00,Default,,0000,0000,0000,template syl noblank,all here: 
Comment: 0,0:00:15.00,0:00:20.00,Default,,0000,0000,0000,template syl fxgroup long,is long: 
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0000,0000,0000,,{\k10}huh? {\k40}wee~~

It's important to understand the template execution order to understand this example. For each input syllable (ie. "huh?" and "wee~~") all the templates and code lines are run in the order they appear.

This means that for "huh?", first the code line is run. It determines that the duration of that syllable is less than 200 ms and thus sets fxgroup.long to false. The first template has no fxgroup, so it's applied to the syllable then, outputting a line "all here: huh?", but the second template has fxgroup "long". This fxgroup was disabled for that syllable by the code line, so that template is not run at all.

For "wee~~", the code line determines that its duration is longer than 200 ms, so the "long" fxgroup is enabled. Then the first template outputs its line, "all here: wee~~", and when the second template is to run, its fxgroup is enabled now so it's also run, outputting "is long: wee~~".

Neither of the two templates will output anything for the zero'th syllable. The first template, because it has the "noblank" modifier, and the second because the zero'th syllable's duration is too short for the fxgroup to be enabled.

[edit] Samples of working template

A few samples of templates which have been used in real application.


[edit] Yoroshiku's Kekkaishi ED3 by apih

My first karaoke that was made using templates of Auto4 kara-templater. Styles are included as some effects depend on the specific settings in the styles (usually colors).

;Styles
Style: Kekkaishi ED3 Romaji,Pooh,26,&H00D1EDFA,&H018ACCF2,&H00042637,&H00000000,0,0,0,0,100,100,1,0,1,1.8,0,8,10,10,10,0
Style: Kekkaishi ED3 Trans,Clearly Gothic,25,&H00FFFFFF,&H0100FFFF,&H00000000,&H80000000,0,0,0,0,100,100,0,0,1,0.6,1,2,0,0,5,0

;Romaji
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,,--written by apih
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,,--this template is written to demonstrate the capability of kara-templater, in order to promote its usage
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,,--for references and more detail explanations about kara-templater, please go here; http://www.malakith.net/aegiwiki/Auto4_kara-templater or bug jfs in #aegisub@irc.rizon.net
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,,--for Lua's related references and examples, http://www.lua.org/ and http://lua-users.org/ would be a good place to start
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,,--special thanks to jfs for helping me, listening to my complaints and implementing things that i need into kara-templater
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,,--the shapes are drawn using ai-chan's ASSDraw2
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,code once,math.randomseed(3509)
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,code once,function altRndRot(dur,interval) local dir, codestr = 1, ""; if math.random(0,1) == 0 then dir = -dir end; local count = math.ceil(dur/interval); for i = 1, count do codestr = codestr .. string.format("\\t(%d,%d,\\frz%g)",(i-1)*interval,i*interval,dir*(math.random(5,9)/2)); dir = -dir end; return codestr; end
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,code once,shapes = { "m 6 1 b -2 -5 -9 5 -2 13 l 9 29 l 37 29 l 48 13 b 57 5 51 -5 42 1 l 35 5 l 11 5 l 6 1", "m 9 6 b 11 -2 31 -2 33 6 b 36 26 48 58 33 58 b 25 60 20 57 23 47 b 22 50 20 50 19 47 b 21 57 17 60 9 58 b -9 58 6 26 9 6", "m -6 -5 b -1 -6 4 -6 10 -5 b 11 -1 12 5 12 10 b 6 11 -1 11 -8 10 b -8 5 -8 -1 -6 -5 l -6 -5 l -4 7 b 0 8 4 8 8 7 b 8 4 8 1 7 -2 b 4 -3 0 -3 -3 -2 b -4 0 -4 3 -4 7"}
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,code once,tags = { "\\be1\\bord1.5\\1c&HF4F5F5&\\3c&H000000&\\3a&H30&", "\\be1\\bord1.5\\1c&HF4F5F5&\\3c&H000000&\\3a&H30&", "\\bord0\\1c&H252A29&"}
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,code line,fxgroup.main = orgline.actor == ""; fxgroup.bg = orgline.actor == "bg"; fxgroup.hey = orgline.actor == "hey"
Comment: 1,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,template char noblank,!retime("start2syl",-400+($si-1)*50,0)!{\an5\be1\pos($scenter,$smiddle)\fad(400,0)\1c!line.styleref.color1!\t(\1c!line.styleref.color2!)\fscx0\fscy0\t(0,280,\fscx130\fscy130)\t(280,400,\fscx100\fscy100)}
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,template syl  fxgroup main noblank notext loop 3,!retime("syl",-700,400)!{\an5\move(!$scenter+12!,!$smiddle-33!,!$scenter+2!,!$smiddle-3!,0,700)\fad(400,400)!tags[j]!\fscx20\fscy20\frz45\t(0,700,\fscx35\fscy35\frz0)\t(700,701,\fscx55\fscy55)\t(701,!701+$sdur+300!,\fscx25\fscy25)\p1}!shapes[j]!
Comment: 2,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,template syl  fxgroup main noblank,!retime("syl",0,0)!{\an5\be1\move($scenter,!$smiddle+5!,$scenter,$smiddle)\fscx150\fscy140\t(\fscx100\fscy100)}
Comment: 2,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,template syl  fxgroup main noblank,!retime("syl",0,0)!{\an5\be1\move($scenter,!$smiddle+5!,$scenter,$smiddle)\fad(0,$sdur)\1c&HFFFFFF&\3c&HFFFFFF&\1a&H40&\3a&H40&\fscx150\fscy140\t(\fscx100\fscy100)}
Comment: 1,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,template syl  fxgroup main noblank,!retime("syl2end",0,400-($syln-$si)*20)!{\an5\be1\pos($scenter,$smiddle)\fad(0,300)!altRndRot($ldur-$send+200,500)!}
Comment: 2,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,template syl  fxgroup bg noblank,!retime("syl",0,500)!{\an5\be1\move($scenter,$smiddle,!$scenter-30!,$smiddle)\fad(0,500)\1c!line.styleref.color2!\t(0,$sdur,\fscx120\fscy120\1c!line.styleref.color1!\1a&H70&\3a&H70&)}
Comment: 0,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,template syl  fxgroup hey noblank,!retime("syl",0,300)!{\an5\be1\pos($scenter,$smiddle)\1a&HFF&\3c&H60&\t(\bord3\3a&HFF&)\t(0,$skdur,\fscx140\fscy140)\t($skdur,!$sdur+300!,0.7,\fscx200\fscy200)}
Comment: 2,0:00:00.00,0:00:00.00,Kekkaishi ED3 Romaji,,0000,0000,0000,template syl  fxgroup hey noblank,!retime("syl2end",-$sdur,300)!{\an5\be1\pos($scenter,$smiddle)\fad(0,300)\t(0,$skdur,\fscx140\fscy140)\t($skdur,$sdur,\fscx100\fscy100)}
Comment: 0,0:00:02.00,0:00:08.21,Kekkaishi ED3 Romaji,,0000,0000,0000,,{\an5\pos(320,240)\p1}m 6 1 b -2 -5 -9 5 -2 13 l 9 29 l 37 29 l 48 13 b 57 5 51 -5 42 1 l 35 5 l 11 5 l 6 1
Comment: 0,0:00:02.00,0:00:08.21,Kekkaishi ED3 Romaji,,0000,0000,0000,,{\an5\pos(320,240)\p1}m 9 6 b 11 -2 31 -2 33 6 b 36 26 48 58 33 58 b 25 60 20 57 23 47 b 22 50 20 50 19 47 b 21 57 17 60 9 58 b -9 58 6 26 9 6
Comment: 0,0:00:02.00,0:00:08.21,Kekkaishi ED3 Romaji,,0000,0000,0000,,{\an5\pos(320,240)\p1}m -6 -5 b -1 -6 4 -6 10 -5 b 11 -1 12 5 12 10 b 6 11 -1 11 -8 10 b -8 5 -8 -1 -6 -5 l -6 -5 l -4 7 b 0 8 4 8 8 7 b 8 4 8 1 7 -2 b 4 -3 0 -3 -3 -2 b -4 0 -4 3 -4 7

;Sample lines
Dialogue: 0,0:00:54.73,0:00:57.36,Kekkaishi ED3 Romaji,bg,0372,0020,0038,,{\k38}so{\k23}re {\k29}ga {\k29}hon{\k36}tou {\k25}na{\k83}ra
Dialogue: 0,0:00:56.72,0:01:01.31,Kekkaishi ED3 Romaji,,0000,0000,0000,,{\k28}hi{\k21}tsu{\k28}yo{\k46}u {\k25}i{\k21}jo{\k28}u {\k23}ni{\k22} {\k35}a{\k9}ta{\k11}shi {\k10}wo {\k18}a{\k11}ma{\k15}ya{\k8}ka{\k16}sa{\k22}nai {\k10}de {\k10}ku{\k11}da{\k31}sai
Dialogue: 0,0:01:01.52,0:01:04.75,Kekkaishi ED3 Romaji,hey,0000,0000,0000,,{\k8}pu{\k29}rii{\k17}zu{\k16} {\k8}pu{\k31}rii{\k16}zu{\k17} {\k7}pu{\k158}rii{\k16}zu


[edit] A-E & Saizen's Capeta ED4 by apih

The release's version is a bit different where the stars is at the back of letters. Someone edited it, probably because the stars reduce the readability of the karaoke, XD.

;Styles
Style: Capeta ED4 Romaji,EPSON 太行書体B,25,&H00BEBEBE,&H01F0F0F0,&H001E1E1E,&H0091FCFE,0,0,0,0,100,100,0,0,1,2,0,8,10,10,10,128
Style: Capeta ED4 Kanji,EPSON 太行書体B,20,&H00BEBEBE,&H01F0F0F0,&H001E1E1E,&H0091FCFE,0,0,0,0,100,100,0,0,1,2,0,8,10,10,48,128
Style: Capeta ED4 Trans,EPSON 太行書体B,24,&H00BEBEBE,&H01F0F0F0,&H001E1E1E,&H00000000,0,0,0,0,100,100,0,0,1,2,0,2,10,10,12,128

;Romaji
Comment: 0,0:00:00.00,0:00:00.00,Capeta ED4 Romaji,,0000,0000,0000,code once,math.randomseed(8317)
Comment: 0,0:00:00.00,0:00:00.00,Capeta ED4 Romaji,,0000,0000,0000,code once,temp = {}
Comment: 0,0:00:00.00,0:00:00.00,Capeta ED4 Romaji,,0000,0000,0000,code once,function set_temp(ref,val) temp[ref] = val; return val; end
Comment: 0,0:00:00.00,0:00:00.00,Capeta ED4 Romaji,,0000,0000,0000,template syl noblank,!retime("start2syl",-360+($si-1)*40,0)!{\an5\pos($scenter,$smiddle)\fad(360,0)\be1\1c!line.styleref.color2!}
Comment: 0,0:00:00.00,0:00:00.00,Capeta ED4 Romaji,,0000,0000,0000,template syl noblank,!retime("syl2end",-$sdur,360-($syln-$si)*40)!{\an5\pos($scenter,$smiddle)\fad(0,360)\be1\1c!line.styleref.color1!}
Comment: 1,0:00:00.00,0:00:00.00,Capeta ED4 Romaji,,0000,0000,0000,template syl noblank,!retime("syl",0,360)!{\an5\pos($scenter,$smiddle)\fad(0,!line.duration!)\be1\bord!line.styleref.outline+0.5!\1c!line.styleref.color4!\3c!line.styleref.color4!\t(\bord!line.styleref.outline!}
Comment: 1,0:00:00.00,0:00:00.00,Capeta ED4 Romaji,,0000,0000,0000,template char noblank notext,!retime("syl",-1200,360)!{\an5\org($scenter,$smiddle)\move($scenter,!$smiddle-math.random(30,45)!,$scenter,!$smiddle+math.random(-5,5)!,0,1200)\fad(0,360)\be1\bord1.5\1c&H2EFAFD&\3c&H006263&\3a&H70&\fscx5\fscy5\frz!set_temp("angle",math.random(360))!\t(0,1200,\fscx20\fscy20\frz!temp.angle+math.random(450,600)!\t(1200,1201,\fscx30\fscy30)\p1}m 10 49 l 52 19 l 0 19 l 42 49 l 26 0 l 10 49

;Kanji
Comment: 0,0:00:00.00,0:00:00.00,Capeta ED4 Kanji,,0000,0000,0000,template syl noblank,!retime("start2syl",-360+($si-1)*40,0)!{\an5\pos($scenter,$smiddle)\fad(360,0)\be1\1c!line.styleref.color2!}
Comment: 0,0:00:00.00,0:00:00.00,Capeta ED4 Kanji,,0000,0000,0000,template syl noblank,!retime("syl2end",-$sdur,360-($syln-$si)*40)!{\an5\pos($scenter,$smiddle)\fad(0,360)\be1\1c!line.styleref.color1!}
Comment: 1,0:00:00.00,0:00:00.00,Capeta ED4 Kanji,,0000,0000,0000,template syl noblank,!retime("syl",0,360)!{\an5\pos($scenter,$smiddle)\fad(0,!line.duration!)\be1\bord!line.styleref.outline+0.5!\1c!line.styleref.color4!\3c!line.styleref.color4!\t(\bord!line.styleref.outline!}
Comment: 1,0:00:00.00,0:00:00.00,Capeta ED4 Kanji,,0000,0000,0000,template char noblank notext,!retime("syl",-1200,360)!{\an5\org($scenter,$smiddle)\move($scenter,!$smiddle-math.random(30,45)!,$scenter,!$smiddle+math.random(-5,5)!,0,1200)\fad(0,360)\be1\bord1.5\1c&H2EFAFD&\3c&H006263&\3a&H70&\fscx5\fscy5\frz!set_temp("angle",math.random(360))!\t(0,1200,\fscx20\fscy20\frz!temp.angle+math.random(450,600)!\t(1200,1201,\fscx30\fscy30)\p1}m 10 49 l 52 19 l 0 19 l 42 49 l 26 0 l 10 49

;Translation
Comment: 0,0:00:00.00,0:00:00.00,Capeta ED4 Trans,,0000,0000,0000,template pre-line 1t,!retime("line",-300,300)!{\pos($lcenter,$lbottom)\fad(300,300)\be1}


[edit] SHS-yesy-Ureshii's Witchblade OP by apih

Originally written in Automation 3, back in 2006. It is ported to Auto4 kara-templater's templates for testing purpose, on how to count and get current character index in the line. For the Translation's templates, you need to put \k tag in front of the lines to enable the processing.

;Styles
Style: Witchblade OP Romaji,Formal436 BT,25,&H003A3AF8,&H01FFFFFF,&H00010176,&H00C4C9F4,0,0,0,0,100,100,1,0,1,2,0,8,10,10,10,0
Style: Witchblade OP Trans,Formal436 BT,22,&H003A3AF8,&H01FFFFFF,&H00010176,&H00C4C9F4,0,0,0,0,100,100,1,0,1,2,0,2,10,10,13,0

:Romaji
Comment: 0,0:00:00.00,0:00:00.00,Witchblade OP Romaji,,0000,0000,0000,code once,math.randomseed(3918)
Comment: 0,0:00:00.00,0:00:00.00,Witchblade OP Romaji,,0000,0000,0000,code once,function char_counter(ref) ci[ref] = ci[ref] + 1; return "" end
Comment: 0,0:00:00.00,0:00:00.00,Witchblade OP Romaji,,0000,0000,0000,code line,ci = { 0 }; cn = _G.unicode.len(orgline.text_stripped:gsub(" ",""))
Comment: 0,0:00:00.00,0:00:00.00,Witchblade OP Romaji,,0000,0000,0000,template char noblank,!char_counter(1)!!retime("start2syl",-600+(ci[1]-1)*25,0)!{\an5\be1\fad(400,0)\move(!$scenter+math.random(150,180)!,!$smiddle+math.random(-25,10)!,$scenter,$smiddle,0,400)\1c!line.styleref.color2!\fscx10\fscy10\t(0,400,\fscx100\fscy100)}
Comment: 1,0:00:00.00,0:00:00.00,Witchblade OP Romaji,,0000,0000,0000,template syl noblank loop 4,!retime("syl",0,0)!{\an8\be1\bord!line.styleref.outline+1.5+j!\fad(0,$sdur)\pos($scenter,$stop)\3c!line.styleref.color2!\1a&HFF&\3a&H!string.format("%2X",128+j*16)!&\fscx120\fscy140\t(\bord!line.styleref.outline+0.5+j!\fscx100\fscy100)}
Comment: 1,0:00:00.00,0:00:00.00,Witchblade OP Romaji,,0000,0000,0000,template syl noblank,!retime("syl2end",-$sdur,0)!{\an8\be1\pos($scenter,$stop)\1c!line.styleref.color1!\fscx120\fscy140\t(0,$sdur,\1c!line.styleref.color4!\fscx100\fscy100)}
Comment: 0,0:00:00.00,0:00:00.00,Witchblade OP Romaji,,0000,0000,0000,template syl noblank,!retime("postline",0,600)!{\an8\be1\fad(0,600)\pos($scenter,$stop)\1c!line.styleref.color1!}

;Translation
Comment: 0,0:00:00.00,0:00:00.00,Witchblade OP Trans,,0000,0000,0000,code line,ci = { 0 }; cn = _G.unicode.len(orgline.text_stripped:gsub(" ",""))
Comment: 0,0:00:00.00,0:00:00.00,Witchblade OP Trans,,0000,0000,0000,template char noblank,!char_counter(1)!!retime("preline",-600+(ci[1]-1)*18,-200+cn*18)!{\an5\be1\fad(400,0)\move(!$scenter+math.random(150,180)!,!$smiddle+math.random(-10,25)!,$scenter,$smiddle,0,400)\1c!line.styleref.color2!\fscx10\fscy10\t(0,400,\fscx100\fscy100)}
Comment: 1,0:00:00.00,0:00:00.00,Witchblade OP Trans,,0000,0000,0000,template char noblank,!retime("line",-200+cn*18,0)!{\an5\be1\pos($scenter,$smiddle)\1c!line.styleref.color2!}
Comment: 0,0:00:00.00,0:00:00.00,Witchblade OP Trans,,0000,0000,0000,template char noblank,!retime("postline",0,600)!{\an8\be1\fad(0,600)\pos($scenter,$stop)\1c!line.styleref.color1!}

;Sample lines
Dialogue: 0,0:00:14.17,0:00:17.52,Witchblade OP Romaji,,0000,0000,0000,,{\k42}SHORT {\k33}sun{\k48}zen {\k11}mu{\k9}ne {\k20}ga {\k23}hi{\k23}ki{\k23}sa{\k20}ka{\k20}re{\k26}so{\k37}u
Dialogue: 0,0:00:14.17,0:00:17.52,Witchblade OP Trans,,0000,0000,0000,,{\k362}I'm just about to SHORT, my chest feels like it's gonna burst.


[edit] Ureshii's Sola OP by apih

Originally written in Automation 4, during the early days of it. It's rewritten in templates for testing purpose of vertical positioning (may be buggy?).

;Styles
Style: Sola OP Romaji,CantoriaMT-SemiBold,29,&H00FADEC7,&H01FFFFFF,&H00522907,&H00F09D59,0,0,0,0,100,100,1,0,1,1.5,0,8,10,10,5,0
Style: Sola OP Kanji,@DFGLeiSho-SB,19,&H00FADEC7,&H01FFFFFF,&H00522907,&H00F09D59,-1,0,0,0,100,100,0,-90,1,1.5,0,5,15,10,10,128
Style: Sola OP Trans,CantoriaMT-SemiBold,24,&H00FADEC7,&H01FFFFFF,&H00522907,&H00F09D59,0,0,0,0,100,100,1,0,1,1.5,0,2,10,10,10,0

;Romaji
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,code once,math.randomseed(7501)
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,code once,function char_counter(ref) ci[ref] = ci[ref] + 1; return "" end
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,code once,debris = { "m 0 0 l 0 5 l 5 5 l 5 0 l 0 0", "m 0 0 l 0 5 l 3 8 l 5 0 l 0 0", "m 0 0 l 1 4 l 4 6 l 7 4 l 0 0", "m 0 0 l 0 4 l 6 3 l 7 1 l 0 0", "m 0 0 l 5 2 l 0 5 l 0 0"}
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,code line,ci = { 0 }; cn = _G.unicode.len(orgline.text_stripped:gsub(" ",""))
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,code line,leadout = 200; if line.actor ~= "" then leadout = _G.tonumber(line.actor) end
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,code syl,fxgroup.bounce = syl.tag == "k"; fxgroup.blur = syl.tag == "kf"
Comment: 1,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,template char noblank,!char_counter(1)!!retime("start2syl",-420+(ci[1]-1)*20,0)!{\an5\be1\fade(255,128,0,0,90,90,360)\pos($scenter,$smiddle)\1c!line.styleref.color2!\3c&HFFFFFF&\frx180\t(0,360,\frx0)\t(0,360,2,\3c!line.styleref.color3!)}
Comment: 2,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,template syl noblank fxgroup bounce,!retime("syl",0,-$skdur*9)!{\an5\be1\move($scenter,$smiddle,$scenter,!$smiddle+6!)\1c!line.styleref.color2!\t(\bord!line.styleref.outline+0.5!\1c!line.styleref.color4!\fscx140\fscy140)}
Comment: 2,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,template syl noblank fxgroup bounce,!retime("syl",$skdur,0)!{\an5\be1\bord!line.styleref.outline+0.5!\move($scenter,!$smiddle+6!,$scenter,$smiddle)\1c!line.styleref.color4!\fscx140\fscy140\t(\bord!line.styleref.outline!\1c!line.styleref.color1!\fscx100\fscy100)}
Comment: 2,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,template syl noblank fxgroup blur loop 10,!retime("syl",0,-$skdur*9)!{\an5\be1\move($scenter,$smiddle,$scenter,!$smiddle+6!)\1c!line.styleref.color1!\1a&H!string.format("%2X",158+j*6)!&\3a&H!string.format("%2X",180+j*6)!&\t(\fscx!100+j*10!\fscy!100+j*10!)}
Comment: 2,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,template syl noblank fxgroup blur loop 10,!retime("syl",$skdur,0)!{\an5\be1\move($scenter,!$smiddle+6!,$scenter,$smiddle)\1c!line.styleref.color1!\1a&H!string.format("%2X",158+j*6)!&\3a&H!string.format("%2X",180+j*6)!&\fscx!100+j*10!\fscy!100+j*10!\t(\fscx100\fscy100)}
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,template syl noblank notext loop 18,!retime("syl",0,math.random(40,60)*10)!{\an5\be1\bord0\move(!$scenter+math.random(-5,5)!,!$smiddle+5+math.random(-5,5)!,!$scenter+math.random(-35,35)!,!$smiddle+5+math.random(-35,35)!)\1c!line.styleref.color2!\fscx!math.random(80,100)!\fscy!math.random(80,100)!\t(\frx!math.random(-360,360)!\fry!math.random(-360,360)!\frz!math.random(-360,360)!)\t(2,\1a&HFF&)\p1}!debris[math.random(5)]!
Comment: 1,0:00:00.00,0:00:00.00,Sola OP Romaji,,0000,0000,0000,template syl noblank,!retime("syl2end",0,leadout)!{\an5\be1\fad(0,!leadout!)\pos($scenter,$smiddle)\1c!line.styleref.color1!}

;Kanji
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,code once,function vposx(an) local newx = 0; if an == 1 or an == 2 or an == 3 then newx = curx elseif an == 4 or an == 5 or an == 6 then newx = curx + line.height/2 elseif an == 7 or an == 8 or an == 9 then newx = curx + line.height end; return math.floor(newx+0.5) end
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,code once,function vposy(an) local newy = 0; if an == 1 or an == 4 or an == 7 then if syl then newy = cury+syl.left else newy = cury end; elseif an == 2 or an == 5 or an == 8 then if syl then newy = cury+syl.center else newy = cury+line.width/2 end; elseif an == 3 or an == 6 or an == 9 then if syl then newy = cury+syl.right else newy = cury+line.width end; end; return math.floor(newy+0.5) end
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,code line,curx, cury = orgline.eff_margin_l, (meta.res_y-line.width)/2
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,code line,ci = { 0 }; cn = _G.unicode.len(orgline.text_stripped:gsub("  ",""))
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,code line,leadout = 200; if line.actor ~= "" then leadout = _G.tonumber(line.actor) end
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,code syl,fxgroup.bounce = syl.tag == "k"; fxgroup.blur = syl.tag == "kf"
Comment: 1,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,template char noblank,!char_counter(1)!!retime("start2syl",-420+(ci[1]-1)*45,0)!{\an5\be1\fade(255,128,0,0,90,90,360)\pos(!vposx(5)!,!vposy(5)!)\1c!line.styleref.color2!\3c&HFFFFFF&\fry180\t(0,360,\fry0)\t(0,360,2,\3c!line.styleref.color3!)}
Comment: 2,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,template syl noblank fxgroup bounce,!retime("syl",0,-$skdur*9)!{\an5\be1\move(!vposx(5)!,!vposy(5)!,!vposx(5)+7!,!vposy(5)!)\1c!line.styleref.color2!\t(\bord!line.styleref.outline+0.5!\1c!line.styleref.color4!\fscx150\fscy150)}
Comment: 2,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,template syl noblank fxgroup bounce,!retime("syl",$skdur,0)!{\an5\be1\bord!line.styleref.outline+0.5!\move(!vposx(5)+7!,!vposy(5)!,!vposx(5)!,!vposy(5)!)\1c!line.styleref.color4!\fscx150\fscy150\t(\bord!line.styleref.outline!\1c!line.styleref.color1!\fscx100\fscy100)}
Comment: 2,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,template syl noblank fxgroup blur loop 10,!retime("syl",0,-$skdur*9)!{\an5\be1\move(!vposx(5)!,!vposy(5)!,!vposx(5)+7!,!vposy(5)!)\1c!line.styleref.color1!\1a&H!string.format("%2X",158+j*6)!&\3a&H!string.format("%2X",180+j*6)!&\t(\fscx!100+j*11!\fscy!100+j*11!)}
Comment: 2,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,template syl noblank fxgroup blur loop 10,!retime("syl",$skdur,0)!{\an5\be1\move(!vposx(5)+7!,!vposy(5)!,!vposx(5)!,!vposy(5)!)\1c!line.styleref.color1!\1a&H!string.format("%2X",158+j*6)!&\3a&H!string.format("%2X",180+j*6)!&\fscx!100+j*11!\fscy!100+j*11!\t(\fscx100\fscy100)}
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,template syl noblank notext loop 18,!retime("syl",0,math.random(40,60)*10)!{\an5\be1\bord0\move(!vposx(5)+5+math.random(-5,5)!,!vposy(5)+math.random(-5,5)!,!vposx(5)+5+math.random(-30,30)!,!vposy(5)+math.random(-30,30)!)\1c!line.styleref.color2!\fscx!math.random(70,90)!\fscy!math.random(70,90)!\t(\frx!math.random(-360,360)!\fry!math.random(-360,360)!\frz!-90+math.random(-360,360)!)\t(2,\1a&HFF&)\p1}!debris[math.random(5)]!
Comment: 1,0:00:00.00,0:00:00.00,Sola OP Kanji,,0000,0000,0000,template syl noblank,!retime("syl2end",0,leadout)!{\an5\be1\fad(0,!leadout!)\pos(!vposx(5)!,!vposy(5)!)\1c!line.styleref.color1!}

;Translation
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Trans,,0000,0000,0000,code line,leadout = 200; if line.actor ~= "" then leadout = _G.tonumber(line.actor) end
Comment: 0,0:00:00.00,0:00:00.00,Sola OP Trans,,0000,0000,0000,template pre-line 1t,!retime("line",-250,leadout)!{\be1\fad(300,!leadout!)\pos($lcenter,$lbottom)}

;Sample lines
Dialogue: 0,0:01:13.76,0:01:21.78,Sola OP Romaji,,0000,0000,0000,,{\kf36}wa{\kf34}su{\kf24}re{\kf24}ta{\kf102}i {\kf32}{\kf47}ne{\kf31}ga{\kf34}u {\kf27}ji{\kf44}bu{\kf26}n {\kf106}ga {\kf29}{\k22}wa{\k21}ka{\k48}ra{\k45}na{\k70}i
Dialogue: 0,0:01:22.10,0:01:33.56,Sola OP Romaji,1000,0000,0000,0000,,{\k53}ma{\k26}t{\k47}te{\k45}i{\k76}ru {\k37}{\k35}yu{\k30}ra{\k23}re{\k48}na{\k24}ga{\k158}ra {\k41}{\k38}yu{\k30}me {\k28}hi{\k39}to{\k25}tsu {\k343}wo


[edit] Shinsen-Subs' Chevalier OP by apih

Originally written in Automation 3. These templates demonstrate on how to do color-changing karaoke and vertical fill (like \kf, except it's vertical, done using \clip).

;Styles
Style: Chevalier OP Romaji,DOUGLASPARKfont,26,&H00F7AF84,&H01FFFFFF,&H00622501,&H00000000,-1,0,0,0,100,100,1,0,1,1.5,0,8,10,10,12,0
Style: Chevalier OP Kanji,@DFGKaiSho-Md,22,&H00F7AF84,&H01FFFFFF,&H00622501,&H00000000,-1,0,0,0,100,100,1,-90,1,1.5,0,5,26,26,10,128
Style: Chevalier OP Trans,DOUGLASPARKfont,23,&H00F7AF84,&H01FFFFFF,&H00622501,&H00000000,0,0,0,0,100,100,1,0,1,1.5,0,2,10,10,10,0

;Romaji
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,code once,function time_shifter(s,time_offset,dur) local temp1, temp2 = s:match("(.-)(\\t.+)"); if temp1 == nil then temp1 = s end; local tempcode = temp1; if temp2 ~= nil then for a,b,c in temp2:gmatch("\\t%((%-?%d+),(%-?%d+),(.-)%)") do if (_G.tonumber(b)+time_offset) <= 0 then tempcode = c elseif (_G.tonumber(b)+time_offset) > 0 and (_G.tonumber(a)+time_offset) < dur then tempcode = tempcode .. string.format("\\t(%d,%d,%s)",a+time_offset,b+time_offset,c) end; end; end; return tempcode; end
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,code line,pretag = line.text:match("{(.-)}")
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,code line,leadout = 300; if line.actor ~= "" then leadout = _G.tonumber(line.actor) end
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,code syl,fxgroup.fill = syl.tag == "k"; fxgroup.blur = syl.tag == "kf"
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,template syl noblank,!retime("start2syl",-300+($si-1)*50,0)!{\an5\pos($scenter,$smiddle)\be1\fad(!300+($si-1)*30!,0)!time_shifter(pretag,300-($si-1)*50,line.duration)!\fscx75\fscy75\t(0,150,\fscx125\fscy125)\t(150,300,\fscx100\fscy100)}
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,template syl noblank fxgroup fill,!retime("syl2end",-$sdur,leadour)!{\an5\pos($scenter,$smiddle)\be1\bord!line.styleref.outline+2.5!\fad(0,!leadout!)\3c&HFFFFFF&\1a&HFF&\3a&H70&\t(0,$sdur,\bord!line.styleref.outline+1!\3a&H90&)}
Comment: 1,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,template syl noblank fxgroup fill,!retime("syl2end",-$sdur,leadout)!{\an5\pos($scenter,$smiddle)\be1\bord!line.styleref.outline+1.5!\fad(0,!leadout!)!time_shifter(pretag,-$sstart,line.duration)!\t(0,$sdur,\bord!line.styleref.outline!)}
Comment: 1,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,template syl noblank fxgroup fill,!retime("syl2end",-$sdur,leadout)!{\an5\pos($scenter,$smiddle)\bord0\fad(0,!leadout!)\1c&HFFFFFF&\clip($sleft,0,$sleft,!meta.res_y!)\t(0,$sdur,\clip($sleft,0,$sright,!meta.res_y!))\t($sdur,!line.duration!,1.5,\1a&HFF&)}
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,template syl noblank fxgroup blur,!retime("syl2end",-$sdur,leadout)!{\an5\pos($scenter,$smiddle)\be1\bord!line.styleref.outline+1!\fad(0,!leadout!)\3c&HFFFFFF&\1a&HFF&\3a&H90&\t(0,!$skdur*3!,\fscx130\fscy130)\t(!$skdur*3!,$sdur,\fscx100\fscy100)}
Comment: 1,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,template syl noblank fxgroup blur,!retime("syl2end",-$sdur,leadout)!{\an5\pos($scenter,$smiddle)\be1\fad(0,!leadout!)!time_shifter(pretag,-$sstart,line.duration)!\t(0,!$skdur*3!,\fscx130\fscy130)\t(!$skdur*3!,$sdur,\fscx100\fscy100)}
Comment: 1,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,template syl noblank fxgroup blur loop 5,!retime("syl",0,0)!{\an5\pos($scenter,$smiddle)\be1\1c&HFFFFFF&!time_shifter(pretag:gsub("\\1c%&H%x-%&",""),-$sstart,line.duration)!\1a&H!string.format("%2X",128+j*16)!\3a&H!string.format("%2X",160+j*16)!&\t(0,!$skdur*3!,\fscx!130+j*12!\fscy!130+j*12!)\t(!$skdur*3!,$sdur,\fscx100\fscy100)}
Comment: 1,0:00:00.00,0:00:00.00,Chevalier OP Romaji,,0000,0000,0000,template syl noblank fxgroup blur,!retime("syl2end",0,leadout)!{\an5\pos($scenter,$smiddle)\bord0\fad(0,!leadout!)\1c&HFFFFFF&\t(1.5,\1a&HFF&)}

;Kanji
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,code once,function vposx(an) local newx = 0; if an == 1 or an == 2 or an == 3 then newx = curx elseif an == 4 or an == 5 or an == 6 then newx = curx + line.height/2 elseif an == 7 or an == 8 or an == 9 then newx = curx + line.height end; return math.floor(newx+0.5) end
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,code once,function vposy(an) local newy = 0; if an == 1 or an == 4 or an == 7 then if syl then newy = cury+syl.left else newy = cury end; elseif an == 2 or an == 5 or an == 8 then if syl then newy = cury+syl.center else newy = cury+line.width/2 end; elseif an == 3 or an == 6 or an == 9 then if syl then newy = cury+syl.right else newy = cury+line.width end; end; return math.floor(newy+0.5) end
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,code line,curx, cury = meta.res_x-orgline.eff_margin_l-line.height, (meta.res_y-line.width)/2
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,code line,pretag = line.text:match("{(.-)}")
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,code line,leadout = 300; if line.actor ~= "" then leadout = _G.tonumber(line.actor) end
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,code syl,fxgroup.fill = syl.tag == "k"; fxgroup.blur = syl.tag == "kf"
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,template syl noblank,!retime("start2syl",-300+($si-1)*50,0)!{\an5\pos(!vposx(5)!,!vposy(5)!)\be1\fad(!300+($si-1)*30!,0)!time_shifter(pretag,300-($si-1)*50,line.duration)!\fscx75\fscy75\t(0,150,\fscx125\fscy125)\t(150,300,\fscx100\fscy100)}
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,template syl noblank fxgroup fill,!retime("syl2end",-$sdur,leadour)!{\an5\pos(!vposx(5)!,!vposy(5)!)\be1\bord!line.styleref.outline+2.5!\fad(0,!leadout!)\3c&HFFFFFF&\1a&HFF&\3a&H70&\t(0,$sdur,\bord!line.styleref.outline+1!\3a&H90&)}
Comment: 1,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,template syl noblank fxgroup fill,!retime("syl2end",-$sdur,leadout)!{\an5\pos(!vposx(5)!,!vposy(5)!)\be1\bord!line.styleref.outline+1.5!\fad(0,!leadout!)!time_shifter(pretag,-$sstart,line.duration)!\t(0,$sdur,\bord!line.styleref.outline!)}
Comment: 1,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,template syl noblank fxgroup fill,!retime("syl2end",-$sdur,leadout)!{\an5\pos(!vposx(5)!,!vposy(5)!)\bord0\fad(0,!leadout!)\1c&HFFFFFF&\clip(0,!vposy(1)!,!meta.res_x!,!vposy(1)!)\t(0,$sdur,\clip(0,!vposy(1)!,!meta.res_x!,!vposy(3)!))\t($sdur,!line.duration!,1.5,\1a&HFF&)}
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,template syl noblank fxgroup blur,!retime("syl2end",-$sdur,leadout)!{\an5\pos(!vposx(5)!,!vposy(5)!)\be1\bord!line.styleref.outline+1!\fad(0,!leadout!)\3c&HFFFFFF&\1a&HFF&\3a&H90&\t(0,!$skdur*3!,\fscx130\fscy130)\t(!$skdur*3!,$sdur,\fscx100\fscy100)}
Comment: 1,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,template syl noblank fxgroup blur,!retime("syl2end",-$sdur,leadout)!{\an5\pos(!vposx(5)!,!vposy(5)!)\be1\fad(0,!leadout!)!time_shifter(pretag,-$sstart,line.duration)!\t(0,!$skdur*3!,\fscx130\fscy130)\t(!$skdur*3!,$sdur,\fscx100\fscy100)}
Comment: 1,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,template syl noblank fxgroup blur loop 5,!retime("syl",0,0)!{\an5\pos(!vposx(5)!,!vposy(5)!)\be1\1c&HFFFFFF&!time_shifter(pretag:gsub("\\1c%&H%x-%&",""),-$sstart,line.duration)!\1a&H!string.format("%2X",128+j*16)!\3a&H!string.format("%2X",160+j*16)!&\t(0,!$skdur*3!,\fscx!130+j*15!\fscy!130+j*15!)\t(!$skdur*3!,$sdur,\fscx100\fscy100)}
Comment: 1,0:00:00.00,0:00:00.00,Chevalier OP Kanji,,0000,0000,0000,template syl noblank fxgroup blur,!retime("syl2end",0,leadout)!{\an5\pos(!vposx(5)!,!vposy(5)!)\bord0\fad(0,!leadout!)\1c&HFFFFFF&\t(1.5,\1a&HFF&)}

;Translation
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Trans,,0000,0000,0000,code line,pretag = line.text:match("{(.-)}")
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Trans,,0000,0000,0000,code line,leadout = 300; if line.actor ~= "" then leadout = _G.tonumber(line.actor) end
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Trans,,0000,0000,0000,template pre-line 1t,!retime("line",-200,leadout)!{\be1\bord!line.styleref.outline+1!\fad(200,!leadout!)\pos($lcenter,$lbottom)\3c&HFFFFFF&\1a&HFF&\3a&H90&}
Comment: 0,0:00:00.00,0:00:00.00,Chevalier OP Trans,,0000,0000,0000,template pre-line 2t,!retime("line",-200,leadout)!{\be1\fad(200,!leadout!)\pos($lcenter,$lbottom)!time_shifter(pretag,200,line.duration)!}

;Sample lines
Dialogue: 0,0:00:12.49,0:00:16.46,Chevalier OP Romaji,,0000,0000,0000,,{\1c&HF7AF84&\3c&H622501&}{\k72}Na{\k35}mi{\k32}da {\k31}ga {\k18}o{\k16}chi{\k36}ta {\k18}a{\k34}to {\k32}da{\k73}tte
Dialogue: 0,0:00:32.92,0:00:38.06,Chevalier OP Romaji,,0000,0000,0000,,{\1c&HDEA69D&\3c&H4A2019&\t(2239,2240,\1c&HCBDAA1&\3c&H3B471C&)\t(4741,4742,\1c&HBCBFBD&\3c&H313231&)}{\kf39}Da{\kf32}ke{\kf168}do {\k33}{\k39}shin{\k18}ji{\k40}te{\k24}i{\k36}ki{\k40}ta{\k45}i
Dialogue: 0,0:01:13.87,0:01:20.00,Chevalier OP Romaji,1000,0000,0000,0000,,{\1c&HDEA69D&\3c&H4A2019&\t(579,996,\1c&H837DFF&\3c&H020064&)}{\kf36}A{\kf31}ta{\kf31}ra{\kf22}shi{\kf37}ku {\kf25}u{\kf56}ma{\kf29}re{\kf37}ta {\kf31}wa{\kf32}ta{\kf24}shi {\kf29}ga {\kf33}i{\kf160}ru
Dialogue: 0,0:00:12.49,0:00:16.46,Chevalier OP Trans,,0000,0000,0000,,{\1c&HF7AF84&\3c&H622501&}Even as tear flows no more,
Dialogue: 0,0:01:13.87,0:01:20.00,Chevalier OP Trans,1000,0000,0000,0000,,{\1c&HDEA69D&\3c&H4A2019&\t(579,996,\1c&H837DFF&\3c&H020064&)}There I am reborn again.
Personal tools