botanic 0 Posted September 6, 2007 I am trying to convert something in the notation of "Measures : Beats : Division" into seconds. I have the key signature as well as the BPM and the Division just my script is returning wrong values. I believe part of the problem is that all 3 categories are not there every time, for example: 16: 1: 0 2: 0 3: 0 24 48 if $tempstring <> " 1: 1: 0 " Then $tempstring = StringReplace($tempstring, " ", "") $tempstring = StringReplace($tempstring, " ", "") $tempstring = StringSplit( $tempstring, ":") if $tempstring[0] = 1 Then $beatdif = $tempstring[1] - $beat3 if $beatdif < 0 then $beatdif = $division + $beatdif $beat3 = $tempstring[1] $tempstring = (($beatdif/$division)*$BPM)/60 ElseIf $tempstring[0] = 2 Then $beatdif = ($tempstring[1] - $beat2) &":"& ($tempstring[2] - $beat3) $beatdif = StringSplit($beatdif, ":") $beat2 = $tempstring[1] $beat3 = $tempstring[2] if $beatdif[1] < 0 then $beatdif[1] = StringLeft($keysig, 1) + $beatdif if $beatdif[2] < 0 then $beatdif[2] = $division + $beatdif $tempstring = (($beatdif[1] + $beatdif[2]/$division)*$BPM)/60 ElseIf $tempstring[0] = 3 then $beatdif = $tempstring[1] & ":"& ($tempstring[2] - $beat2) &":"& ($tempstring[3] - $beat3) $beatdif = StringSplit($beatdif, ":") $beat = $tempstring[1] $beat2 = $tempstring[2] $beat3 = $tempstring[3] if $beatdif[2] < 0 then $beatdif[2] = StringLeft($keysig, 1) + $beatdif if $beatdif[3] < 0 then $beatdif[3] = 192 + $beatdif $tempstring = ((($beatdif[1] * StringRight($keysig, 1)-$beat) + $beatdif[2] + $beatdif[3]/$division)*$BPM)/60 EndIf EndIf Share this post Link to post Share on other sites
GMK 25 Posted September 6, 2007 I'm still playing with it and trying to fully understand what you're after here, but perhaps using StringRegExp would help for those lines where not all categories are there. Share this post Link to post Share on other sites
botanic 0 Posted September 6, 2007 Basically im trying to get the seconds where the "Measures" * $keysig = Beats, Beats / BPM = seconds (i think my math is wrong there), and Division = Division/$Division Beats Its kinda complicated I know but I hope that helps clear it up Share this post Link to post Share on other sites
GMK 25 Posted September 6, 2007 Basically im trying to get the seconds where the "Measures" * $keysig = Beats, Beats / BPM = seconds (i think my math is wrong there), and Division = Division/$Division BeatsIts kinda complicated I know but I hope that helps clear it upLet me see if I understand this right, though I'm still not quite sure I understand divisions (is that like 8ths or 16ths?). For example:Time signature (not key signature ) = 4/4Tempo (BPM) = 120 BPM120 BPM = 120 beats per 60 seconds (120/60) = 2 BPS (beats per second), so 1 BEAT = 0.5 sec.16:1:0 = (16 * 4) + 1 * 0.5 = 65 beats in 32.5 sec.Clear as mud? Share this post Link to post Share on other sites