Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How can I make a millisecond retiming applescript for LRC (karaoke) files?

Hi, I work for a karaoke company making LRC files which play lyrics on our app. We currently have a number of applescripts we use to "retime" the LRC's if they are wrong. We already have a working script which I've included below that works great for adding and subtracting whole seconds from each line of an LRC file but we do not have one for adding and subtracting milliseconds. I am using version 2.7 of Script Editor on my MacBook Pro 10.10.3, Mac OS Extended (Journaled)


Would love any help in creating this script and can provide any additional info needed. Thanks!


Here's the whole second retiming script:

set the_text to "[ti:The Wonderful Thing About Tiggers]

[ar:Winnie The Pooh]

[la:en]

[00:03.00]<00:03.75>THE WONDERFUL

[00:04.15]<00:04.15>THING ABOUT TIGGERS

[00:04.94]<00:04.94>IS TIGGERS ARE

[00:05.34]<00:05.34>WONDERFUL THINGS"


set new_text to ""

repeat with this_paragraph from 1 to 3

set new_text to new_text & paragraphthis_paragraph of the_text & return

end repeat

repeat with this_paragraph from 4 to (countparagraphs of the_text)

set the_paragraph to paragraphthis_paragraph of the_text

set new_number to (items 15 thru 16 of the_paragraph as string as number) - 3

set new_number2 to (items 12 thru 13 of the_paragraph as string as number)

if this_paragraph = 4 then

if new_number > 59 then

set new_number to new_number - 60

set new_number2 to new_number2 + 1

if new_number < 10 then

if new_number = 9 then

set new_text to new_text & ((items 1 thru 2 of the_paragraph) & new_number2 & (item 4 of the_paragraph) & 0 & new_number & (item 7 of the_paragraph) & (items 18 thru 19 of the_paragraph) & (items 10 thru 12 of the_paragraph) & new_number2 & (item 14 of the_paragraph) & new_number + 1 & (items 17 thru -1 of the_paragraph)) & return as string

else

set new_text to new_text & ((items 1 thru 2 of the_paragraph) & new_number2 & (item 4 of the_paragraph) & 0 & new_number & (item 7 of the_paragraph) & (items 18 thru 19 of the_paragraph) & (items 10 thru 12 of the_paragraph) & new_number2 & (item 14 of the_paragraph) & 0 & new_number + 1 & (items 17 thru -1 of the_paragraph)) & return as string

end if

else

set new_text to new_text & ((items 1 thru 2 of the_paragraph) & new_number2 & (item 4 of the_paragraph) & new_number & (item 7 of the_paragraph) & (items 18 thru 19 of the_paragraph) & (items 10 thru 12 of the_paragraph) & new_number2 & (item 14 of the_paragraph) & new_number + 1 & (items 17 thru -1 of the_paragraph)) & return as string

end if

else

if new_number < 0 then

set new_number to new_number + 60

set new_number2 to new_number2 - 1

set new_text to new_text & ((items 1 thru 2 of the_paragraph) & new_number2 & (item 4 of the_paragraph) & new_number & (item 7 of the_paragraph) & (items 18 thru 19 of the_paragraph) & (items 10 thru 12 of the_paragraph) & new_number2 & (item 14 of the_paragraph) & (new_number + 1) & (items 17 thru -1 of the_paragraph)) & return as string

else

if new_number < 10 then

set new_text to new_text & ((items 1 thru 4 of the_paragraph) & 0 & new_number & (item 7 of the_paragraph) & (items 18 thru 19 of the_paragraph) & (items 10 thru 14 of the_paragraph) & 0 & (new_number + 1) & (items 17 thru -1 of the_paragraph)) & return as string

else

set new_text to new_text & ((items 1 thru 4 of the_paragraph) & (new_number - 1) & (item 7 of the_paragraph) & (items 18 thru 19 of the_paragraph) & (items 10 thru 14 of the_paragraph) & new_number & (items 17 thru -1 of the_paragraph)) & return as string

end if

end if

end if

else

if new_number > 59 then

set new_number to new_number - 60

set new_number2 to new_number2 + 1

if new_number < 10 then

set new_text to new_text & ((items 1 thru 2 of the_paragraph) & new_number2 & (item 4 of the_paragraph) & 0 & new_number & (item 7 of the_paragraph) & (items 18 thru 19 of the_paragraph) & (items 10 thru 12 of the_paragraph) & new_number2 & (item 14 of the_paragraph) & 0 & new_number & (items 17 thru -1 of the_paragraph)) & return as string

else

set new_text to new_text & ((items 1 thru 2 of the_paragraph) & new_number2 & (item 4 of the_paragraph) & new_number & (item 7 of the_paragraph) & (items 18 thru 19 of the_paragraph) & (items 10 thru 12 of the_paragraph) & new_number2 & (item 14 of the_paragraph) & new_number & (items 17 thru -1 of the_paragraph)) & return as string

end if

else

if new_number < 0 then

set new_number to new_number + 60

set new_number2 to new_number2 - 1

set new_text to new_text & ((items 1 thru 2 of the_paragraph) & new_number2 & (item 4 of the_paragraph) & new_number & (item 7 of the_paragraph) & (items 18 thru 19 of the_paragraph) & (items 10 thru 12 of the_paragraph) & new_number2 & (item 14 of the_paragraph) & new_number & (items 17 thru -1 of the_paragraph)) & return as string

else

if new_number < 10 then

set new_text to new_text & ((items 1 thru 4 of the_paragraph) & 0 & new_number & (item 7 of the_paragraph) & (items 18 thru 19 of the_paragraph) & (items 10 thru 14 of the_paragraph) & 0 & new_number & (items 17 thru -1 of the_paragraph)) & return as string

else

set new_text to new_text & ((items 1 thru 4 of the_paragraph) & new_number & (item 7 of the_paragraph) & (items 18 thru 19 of the_paragraph) & (items 10 thru 14 of the_paragraph) & new_number & (items 17 thru -1 of the_paragraph)) & return as string

end if

end if

end if

end if

end repeat

Result:

"[ti:The Wonderful Thing About Tiggers]

[ar:Winnie The Pooh]

[la:en]

[00:00.75]<00:01.75>THE WONDERFUL

[00:01.15]<00:01.15>THING ABOUT TIGGERS

[00:01.94]<00:01.94>IS TIGGERS ARE

[00:02.34]<00:02.34>WONDERFUL THINGS

"

Apple Script Editor-OTHER, OS X Yosemite (10.10.3)

Posted on Oct 5, 2015 1:14 PM

Reply
1 reply

How can I make a millisecond retiming applescript for LRC (karaoke) files?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.