Karaoke: Remember/Recall and Inline Variables

Discuss and get help for karaoke effect creation here

Karaoke: Remember/Recall and Inline Variables

Unread postby nesa » Tue Nov 01, 2016 5:00 am

Goal: I want to clip syllables in an alternating/random fashion for karaoke. (for example: clip the top half of syllable 1, clip the bottom half of syllable 2, clip the top half of syllable 3, clip the bottom half of syllable 4 and so on...)

I have two clippings I want to alternate between; clip2 = {"$sleft, $smiddle, $scenter, $sbottom" ,"m $sleft $smiddle l $sleft $sbottom $scenter $sbottom" }


When I do:
Input1:
!retime("syl",0,0)!{!remember("a",clip2[math.random(2)])!}{\1a&H00&\2a&HFF&\clip(m $sleft !$smiddle-20! l $sleft !$sbottom-20! !$scenter+5! !$sbottom-20!)\bord5.5\3c&HFFFFFF&\pos($center,!$middle+30!)\t(0,$kdur,\kf$kdur\1c!color4[($si+Random)%4+1]!)}

Output1:
{m $sleft $smiddle l $sleft $sbottom $scenter $sbottom}{\1a&H00&\2a&HFF&\clip(m 769 920 l 769 960 801 960)\bord5.5\3c&HFFFFFF&\pos(796,970)\t(0,134,\kf134\1c&H8942F2&)}番

Notes: Clipping went well as planned and \clip(m $sleft !$smiddle-20! l $sleft !$sbottom-20! !$scenter+5! !$sbottom-20!) took effect

But if I do:
Input2:
!retime("syl",0,0)!{!remember("a",clip2[math.random(2)])!}{\1a&H00&\2a&HFF&\clip(!recall("a")!)\bord5.5\3c&HFFFFFF&\pos($center,!$middle+30!)\t(0,$kdur,\kf$kdur\1c!color4[($si+Random)%4+1]!)}

Output2:
{m $sleft $smiddle l $sleft $sbottom $scenter $sbottom}{\1a&H00&\2a&HFF&\clip(m $sleft $smiddle l $sleft $sbottom $scenter $sbottom)\bord5.5\3c&HFFFFFF&\pos(796,970)\t(0,134,\kf134\1c&H8942F2&)}番

Notes: In this case, I actually used remember/recall to try and randomize my clippings, but nothing happened, I did not see any clippings. I thought there would be coordinates in \clip, but it was \clip(m $sleft $smiddle l $sleft $sbottom $scenter $sbottom) that came out as the output.

I want to use remember/recall to alternate/randomize my clipping effect, however for some reason, it doesn't work. The inline variables as outputs don't translate into the coordinates needed for some reason. Does anyone have any idea why and how I can bypass this (maybe there is a better approach to doing this?)

Warm Regards,

nesa
nesa
Comic Sans MS
Comic Sans MS
 
Posts: 2
Joined: Tue Nov 01, 2016 4:32 am

Re: Karaoke: Remember/Recall and Inline Variables

Unread postby LeSaint » Wed Nov 02, 2016 12:49 pm

Hello,

The problem here is that the variables are not interpreted in your clip2 array, so you get exactly the text you have in your clip2. A solution can be to create a function that will output the clip code with the values you want:
Example:
Code: Select all
Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,function applyclip(index, center, bottom, middle, left) if(index==1) then retval = string.format("%s, %s, %s, %s", left, middle, center, bottom) else retval = string.format("m %s %s l %s %s %s %s", left, middle, left, bottom, center, bottom) end return retval end


And you can use it like this:
Code: Select all
Comment: 0,0:00:05.00,0:00:05.00,Default,,0,0,0,template syl,!retime("syl",0,0)!{!remember("a",applyclip(math.random(2), $scenter, $sbottom, $smiddle, $sleft))!}{\1a&H00&\2a&HFF&\clip(!recall("a")!)\bord5.5\3c&HFFFFFF&\pos($center,!$middle+30!)\t(0,$kdur,\kf$kdur\1c!color4[($si+Random)%4+1]!)}


I don't have your entire script, so I'm not able to test the effect, but the function should work correctly. You can search for Lua reference to get more details about Lua functions if you need.

Have fun,
User avatar
LeSaint
Moderator
Moderator
 
Posts: 252
Joined: Wed Feb 10, 2010 8:19 pm

Re: Karaoke: Remember/Recall and Inline Variables

Unread postby nesa » Thu Nov 03, 2016 3:42 am

thank you, that was very helpful.
nesa
Comic Sans MS
Comic Sans MS
 
Posts: 2
Joined: Tue Nov 01, 2016 4:32 am


Return to Karaoke

Who is online

Users browsing this forum: No registered users and 1 guest